OLD | NEW |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 DCHECK(zoom_controller); |
73 | 73 |
74 double current_zoom_level = zoom_controller->GetZoomLevel(); | 74 double current_zoom_level = zoom_controller->GetZoomLevel(); |
75 double default_zoom_level = | 75 double default_zoom_level = zoom_controller->GetDefaultZoomLevel(); |
76 Profile::FromBrowserContext(web_contents->GetBrowserContext())-> | |
77 GetPrefs()->GetDouble(prefs::kDefaultZoomLevel); | |
78 | 76 |
79 if (zoom == content::PAGE_ZOOM_RESET) { | 77 if (zoom == content::PAGE_ZOOM_RESET) { |
80 zoom_controller->SetZoomLevel(default_zoom_level); | 78 zoom_controller->SetZoomLevel(default_zoom_level); |
81 content::RecordAction(UserMetricsAction("ZoomNormal")); | 79 content::RecordAction(UserMetricsAction("ZoomNormal")); |
82 return; | 80 return; |
83 } | 81 } |
84 | 82 |
85 // Generate a vector of zoom levels from an array of known presets along with | 83 // Generate a vector of zoom levels from an array of known presets along with |
86 // the default level added if necessary. | 84 // the default level added if necessary. |
87 std::vector<double> zoom_levels = PresetZoomLevels(default_zoom_level); | 85 std::vector<double> zoom_levels = PresetZoomLevels(default_zoom_level); |
(...skipping 25 matching lines...) Expand all Loading... |
113 zoom_controller->SetZoomLevel(zoom_level); | 111 zoom_controller->SetZoomLevel(zoom_level); |
114 content::RecordAction(UserMetricsAction("ZoomPlus")); | 112 content::RecordAction(UserMetricsAction("ZoomPlus")); |
115 return; | 113 return; |
116 } | 114 } |
117 } | 115 } |
118 content::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum")); | 116 content::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum")); |
119 } | 117 } |
120 } | 118 } |
121 | 119 |
122 } // namespace chrome_page_zoom | 120 } // namespace chrome_page_zoom |
OLD | NEW |