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

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

Powered by Google App Engine
This is Rietveld 408576698