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

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

Issue 373733003: Make sure WebContents passed to chrome_page_zoom::Zoom() have a ZoomController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to r282074. Created 6 years, 5 months 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
« no previous file with comments | « no previous file | chrome/browser/devtools/devtools_window.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_page_zoom.h" 5 #include "chrome/browser/chrome_page_zoom.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_FACTOR, custom_factor); 62 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_FACTOR, custom_factor);
63 } 63 }
64 64
65 std::vector<double> PresetZoomLevels(double custom_level) { 65 std::vector<double> PresetZoomLevels(double custom_level) {
66 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_LEVEL, custom_level); 66 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_LEVEL, custom_level);
67 } 67 }
68 68
69 void Zoom(content::WebContents* web_contents, content::PageZoom zoom) { 69 void Zoom(content::WebContents* web_contents, content::PageZoom zoom) {
70 ZoomController* zoom_controller = 70 ZoomController* zoom_controller =
71 ZoomController::FromWebContents(web_contents); 71 ZoomController::FromWebContents(web_contents);
72 DCHECK(zoom_controller);
72 73
73 double current_zoom_level = zoom_controller->GetZoomLevel(); 74 double current_zoom_level = zoom_controller->GetZoomLevel();
74 double default_zoom_level = 75 double default_zoom_level =
75 Profile::FromBrowserContext(web_contents->GetBrowserContext())-> 76 Profile::FromBrowserContext(web_contents->GetBrowserContext())->
76 GetPrefs()->GetDouble(prefs::kDefaultZoomLevel); 77 GetPrefs()->GetDouble(prefs::kDefaultZoomLevel);
77 78
78 if (zoom == content::PAGE_ZOOM_RESET) { 79 if (zoom == content::PAGE_ZOOM_RESET) {
79 zoom_controller->SetZoomLevel(default_zoom_level); 80 zoom_controller->SetZoomLevel(default_zoom_level);
80 content::RecordAction(UserMetricsAction("ZoomNormal")); 81 content::RecordAction(UserMetricsAction("ZoomNormal"));
81 return; 82 return;
(...skipping 30 matching lines...) Expand all
112 zoom_controller->SetZoomLevel(zoom_level); 113 zoom_controller->SetZoomLevel(zoom_level);
113 content::RecordAction(UserMetricsAction("ZoomPlus")); 114 content::RecordAction(UserMetricsAction("ZoomPlus"));
114 return; 115 return;
115 } 116 }
116 } 117 }
117 content::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum")); 118 content::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum"));
118 } 119 }
119 } 120 }
120 121
121 } // namespace chrome_page_zoom 122 } // namespace chrome_page_zoom
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/devtools/devtools_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698