Chromium Code Reviews| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | 72 |
|
Peter Kasting
2014/07/08 19:16:42
Nit: Extra blank line
wjmaclean
2014/07/08 20:51:21
Done.
| |
| 73 if (!zoom_controller) { | |
| 74 NOTREACHED(); | |
|
Peter Kasting
2014/07/08 19:16:43
This is banned by the style guide. If |zoom_contr
wjmaclean
2014/07/08 20:51:21
I was hoping to generate well-documented failures
Peter Kasting
2014/07/08 20:52:47
Yeah, DCHECK is correct for what you describe. Th
| |
| 75 return; | |
| 76 } | |
| 77 | |
| 73 double current_zoom_level = zoom_controller->GetZoomLevel(); | 78 double current_zoom_level = zoom_controller->GetZoomLevel(); |
| 74 double default_zoom_level = | 79 double default_zoom_level = |
| 75 Profile::FromBrowserContext(web_contents->GetBrowserContext())-> | 80 Profile::FromBrowserContext(web_contents->GetBrowserContext())-> |
| 76 GetPrefs()->GetDouble(prefs::kDefaultZoomLevel); | 81 GetPrefs()->GetDouble(prefs::kDefaultZoomLevel); |
| 77 | 82 |
| 78 if (zoom == content::PAGE_ZOOM_RESET) { | 83 if (zoom == content::PAGE_ZOOM_RESET) { |
| 79 zoom_controller->SetZoomLevel(default_zoom_level); | 84 zoom_controller->SetZoomLevel(default_zoom_level); |
| 80 content::RecordAction(UserMetricsAction("ZoomNormal")); | 85 content::RecordAction(UserMetricsAction("ZoomNormal")); |
| 81 return; | 86 return; |
| 82 } | 87 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 112 zoom_controller->SetZoomLevel(zoom_level); | 117 zoom_controller->SetZoomLevel(zoom_level); |
| 113 content::RecordAction(UserMetricsAction("ZoomPlus")); | 118 content::RecordAction(UserMetricsAction("ZoomPlus")); |
| 114 return; | 119 return; |
| 115 } | 120 } |
| 116 } | 121 } |
| 117 content::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum")); | 122 content::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum")); |
| 118 } | 123 } |
| 119 } | 124 } |
| 120 | 125 |
| 121 } // namespace chrome_page_zoom | 126 } // namespace chrome_page_zoom |
| OLD | NEW |