| 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 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 Loading... |
| 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 |
| OLD | NEW |