Refactor to move chrome_page_zoom functions to components/ui/zoom.
This refactor will allow non-chrome builds to access the functionality formerly provided by chrome_page_zoom. BUG=none TBR=sky@chromium.org Review URL: https://codereview.chromium.org/847703003 Cr-Commit-Position: refs/heads/master@{#311719}
This commit is contained in:
chrome
browser
browser_commands_unittest.ccchrome_page_zoom.hchrome_page_zoom_constants.h
chrome_browser.gypichrome_tests_unit.gypidevtools
guest_view
mime_handler_view
profiles
resources
pdf
ui
components
pdf
@ -4,7 +4,6 @@
|
||||
|
||||
#include "chrome/app/chrome_command_ids.h"
|
||||
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/ui/browser_command_controller.h"
|
||||
#include "chrome/browser/ui/browser_commands.h"
|
||||
#include "chrome/browser/ui/browser_finder.h"
|
||||
@ -14,6 +13,7 @@
|
||||
#include "chrome/test/base/testing_profile.h"
|
||||
#include "components/bookmarks/browser/bookmark_model.h"
|
||||
#include "components/bookmarks/test/bookmark_test_helpers.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "components/ui/zoom/zoom_controller.h"
|
||||
#include "content/public/browser/navigation_controller.h"
|
||||
#include "content/public/browser/navigation_entry.h"
|
||||
@ -241,7 +241,7 @@ TEST_F(BrowserCommandsTest, OnMaxZoomIn) {
|
||||
|
||||
// Continue to zoom in until zoom percent reaches 500.
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
chrome_page_zoom::Zoom(contents1, content::PAGE_ZOOM_IN);
|
||||
ui_zoom::PageZoom::Zoom(contents1, content::PAGE_ZOOM_IN);
|
||||
}
|
||||
|
||||
// TODO(a.sarkar.arun@gmail.com): Figure out why Zoom-In menu item is not
|
||||
@ -266,7 +266,7 @@ TEST_F(BrowserCommandsTest, OnMaxZoomOut) {
|
||||
|
||||
// Continue to zoom out until zoom percent reaches 25.
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
chrome_page_zoom::Zoom(contents1, content::PAGE_ZOOM_OUT);
|
||||
ui_zoom::PageZoom::Zoom(contents1, content::PAGE_ZOOM_OUT);
|
||||
}
|
||||
|
||||
ZoomController* zoom_controller = ZoomController::FromWebContents(contents1);
|
||||
@ -284,7 +284,7 @@ TEST_F(BrowserCommandsTest, OnZoomReset) {
|
||||
content::WebContents* contents1 = tab_strip_model->GetWebContentsAt(0);
|
||||
|
||||
// Change the zoom percentage to 100.
|
||||
chrome_page_zoom::Zoom(contents1, content::PAGE_ZOOM_RESET);
|
||||
ui_zoom::PageZoom::Zoom(contents1, content::PAGE_ZOOM_RESET);
|
||||
|
||||
ZoomController* zoom_controller = ZoomController::FromWebContents(contents1);
|
||||
EXPECT_EQ(zoom_controller->GetZoomPercent(), 100.0f);
|
||||
@ -302,7 +302,7 @@ TEST_F(BrowserCommandsTest, OnZoomLevelChanged) {
|
||||
|
||||
// Changing zoom percentage from default should enable all the zoom
|
||||
// NSMenuItems.
|
||||
chrome_page_zoom::Zoom(contents1, content::PAGE_ZOOM_IN);
|
||||
ui_zoom::PageZoom::Zoom(contents1, content::PAGE_ZOOM_IN);
|
||||
|
||||
ZoomController* zoom_controller = ZoomController::FromWebContents(contents1);
|
||||
EXPECT_EQ(zoom_controller->GetZoomPercent(), 110.0f);
|
||||
@ -333,7 +333,7 @@ TEST_F(BrowserCommandsTest, OnZoomChangedForActiveTab) {
|
||||
|
||||
tab_strip_model->ActivateTabAt(1, true);
|
||||
EXPECT_TRUE(tab_strip_model->IsTabSelected(1));
|
||||
chrome_page_zoom::Zoom(contents2, content::PAGE_ZOOM_OUT);
|
||||
ui_zoom::PageZoom::Zoom(contents2, content::PAGE_ZOOM_OUT);
|
||||
|
||||
zoom_controller = ZoomController::FromWebContents(contents2);
|
||||
EXPECT_EQ(zoom_controller->GetZoomPercent(), 90.0f);
|
||||
|
@ -1,32 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CHROME_BROWSER_CHROME_PAGE_ZOOM_H_
|
||||
#define CHROME_BROWSER_CHROME_PAGE_ZOOM_H_
|
||||
|
||||
#include <vector>
|
||||
#include "content/public/common/page_zoom.h"
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
namespace chrome_page_zoom {
|
||||
|
||||
// Return a sorted vector of zoom factors. The vector will consist of preset
|
||||
// values along with a custom value (if the custom value is not already
|
||||
// represented.)
|
||||
std::vector<double> PresetZoomFactors(double custom_factor);
|
||||
|
||||
// Return a sorted vector of zoom levels. The vector will consist of preset
|
||||
// values along with a custom value (if the custom value is not already
|
||||
// represented.)
|
||||
std::vector<double> PresetZoomLevels(double custom_level);
|
||||
|
||||
// Adjusts the zoom level of |web_contents|.
|
||||
void Zoom(content::WebContents* web_contents, content::PageZoom zoom);
|
||||
|
||||
} // namespace chrome_page_zoom
|
||||
|
||||
#endif // CHROME_BROWSER_CHROME_PAGE_ZOOM_H_
|
@ -1,20 +0,0 @@
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CHROME_BROWSER_CHROME_PAGE_ZOOM_CONSTANTS_H_
|
||||
#define CHROME_BROWSER_CHROME_PAGE_ZOOM_CONSTANTS_H_
|
||||
|
||||
#include "base/basictypes.h"
|
||||
|
||||
namespace chrome_page_zoom {
|
||||
|
||||
// Zoom factors supported by the browser.
|
||||
extern const double kPresetZoomFactors[];
|
||||
|
||||
// Size of |kPresetZoomFactors|.
|
||||
extern const size_t kPresetZoomFactorsSize;
|
||||
|
||||
} // namespace chrome_page_zoom
|
||||
|
||||
#endif // CHROME_BROWSER_CHROME_PAGE_ZOOM_CONSTANTS_H_
|
@ -14,7 +14,6 @@
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/devtools/devtools_target_impl.h"
|
||||
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
|
||||
#include "chrome/browser/infobars/infobar_service.h"
|
||||
@ -33,6 +32,7 @@
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "components/infobars/core/confirm_infobar_delegate.h"
|
||||
#include "components/infobars/core/infobar.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "content/public/browser/favicon_status.h"
|
||||
#include "content/public/browser/invalidate_type.h"
|
||||
#include "content/public/browser/navigation_controller.h"
|
||||
@ -621,15 +621,15 @@ void DevToolsUIBindings::SetWhitelistedShortcuts(
|
||||
}
|
||||
|
||||
void DevToolsUIBindings::ZoomIn() {
|
||||
chrome_page_zoom::Zoom(web_contents(), content::PAGE_ZOOM_IN);
|
||||
ui_zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_IN);
|
||||
}
|
||||
|
||||
void DevToolsUIBindings::ZoomOut() {
|
||||
chrome_page_zoom::Zoom(web_contents(), content::PAGE_ZOOM_OUT);
|
||||
ui_zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_OUT);
|
||||
}
|
||||
|
||||
void DevToolsUIBindings::ResetZoom() {
|
||||
chrome_page_zoom::Zoom(web_contents(), content::PAGE_ZOOM_RESET);
|
||||
ui_zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_RESET);
|
||||
}
|
||||
|
||||
static void InspectTarget(Profile* profile, DevToolsTargetImpl* target) {
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "base/prefs/scoped_user_pref_update.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/file_select_helper.h"
|
||||
#include "chrome/browser/infobars/infobar_service.h"
|
||||
#include "chrome/browser/prefs/pref_service_syncable.h"
|
||||
@ -31,6 +30,7 @@
|
||||
#include "chrome/common/render_messages.h"
|
||||
#include "chrome/common/url_constants.h"
|
||||
#include "components/pref_registry/pref_registry_syncable.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "components/ui/zoom/zoom_controller.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
@ -691,7 +691,7 @@ DevToolsWindow::DevToolsWindow(Profile* profile,
|
||||
|
||||
// Bindings take ownership over devtools as its delegate.
|
||||
bindings_->SetDelegate(this);
|
||||
// DevTools uses chrome_page_zoom::Zoom(), so main_web_contents_ requires a
|
||||
// DevTools uses PageZoom::Zoom(), so main_web_contents_ requires a
|
||||
// ZoomController.
|
||||
ui_zoom::ZoomController::CreateForWebContents(main_web_contents_);
|
||||
ui_zoom::ZoomController::FromWebContents(main_web_contents_)
|
||||
@ -881,8 +881,8 @@ void DevToolsWindow::CloseContents(WebContents* source) {
|
||||
|
||||
void DevToolsWindow::ContentsZoomChange(bool zoom_in) {
|
||||
DCHECK(is_docked_);
|
||||
chrome_page_zoom::Zoom(main_web_contents_,
|
||||
zoom_in ? content::PAGE_ZOOM_IN : content::PAGE_ZOOM_OUT);
|
||||
ui_zoom::PageZoom::Zoom(main_web_contents_, zoom_in ? content::PAGE_ZOOM_IN
|
||||
: content::PAGE_ZOOM_OUT);
|
||||
}
|
||||
|
||||
void DevToolsWindow::BeforeUnloadFired(WebContents* tab,
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
#include "chrome/browser/guest_view/mime_handler_view/chrome_mime_handler_view_guest_delegate.h"
|
||||
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
|
||||
#include "chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.h"
|
||||
#include "components/pdf/browser/pdf_web_contents_helper.h"
|
||||
#include "components/renderer_context_menu/context_menu_delegate.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
|
||||
|
||||
#if defined(ENABLE_PRINTING)
|
||||
@ -50,7 +50,7 @@ void ChromeMimeHandlerViewGuestDelegate::AttachHelpers() {
|
||||
void ChromeMimeHandlerViewGuestDelegate::ChangeZoom(bool zoom_in) {
|
||||
// TODO(lazyboy): Move this to //extensions once ZoomController and friends
|
||||
// move to //extensions.
|
||||
chrome_page_zoom::Zoom(
|
||||
ui_zoom::PageZoom::Zoom(
|
||||
guest_->embedder_web_contents(),
|
||||
zoom_in ? content::PAGE_ZOOM_IN : content::PAGE_ZOOM_OUT);
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/profiles/profile_impl.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
@ -31,6 +30,7 @@
|
||||
#include "chrome/test/base/testing_profile.h"
|
||||
#include "chrome/test/base/ui_test_utils.h"
|
||||
#include "components/signin/core/common/profile_management_switches.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "components/ui/zoom/zoom_event_manager.h"
|
||||
#include "content/public/test/test_utils.h"
|
||||
#include "net/dns/mock_host_resolver.h"
|
||||
@ -302,12 +302,12 @@ IN_PROC_BROWSER_TEST_F(HostZoomMapBrowserTest, ToggleDefaultZoomLevel) {
|
||||
|
||||
content::WebContents* web_contents =
|
||||
browser()->tab_strip_model()->GetActiveWebContents();
|
||||
chrome_page_zoom::Zoom(web_contents, content::PAGE_ZOOM_OUT);
|
||||
ui_zoom::PageZoom::Zoom(web_contents, content::PAGE_ZOOM_OUT);
|
||||
observer.BlockUntilZoomLevelForHostHasChanged(test_url2.host());
|
||||
EXPECT_FALSE(
|
||||
content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2)));
|
||||
|
||||
chrome_page_zoom::Zoom(web_contents, content::PAGE_ZOOM_IN);
|
||||
ui_zoom::PageZoom::Zoom(web_contents, content::PAGE_ZOOM_IN);
|
||||
observer.BlockUntilZoomLevelForHostHasChanged(test_url2.host());
|
||||
EXPECT_TRUE(
|
||||
content::ZoomValuesEqual(default_zoom_level, GetZoomLevel(test_url2)));
|
||||
|
@ -67,7 +67,7 @@ Viewport.SCROLL_INCREMENT = 40;
|
||||
/**
|
||||
* Predefined zoom factors to be used when zooming in/out. These are in
|
||||
* ascending order. This should match the list in
|
||||
* chrome/browser/chrome_page_zoom_constants.cc.
|
||||
* components/ui/zoom/page_zoom_constants.h
|
||||
*/
|
||||
Viewport.ZOOM_FACTORS = [0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1,
|
||||
1.1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5];
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "chrome/browser/browser_shutdown.h"
|
||||
#include "chrome/browser/character_encoding.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
|
||||
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
|
||||
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "chrome/browser/browsing_data/browsing_data_helper.h"
|
||||
#include "chrome/browser/browsing_data/browsing_data_remover.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/devtools/devtools_window.h"
|
||||
#include "chrome/browser/dom_distiller/tab_utils.h"
|
||||
#include "chrome/browser/favicon/favicon_tab_helper.h"
|
||||
@ -61,6 +60,7 @@
|
||||
#include "components/bookmarks/browser/bookmark_utils.h"
|
||||
#include "components/google/core/browser/google_util.h"
|
||||
#include "components/translate/core/browser/language_state.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "components/ui/zoom/zoom_controller.h"
|
||||
#include "components/web_modal/popup_manager.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
@ -971,8 +971,8 @@ void FindInPage(Browser* browser, bool find_next, bool forward_direction) {
|
||||
}
|
||||
|
||||
void Zoom(Browser* browser, content::PageZoom zoom) {
|
||||
chrome_page_zoom::Zoom(browser->tab_strip_model()->GetActiveWebContents(),
|
||||
zoom);
|
||||
ui_zoom::PageZoom::Zoom(browser->tab_strip_model()->GetActiveWebContents(),
|
||||
zoom);
|
||||
}
|
||||
|
||||
void FocusToolbar(Browser* browser) {
|
||||
|
@ -6,10 +6,10 @@
|
||||
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#import "chrome/browser/ui/cocoa/info_bubble_view.h"
|
||||
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "components/ui/zoom/zoom_controller.h"
|
||||
#include "content/public/common/page_zoom.h"
|
||||
#include "skia/ext/skia_utils_mac.h"
|
||||
@ -314,7 +314,7 @@ void SetZoomBubbleAutoCloseDelayForTesting(NSTimeInterval time_interval) {
|
||||
// there haven't been associated crashes in the wild, so it seems
|
||||
// fine in practice. It might make sense to close the bubble in
|
||||
// that case, though.
|
||||
chrome_page_zoom::Zoom(webContents, alterPageZoom);
|
||||
ui_zoom::PageZoom::Zoom(webContents, alterPageZoom);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/auto_reset.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/browser_window.h"
|
||||
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
|
||||
@ -14,6 +13,7 @@
|
||||
#include "chrome/browser/ui/tabs/tab_strip_model.h"
|
||||
#include "chrome/browser/ui/toolbar/test_toolbar_model.h"
|
||||
#include "chrome/test/base/in_process_browser_test.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "content/public/browser/host_zoom_map.h"
|
||||
#include "content/public/test/test_utils.h"
|
||||
|
||||
@ -56,7 +56,7 @@ class ZoomDecorationTest : public InProcessBrowserTest {
|
||||
browser()->tab_strip_model()->GetActiveWebContents();
|
||||
|
||||
base::AutoReset<bool> reset(&should_quit_on_zoom_, true);
|
||||
chrome_page_zoom::Zoom(web_contents, zoom);
|
||||
ui_zoom::PageZoom::Zoom(web_contents, zoom);
|
||||
content::RunMessageLoop();
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
|
||||
#include "chrome/browser/extensions/window_controller.h"
|
||||
#include "chrome/browser/favicon/favicon_tab_helper.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "chrome/browser/ui/browser_navigator.h"
|
||||
#include "chrome/browser/ui/panels/panel.h"
|
||||
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "components/ui/zoom/zoom_controller.h"
|
||||
#include "content/public/browser/invalidate_type.h"
|
||||
#include "content/public/browser/navigation_controller.h"
|
||||
@ -55,7 +55,7 @@ void PanelHost::Init(const GURL& url) {
|
||||
web_contents_.reset(content::WebContents::Create(create_params));
|
||||
extensions::SetViewType(web_contents_.get(), extensions::VIEW_TYPE_PANEL);
|
||||
web_contents_->SetDelegate(this);
|
||||
// web_contents_ may be passed to chrome_page_zoom::Zoom(), so it needs
|
||||
// web_contents_ may be passed to PageZoom::Zoom(), so it needs
|
||||
// a ZoomController.
|
||||
ui_zoom::ZoomController::CreateForWebContents(web_contents_.get());
|
||||
content::WebContentsObserver::Observe(web_contents_.get());
|
||||
@ -269,5 +269,5 @@ void PanelHost::StopLoading() {
|
||||
}
|
||||
|
||||
void PanelHost::Zoom(content::PageZoom zoom) {
|
||||
chrome_page_zoom::Zoom(web_contents_.get(), zoom);
|
||||
ui_zoom::PageZoom::Zoom(web_contents_.get(), zoom);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "base/command_line.h"
|
||||
#include "chrome/app/chrome_command_ids.h"
|
||||
#include "chrome/browser/app_mode/app_mode_utils.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/favicon/favicon_tab_helper.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/host_desktop.h"
|
||||
@ -18,6 +17,7 @@
|
||||
#include "chrome/browser/ui/views/frame/taskbar_decorator.h"
|
||||
#include "chrome/browser/web_applications/web_app.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "components/ui/zoom/zoom_controller.h"
|
||||
#include "extensions/common/extension.h"
|
||||
#include "ui/aura/window.h"
|
||||
@ -584,16 +584,16 @@ bool ChromeNativeAppWindowViews::AcceleratorPressed(
|
||||
Close();
|
||||
return true;
|
||||
case IDC_ZOOM_MINUS:
|
||||
chrome_page_zoom::Zoom(web_view()->GetWebContents(),
|
||||
content::PAGE_ZOOM_OUT);
|
||||
ui_zoom::PageZoom::Zoom(web_view()->GetWebContents(),
|
||||
content::PAGE_ZOOM_OUT);
|
||||
return true;
|
||||
case IDC_ZOOM_NORMAL:
|
||||
chrome_page_zoom::Zoom(web_view()->GetWebContents(),
|
||||
content::PAGE_ZOOM_RESET);
|
||||
ui_zoom::PageZoom::Zoom(web_view()->GetWebContents(),
|
||||
content::PAGE_ZOOM_RESET);
|
||||
return true;
|
||||
case IDC_ZOOM_PLUS:
|
||||
chrome_page_zoom::Zoom(web_view()->GetWebContents(),
|
||||
content::PAGE_ZOOM_IN);
|
||||
ui_zoom::PageZoom::Zoom(web_view()->GetWebContents(),
|
||||
content::PAGE_ZOOM_IN);
|
||||
return true;
|
||||
default:
|
||||
NOTREACHED() << "Unknown accelerator sent to app window.";
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "base/i18n/rtl.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_finder.h"
|
||||
#include "chrome/browser/ui/browser_tabstrip.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "chrome/browser/ui/views/location_bar/zoom_view.h"
|
||||
#include "chrome/common/extensions/api/extension_action/action_info.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "components/ui/zoom/zoom_controller.h"
|
||||
#include "content/public/browser/notification_source.h"
|
||||
#include "extensions/browser/extension_zoom_request_client.h"
|
||||
@ -235,7 +235,7 @@ void ZoomBubbleView::ButtonPressed(views::Button* sender,
|
||||
extension_info_.id.c_str())),
|
||||
ui::PAGE_TRANSITION_FROM_API);
|
||||
} else {
|
||||
chrome_page_zoom::Zoom(web_contents_, content::PAGE_ZOOM_RESET);
|
||||
ui_zoom::PageZoom::Zoom(web_contents_, content::PAGE_ZOOM_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "chrome/browser/auto_launch_trial.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "chrome/browser/custom_home_pages_table_model.h"
|
||||
#include "chrome/browser/download/download_prefs.h"
|
||||
#include "chrome/browser/gpu/gpu_mode_manager.h"
|
||||
@ -79,6 +78,7 @@
|
||||
#include "components/search_engines/template_url_service.h"
|
||||
#include "components/signin/core/browser/signin_manager.h"
|
||||
#include "components/signin/core/common/profile_management_switches.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "components/user_manager/user_type.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
@ -1926,7 +1926,7 @@ void BrowserOptionsHandler::SetupPageZoomSelector() {
|
||||
// Generate a vector of zoom factors from an array of known presets along with
|
||||
// the default factor added if necessary.
|
||||
std::vector<double> zoom_factors =
|
||||
chrome_page_zoom::PresetZoomFactors(default_zoom_factor);
|
||||
ui_zoom::PageZoom::PresetZoomFactors(default_zoom_factor);
|
||||
|
||||
// Iterate through the zoom factors and and build the contents of the
|
||||
// selector that will be sent to the javascript handler.
|
||||
|
@ -827,10 +827,6 @@
|
||||
'browser/chrome_browser_main_posix.h',
|
||||
'browser/chrome_device_client.cc',
|
||||
'browser/chrome_device_client.h',
|
||||
'browser/chrome_page_zoom.cc',
|
||||
'browser/chrome_page_zoom.h',
|
||||
'browser/chrome_page_zoom_constants.cc',
|
||||
'browser/chrome_page_zoom_constants.h',
|
||||
'browser/chrome_process_singleton.cc',
|
||||
'browser/chrome_process_singleton.h',
|
||||
'browser/component_updater/widevine_cdm_component_installer.cc',
|
||||
|
@ -1399,7 +1399,6 @@
|
||||
# ContentProvider.
|
||||
'browser/bookmarks/bookmark_html_writer_unittest.cc',
|
||||
'browser/browser_commands_unittest.cc',
|
||||
'browser/chrome_page_zoom_unittest.cc',
|
||||
'browser/diagnostics/diagnostics_model_unittest.cc',
|
||||
'browser/diagnostics/diagnostics_controller_unittest.cc',
|
||||
'browser/download/download_shelf_unittest.cc',
|
||||
|
@ -280,6 +280,7 @@
|
||||
'translate/ios/browser/js_translate_manager_unittest.mm',
|
||||
'translate/ios/browser/language_detection_controller_unittest.mm',
|
||||
'translate/ios/browser/translate_controller_unittest.mm',
|
||||
'ui/zoom/page_zoom_unittests.cc',
|
||||
'update_client/update_query_params_unittest.cc',
|
||||
'url_matcher/regex_set_matcher_unittest.cc',
|
||||
'url_matcher/string_pattern_unittest.cc',
|
||||
@ -496,6 +497,9 @@
|
||||
# Dependencies of wallpaper
|
||||
'components.gyp:wallpaper',
|
||||
|
||||
# Dependencies of ui/zoom
|
||||
'components.gyp:ui_zoom',
|
||||
|
||||
# Dependencies of update_client
|
||||
'components.gyp:update_client',
|
||||
|
||||
|
@ -4,6 +4,10 @@
|
||||
|
||||
static_library("ui_zoom") {
|
||||
sources = [
|
||||
"page_zoom.cc",
|
||||
"page_zoom.h",
|
||||
"page_zoom_constants.cc",
|
||||
"page_zoom_constants.h",
|
||||
"zoom_controller.cc",
|
||||
"zoom_controller.h",
|
||||
"zoom_event_manager.cc",
|
||||
|
@ -1,14 +1,14 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "chrome/browser/chrome_page_zoom_constants.h"
|
||||
#include "components/ui/zoom/page_zoom_constants.h"
|
||||
#include "components/ui/zoom/zoom_controller.h"
|
||||
#include "content/public/browser/host_zoom_map.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
using base::UserMetricsAction;
|
||||
|
||||
namespace chrome_page_zoom {
|
||||
namespace {
|
||||
|
||||
enum PageZoomValueType {
|
||||
PAGE_ZOOM_VALUE_TYPE_FACTOR,
|
||||
@ -33,8 +33,8 @@ std::vector<double> PresetZoomValues(PageZoomValueType value_type,
|
||||
// sorted order.
|
||||
std::vector<double> zoom_values;
|
||||
bool found_custom = false;
|
||||
for (size_t i = 0; i < kPresetZoomFactorsSize; i++) {
|
||||
double zoom_value = kPresetZoomFactors[i];
|
||||
for (size_t i = 0; i < ui_zoom::kPresetZoomFactorsSize; i++) {
|
||||
double zoom_value = ui_zoom::kPresetZoomFactors[i];
|
||||
if (value_type == PAGE_ZOOM_VALUE_TYPE_LEVEL)
|
||||
zoom_value = content::ZoomFactorToZoomLevel(zoom_value);
|
||||
if (content::ZoomValuesEqual(zoom_value, custom_value))
|
||||
@ -56,15 +56,23 @@ std::vector<double> PresetZoomValues(PageZoomValueType value_type,
|
||||
return zoom_values;
|
||||
}
|
||||
|
||||
std::vector<double> PresetZoomFactors(double custom_factor) {
|
||||
} // namespace anonymous
|
||||
|
||||
namespace ui_zoom {
|
||||
|
||||
// static
|
||||
std::vector<double> PageZoom::PresetZoomFactors(double custom_factor) {
|
||||
return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_FACTOR, custom_factor);
|
||||
}
|
||||
|
||||
std::vector<double> PresetZoomLevels(double custom_level) {
|
||||
// static
|
||||
std::vector<double> PageZoom::PresetZoomLevels(double custom_level) {
|
||||
return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_LEVEL, custom_level);
|
||||
}
|
||||
|
||||
void Zoom(content::WebContents* web_contents, content::PageZoom zoom) {
|
||||
// static
|
||||
void PageZoom::Zoom(content::WebContents* web_contents,
|
||||
content::PageZoom zoom) {
|
||||
ui_zoom::ZoomController* zoom_controller =
|
||||
ui_zoom::ZoomController::FromWebContents(web_contents);
|
||||
DCHECK(zoom_controller);
|
||||
@ -115,4 +123,4 @@ void Zoom(content::WebContents* web_contents, content::PageZoom zoom) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace chrome_page_zoom
|
||||
} // namespace ui_zoom
|
46
components/ui/zoom/page_zoom.h
Normal file
46
components/ui/zoom/page_zoom.h
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef COMPONENTS_UI_ZOOM_PAGE_ZOOM_H_
|
||||
#define COMPONENTS_UI_ZOOM_PAGE_ZOOM_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "content/public/common/page_zoom.h"
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
namespace ui_zoom {
|
||||
|
||||
// This class provides a means of zooming pages according to a predetermined
|
||||
// set of zoom levels/factors. In future, the static methods in this class
|
||||
// can be made non-static, with PresetZoomX() being virtual, to allow clients
|
||||
// to create custom sets of zoom levels.
|
||||
class PageZoom {
|
||||
public:
|
||||
// Return a sorted vector of zoom factors. The vector will consist of preset
|
||||
// values along with a custom value (if the custom value is not already
|
||||
// represented.)
|
||||
static std::vector<double> PresetZoomFactors(double custom_factor);
|
||||
|
||||
// Return a sorted vector of zoom levels. The vector will consist of preset
|
||||
// values along with a custom value (if the custom value is not already
|
||||
// represented.)
|
||||
static std::vector<double> PresetZoomLevels(double custom_level);
|
||||
|
||||
// Adjusts the zoom level of |web_contents|.
|
||||
static void Zoom(content::WebContents* web_contents, content::PageZoom zoom);
|
||||
|
||||
private:
|
||||
// We don't expect (currently) to create instances of this class.
|
||||
PageZoom() {}
|
||||
DISALLOW_COPY_AND_ASSIGN(PageZoom);
|
||||
};
|
||||
|
||||
} // namespace ui_zoom
|
||||
|
||||
#endif // COMPONENTS_UI_ZOOM_PAGE_ZOOM_H_
|
@ -1,16 +1,18 @@
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/browser/chrome_page_zoom_constants.h"
|
||||
#include "components/ui/zoom/page_zoom_constants.h"
|
||||
|
||||
namespace chrome_page_zoom {
|
||||
#include "base/macros.h"
|
||||
|
||||
namespace ui_zoom {
|
||||
|
||||
// This list is duplicated in chrome/browser/resources/pdf/viewport.js. Please
|
||||
// make sure the two match.
|
||||
const double kPresetZoomFactors[] = { 0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0,
|
||||
1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0,
|
||||
5.0 };
|
||||
const size_t kPresetZoomFactorsSize = arraysize(kPresetZoomFactors);
|
||||
const std::size_t kPresetZoomFactorsSize = arraysize(kPresetZoomFactors);
|
||||
|
||||
} // namespace chrome_page_zoom
|
||||
} // namespace ui_zoom
|
20
components/ui/zoom/page_zoom_constants.h
Normal file
20
components/ui/zoom/page_zoom_constants.h
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef COMPONENTS_UI_ZOOM_PAGE_ZOOM_CONSTANTS_H_
|
||||
#define COMPONENTS_UI_ZOOM_PAGE_ZOOM_CONSTANTS_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace ui_zoom {
|
||||
|
||||
// Default zoom factors supported by ui_zoom.
|
||||
extern const double kPresetZoomFactors[];
|
||||
|
||||
// Size of |kPresetZoomFactors|.
|
||||
extern const std::size_t kPresetZoomFactorsSize;
|
||||
|
||||
} // namespace ui_zoom
|
||||
|
||||
#endif // COMPONENTS_UI_ZOOM_PAGE_ZOOM_CONSTANTS_H_
|
@ -2,16 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/browser/chrome_page_zoom.h"
|
||||
#include "components/ui/zoom/page_zoom.h"
|
||||
#include "content/public/common/page_zoom.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
TEST(ChromePageZoomTest, PresetZoomFactors) {
|
||||
TEST(PageTestZoom, PresetZoomFactors) {
|
||||
// Fetch a vector of preset zoom factors, including a custom value that we
|
||||
// already know is not going to be in the list.
|
||||
double custom_value = 1.05; // 105%
|
||||
std::vector<double> factors =
|
||||
chrome_page_zoom::PresetZoomFactors(custom_value);
|
||||
ui_zoom::PageZoom::PresetZoomFactors(custom_value);
|
||||
|
||||
// Expect at least 10 zoom factors.
|
||||
EXPECT_GE(factors.size(), 10U);
|
||||
@ -43,11 +43,12 @@ TEST(ChromePageZoomTest, PresetZoomFactors) {
|
||||
EXPECT_TRUE(found_100_percent);
|
||||
}
|
||||
|
||||
TEST(ChromePageZoomTest, PresetZoomLevels) {
|
||||
TEST(PageTestZoom, PresetZoomLevels) {
|
||||
// Fetch a vector of preset zoom levels, including a custom value that we
|
||||
// already know is not going to be in the list.
|
||||
double custom_value = 0.1;
|
||||
std::vector<double> levels = chrome_page_zoom::PresetZoomLevels(custom_value);
|
||||
std::vector<double> levels =
|
||||
ui_zoom::PageZoom::PresetZoomLevels(custom_value);
|
||||
|
||||
// Expect at least 10 zoom levels.
|
||||
EXPECT_GE(levels.size(), 10U);
|
||||
@ -75,23 +76,23 @@ TEST(ChromePageZoomTest, PresetZoomLevels) {
|
||||
EXPECT_TRUE(found_100_percent);
|
||||
}
|
||||
|
||||
TEST(ChromePageZoomTest, InvalidCustomFactor) {
|
||||
TEST(PageTestZoom, InvalidCustomFactor) {
|
||||
double too_low = 0.01;
|
||||
std::vector<double> factors = chrome_page_zoom::PresetZoomFactors(too_low);
|
||||
std::vector<double> factors = ui_zoom::PageZoom::PresetZoomFactors(too_low);
|
||||
EXPECT_FALSE(content::ZoomValuesEqual(factors.front(), too_low));
|
||||
|
||||
double too_high = 99.0;
|
||||
factors = chrome_page_zoom::PresetZoomFactors(too_high);
|
||||
factors = ui_zoom::PageZoom::PresetZoomFactors(too_high);
|
||||
EXPECT_FALSE(content::ZoomValuesEqual(factors.back(), too_high));
|
||||
}
|
||||
|
||||
TEST(ChromePageZoomTest, InvalidCustomLevel) {
|
||||
TEST(PageTestZoom, InvalidCustomLevel) {
|
||||
double too_low = -99.0;
|
||||
std::vector<double> levels = chrome_page_zoom::PresetZoomLevels(too_low);
|
||||
std::vector<double> levels = ui_zoom::PageZoom::PresetZoomLevels(too_low);
|
||||
EXPECT_FALSE(content::ZoomValuesEqual(levels.front(), too_low));
|
||||
|
||||
double too_high = 99.0;
|
||||
levels = chrome_page_zoom::PresetZoomLevels(too_high);
|
||||
levels = ui_zoom::PageZoom::PresetZoomLevels(too_high);
|
||||
EXPECT_FALSE(content::ZoomValuesEqual(levels.back(), too_high));
|
||||
}
|
||||
|
@ -19,6 +19,10 @@
|
||||
'../url/url.gyp:url_lib',
|
||||
],
|
||||
'sources': [
|
||||
'ui/zoom/page_zoom.cc',
|
||||
'ui/zoom/page_zoom.h',
|
||||
'ui/zoom/page_zoom_constants.cc',
|
||||
'ui/zoom/page_zoom_constants.h',
|
||||
'ui/zoom/zoom_controller.cc',
|
||||
'ui/zoom/zoom_controller.h',
|
||||
'ui/zoom/zoom_event_manager.cc',
|
||||
|
@ -45,7 +45,7 @@ shared_library("pdf") {
|
||||
"resource_consts.h",
|
||||
"thumbnail_control.cc",
|
||||
"thumbnail_control.h",
|
||||
"../chrome/browser/chrome_page_zoom_constants.cc",
|
||||
"../components/ui/zoom/page_zoom_constants.cc",
|
||||
"../content/common/page_zoom.cc",
|
||||
]
|
||||
|
||||
|
2
pdf/DEPS
2
pdf/DEPS
@ -1,7 +1,7 @@
|
||||
include_rules = [
|
||||
"!chrome/browser/chrome_page_zoom_constants.h",
|
||||
"!chrome/common/content_restriction.h",
|
||||
"!content/public/common/page_zoom.h",
|
||||
"+components/ui/zoom/page_zoom_constants.h",
|
||||
"+net",
|
||||
"+ppapi",
|
||||
"+third_party/pdfium/fpdfsdk/include",
|
||||
|
@ -17,8 +17,8 @@
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/chrome_page_zoom_constants.h"
|
||||
#include "chrome/common/content_restriction.h"
|
||||
#include "components/ui/zoom/page_zoom_constants.h"
|
||||
#include "content/public/common/page_zoom.h"
|
||||
#include "net/base/escape.h"
|
||||
#include "pdf/draw_utils.h"
|
||||
@ -2574,14 +2574,14 @@ void Instance::UpdateZoomScale() {
|
||||
|
||||
double Instance::CalculateZoom(uint32 control_id) const {
|
||||
if (control_id == kZoomInButtonId) {
|
||||
for (size_t i = 0; i < chrome_page_zoom::kPresetZoomFactorsSize; ++i) {
|
||||
double current_zoom = chrome_page_zoom::kPresetZoomFactors[i];
|
||||
for (size_t i = 0; i < ui_zoom::kPresetZoomFactorsSize; ++i) {
|
||||
double current_zoom = ui_zoom::kPresetZoomFactors[i];
|
||||
if (current_zoom - content::kEpsilon > zoom_)
|
||||
return current_zoom;
|
||||
}
|
||||
} else {
|
||||
for (size_t i = chrome_page_zoom::kPresetZoomFactorsSize; i > 0; --i) {
|
||||
double current_zoom = chrome_page_zoom::kPresetZoomFactors[i - 1];
|
||||
for (size_t i = ui_zoom::kPresetZoomFactorsSize; i > 0; --i) {
|
||||
double current_zoom = ui_zoom::kPresetZoomFactors[i - 1];
|
||||
if (current_zoom + content::kEpsilon < zoom_)
|
||||
return current_zoom;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@
|
||||
'resource_consts.h',
|
||||
'thumbnail_control.cc',
|
||||
'thumbnail_control.h',
|
||||
'../chrome/browser/chrome_page_zoom_constants.cc',
|
||||
'../components/ui/zoom/page_zoom_constants.cc',
|
||||
'../content/common/page_zoom.cc',
|
||||
],
|
||||
'conditions': [
|
||||
|
Reference in New Issue
Block a user