Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1047)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 8528011: Page zoom improvements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: One last(?) tweak. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 15 matching lines...) Expand all
26 #include "base/time.h" 26 #include "base/time.h"
27 #include "base/utf_string_conversions.h" 27 #include "base/utf_string_conversions.h"
28 #include "chrome/app/chrome_command_ids.h" 28 #include "chrome/app/chrome_command_ids.h"
29 #include "chrome/browser/autofill/personal_data_manager_factory.h" 29 #include "chrome/browser/autofill/personal_data_manager_factory.h"
30 #include "chrome/browser/background/background_contents_service.h" 30 #include "chrome/browser/background/background_contents_service.h"
31 #include "chrome/browser/bookmarks/bookmark_model.h" 31 #include "chrome/browser/bookmarks/bookmark_model.h"
32 #include "chrome/browser/bookmarks/bookmark_utils.h" 32 #include "chrome/browser/bookmarks/bookmark_utils.h"
33 #include "chrome/browser/browser_process.h" 33 #include "chrome/browser/browser_process.h"
34 #include "chrome/browser/browser_shutdown.h" 34 #include "chrome/browser/browser_shutdown.h"
35 #include "chrome/browser/character_encoding.h" 35 #include "chrome/browser/character_encoding.h"
36 #include "chrome/browser/chrome_page_zoom.h"
36 #include "chrome/browser/content_settings/host_content_settings_map.h" 37 #include "chrome/browser/content_settings/host_content_settings_map.h"
37 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 38 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
38 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h" 39 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h"
39 #include "chrome/browser/debugger/devtools_toggle_action.h" 40 #include "chrome/browser/debugger/devtools_toggle_action.h"
40 #include "chrome/browser/debugger/devtools_window.h" 41 #include "chrome/browser/debugger/devtools_window.h"
41 #include "chrome/browser/download/chrome_download_manager_delegate.h" 42 #include "chrome/browser/download/chrome_download_manager_delegate.h"
42 #include "chrome/browser/download/download_item_model.h" 43 #include "chrome/browser/download/download_item_model.h"
43 #include "chrome/browser/download/download_service.h" 44 #include "chrome/browser/download/download_service.h"
44 #include "chrome/browser/download/download_service_factory.h" 45 #include "chrome/browser/download/download_service_factory.h"
45 #include "chrome/browser/download/download_started_animation.h" 46 #include "chrome/browser/download/download_started_animation.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 #include "content/browser/site_instance.h" 146 #include "content/browser/site_instance.h"
146 #include "content/browser/tab_contents/interstitial_page.h" 147 #include "content/browser/tab_contents/interstitial_page.h"
147 #include "content/browser/tab_contents/navigation_controller.h" 148 #include "content/browser/tab_contents/navigation_controller.h"
148 #include "content/browser/tab_contents/navigation_entry.h" 149 #include "content/browser/tab_contents/navigation_entry.h"
149 #include "content/browser/tab_contents/tab_contents_view.h" 150 #include "content/browser/tab_contents/tab_contents_view.h"
150 #include "content/browser/user_metrics.h" 151 #include "content/browser/user_metrics.h"
151 #include "content/public/browser/notification_service.h" 152 #include "content/public/browser/notification_service.h"
152 #include "content/public/browser/notification_details.h" 153 #include "content/public/browser/notification_details.h"
153 #include "content/public/common/content_restriction.h" 154 #include "content/public/common/content_restriction.h"
154 #include "content/public/common/content_switches.h" 155 #include "content/public/common/content_switches.h"
156 #include "content/public/common/page_zoom.h"
155 #include "grit/chromium_strings.h" 157 #include "grit/chromium_strings.h"
156 #include "grit/generated_resources.h" 158 #include "grit/generated_resources.h"
157 #include "grit/locale_settings.h" 159 #include "grit/locale_settings.h"
158 #include "grit/theme_resources_standard.h" 160 #include "grit/theme_resources_standard.h"
159 #include "net/base/cookie_monster.h" 161 #include "net/base/cookie_monster.h"
160 #include "net/base/net_util.h" 162 #include "net/base/net_util.h"
161 #include "net/base/registry_controlled_domain.h" 163 #include "net/base/registry_controlled_domain.h"
162 #include "net/url_request/url_request_context.h" 164 #include "net/url_request/url_request_context.h"
163 #include "ui/base/animation/animation.h" 165 #include "ui/base/animation/animation.h"
164 #include "ui/base/l10n/l10n_util.h" 166 #include "ui/base/l10n/l10n_util.h"
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 1895
1894 void Browser::FindPrevious() { 1896 void Browser::FindPrevious() {
1895 UserMetrics::RecordAction(UserMetricsAction("FindPrevious")); 1897 UserMetrics::RecordAction(UserMetricsAction("FindPrevious"));
1896 FindInPage(true, false); 1898 FindInPage(true, false);
1897 } 1899 }
1898 1900
1899 void Browser::Zoom(content::PageZoom zoom) { 1901 void Browser::Zoom(content::PageZoom zoom) {
1900 if (is_devtools()) 1902 if (is_devtools())
1901 return; 1903 return;
1902 1904
1903 static const UserMetricsAction kActions[] = { 1905 RenderViewHost* host = GetSelectedTabContentsWrapper()->render_view_host();
1904 UserMetricsAction("ZoomMinus"), 1906 if (zoom == content::PAGE_ZOOM_RESET) {
1905 UserMetricsAction("ZoomNormal"), 1907 host->SetZoomLevel(0);
1906 UserMetricsAction("ZoomPlus") 1908 UserMetrics::RecordAction(UserMetricsAction("ZoomNormal"));
1907 }; 1909 return;
1910 }
1908 1911
1909 UserMetrics::RecordAction(kActions[zoom - content::PAGE_ZOOM_OUT]); 1912 double current_zoom_level = GetSelectedTabContents()->GetZoomLevel();
1910 TabContentsWrapper* tab_contents = GetSelectedTabContentsWrapper(); 1913 double default_zoom_level =
1911 RenderViewHost* host = tab_contents->render_view_host(); 1914 profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel);
1912 host->Zoom(zoom); 1915
1916 // Generate a vector of zoom levels from an array of known presets along with
1917 // the default level added if necessary.
1918 std::vector<double> zoom_levels =
1919 chrome_page_zoom::PresetZoomLevels(default_zoom_level);
1920
1921 if (zoom == content::PAGE_ZOOM_OUT) {
1922 // Iterate through the zoom levels in reverse order to find the next
1923 // lower level based on the current zoom level for this page.
1924 for (std::vector<double>::reverse_iterator i = zoom_levels.rbegin();
1925 i != zoom_levels.rend(); ++i) {
1926 double zoom_level = *i;
1927 if (content::ZoomValuesEqual(zoom_level, current_zoom_level))
1928 continue;
1929 if (zoom_level < current_zoom_level) {
1930 host->SetZoomLevel(zoom_level);
1931 UserMetrics::RecordAction(UserMetricsAction("ZoomMinus"));
1932 return;
1933 }
1934 UserMetrics::RecordAction(UserMetricsAction("ZoomMinus_AtMinimum"));
1935 }
1936 } else {
1937 // Iterate through the zoom levels in normal order to find the next
1938 // higher level based on the current zoom level for this page.
1939 for (std::vector<double>::const_iterator i = zoom_levels.begin();
1940 i != zoom_levels.end(); ++i) {
1941 double zoom_level = *i;
1942 if (content::ZoomValuesEqual(zoom_level, current_zoom_level))
1943 continue;
1944 if (zoom_level > current_zoom_level) {
1945 host->SetZoomLevel(zoom_level);
1946 UserMetrics::RecordAction(UserMetricsAction("ZoomPlus"));
1947 return;
1948 }
1949 }
1950 UserMetrics::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum"));
1951 }
1913 } 1952 }
1914 1953
1915 void Browser::FocusToolbar() { 1954 void Browser::FocusToolbar() {
1916 UserMetrics::RecordAction(UserMetricsAction("FocusToolbar")); 1955 UserMetrics::RecordAction(UserMetricsAction("FocusToolbar"));
1917 window_->FocusToolbar(); 1956 window_->FocusToolbar();
1918 } 1957 }
1919 1958
1920 void Browser::FocusAppMenu() { 1959 void Browser::FocusAppMenu() {
1921 UserMetrics::RecordAction(UserMetricsAction("FocusAppMenu")); 1960 UserMetrics::RecordAction(UserMetricsAction("FocusAppMenu"));
1922 window_->FocusAppMenu(); 1961 window_->FocusAppMenu();
(...skipping 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after
5272 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); 5311 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type);
5273 } else if (is_type_tabbed()) { 5312 } else if (is_type_tabbed()) {
5274 GlobalErrorService* service = 5313 GlobalErrorService* service =
5275 GlobalErrorServiceFactory::GetForProfile(profile()); 5314 GlobalErrorServiceFactory::GetForProfile(profile());
5276 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); 5315 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView();
5277 if (error) { 5316 if (error) {
5278 error->ShowBubbleView(this); 5317 error->ShowBubbleView(this);
5279 } 5318 }
5280 } 5319 }
5281 } 5320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698