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

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: Tweak, 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 #include "content/browser/site_instance.h" 145 #include "content/browser/site_instance.h"
146 #include "content/browser/tab_contents/interstitial_page.h" 146 #include "content/browser/tab_contents/interstitial_page.h"
147 #include "content/browser/tab_contents/navigation_controller.h" 147 #include "content/browser/tab_contents/navigation_controller.h"
148 #include "content/browser/tab_contents/navigation_entry.h" 148 #include "content/browser/tab_contents/navigation_entry.h"
149 #include "content/browser/tab_contents/tab_contents_view.h" 149 #include "content/browser/tab_contents/tab_contents_view.h"
150 #include "content/browser/user_metrics.h" 150 #include "content/browser/user_metrics.h"
151 #include "content/public/browser/notification_service.h" 151 #include "content/public/browser/notification_service.h"
152 #include "content/public/browser/notification_details.h" 152 #include "content/public/browser/notification_details.h"
153 #include "content/public/common/content_restriction.h" 153 #include "content/public/common/content_restriction.h"
154 #include "content/public/common/content_switches.h" 154 #include "content/public/common/content_switches.h"
155 #include "content/public/common/page_zoom.h"
155 #include "grit/chromium_strings.h" 156 #include "grit/chromium_strings.h"
156 #include "grit/generated_resources.h" 157 #include "grit/generated_resources.h"
157 #include "grit/locale_settings.h" 158 #include "grit/locale_settings.h"
158 #include "grit/theme_resources_standard.h" 159 #include "grit/theme_resources_standard.h"
159 #include "net/base/cookie_monster.h" 160 #include "net/base/cookie_monster.h"
160 #include "net/base/net_util.h" 161 #include "net/base/net_util.h"
161 #include "net/base/registry_controlled_domain.h" 162 #include "net/base/registry_controlled_domain.h"
162 #include "net/url_request/url_request_context.h" 163 #include "net/url_request/url_request_context.h"
163 #include "ui/base/animation/animation.h" 164 #include "ui/base/animation/animation.h"
164 #include "ui/base/l10n/l10n_util.h" 165 #include "ui/base/l10n/l10n_util.h"
(...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 1967
1967 void Browser::FindPrevious() { 1968 void Browser::FindPrevious() {
1968 UserMetrics::RecordAction(UserMetricsAction("FindPrevious")); 1969 UserMetrics::RecordAction(UserMetricsAction("FindPrevious"));
1969 FindInPage(true, false); 1970 FindInPage(true, false);
1970 } 1971 }
1971 1972
1972 void Browser::Zoom(content::PageZoom zoom) { 1973 void Browser::Zoom(content::PageZoom zoom) {
1973 if (is_devtools()) 1974 if (is_devtools())
1974 return; 1975 return;
1975 1976
1976 static const UserMetricsAction kActions[] = { 1977 RenderViewHost* host = GetSelectedTabContentsWrapper()->render_view_host();
1977 UserMetricsAction("ZoomMinus"), 1978 if (zoom == content::PAGE_ZOOM_RESET) {
1978 UserMetricsAction("ZoomNormal"), 1979 host->SetZoomLevel(0);
1979 UserMetricsAction("ZoomPlus") 1980 UserMetrics::RecordAction(UserMetricsAction("ZoomNormal"));
1980 }; 1981 return;
1982 }
1981 1983
1982 UserMetrics::RecordAction(kActions[zoom - content::PAGE_ZOOM_OUT]); 1984 double current_zoom_level = GetSelectedTabContents()->GetZoomLevel();
1983 TabContentsWrapper* tab_contents = GetSelectedTabContentsWrapper(); 1985 double default_zoom_level =
1984 RenderViewHost* host = tab_contents->render_view_host(); 1986 profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel);
1985 host->Zoom(zoom); 1987
1988 // Generate a vector of zoom levels from an array of known presets along with
1989 // the default level added if necessary.
1990 std::vector<double> zoom_levels =
1991 content::PresetZoomLevels(default_zoom_level);
1992
1993 if (zoom == content::PAGE_ZOOM_OUT) {
1994 // Iterate through the zoom levels in reverse order to find the next
1995 // lower level based on the current zoom level for this page.
1996 for (std::vector<double>::reverse_iterator i = zoom_levels.rbegin();
1997 i != zoom_levels.rend(); ++i) {
1998 double zoom_level = *i;
1999 if (content::ZoomValuesEqual(zoom_level, current_zoom_level))
2000 continue;
2001 if (zoom_level < current_zoom_level) {
2002 host->SetZoomLevel(zoom_level);
2003 UserMetrics::RecordAction(UserMetricsAction("ZoomMinus"));
2004 return;
2005 }
2006 UserMetrics::RecordAction(UserMetricsAction("ZoomMinus_AtMinimum"));
2007 }
2008 } else {
2009 // Iterate through the zoom levels in normal order to find the next
2010 // higher level based on the current zoom level for this page.
2011 for (std::vector<double>::const_iterator i = zoom_levels.begin();
2012 i != zoom_levels.end(); ++i) {
2013 double zoom_level = *i;
2014 if (content::ZoomValuesEqual(zoom_level, current_zoom_level))
2015 continue;
2016 if (zoom_level > current_zoom_level) {
2017 host->SetZoomLevel(zoom_level);
2018 UserMetrics::RecordAction(UserMetricsAction("ZoomPlus"));
2019 return;
2020 }
2021 }
2022 UserMetrics::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum"));
2023 }
1986 } 2024 }
1987 2025
1988 void Browser::FocusToolbar() { 2026 void Browser::FocusToolbar() {
1989 UserMetrics::RecordAction(UserMetricsAction("FocusToolbar")); 2027 UserMetrics::RecordAction(UserMetricsAction("FocusToolbar"));
1990 window_->FocusToolbar(); 2028 window_->FocusToolbar();
1991 } 2029 }
1992 2030
1993 void Browser::FocusAppMenu() { 2031 void Browser::FocusAppMenu() {
1994 UserMetrics::RecordAction(UserMetricsAction("FocusAppMenu")); 2032 UserMetrics::RecordAction(UserMetricsAction("FocusAppMenu"));
1995 window_->FocusAppMenu(); 2033 window_->FocusAppMenu();
(...skipping 3518 matching lines...) Expand 10 before | Expand all | Expand 10 after
5514 } 5552 }
5515 5553
5516 void Browser::UpdateFullscreenExitBubbleContent() { 5554 void Browser::UpdateFullscreenExitBubbleContent() {
5517 GURL url; 5555 GURL url;
5518 if (fullscreened_tab_) 5556 if (fullscreened_tab_)
5519 url = fullscreened_tab_->tab_contents()->GetURL(); 5557 url = fullscreened_tab_->tab_contents()->GetURL();
5520 5558
5521 window_->UpdateFullscreenExitBubbleContent( 5559 window_->UpdateFullscreenExitBubbleContent(
5522 url, GetFullscreenExitBubbleType()); 5560 url, GetFullscreenExitBubbleType());
5523 } 5561 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698