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

Side by Side Diff: components/zoom/page_zoom.cc

Issue 2771233002: Remove the wrapper functions content::RecordAction et al (Closed)
Patch Set: Rebased Created 3 years, 8 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
« no previous file with comments | « components/sync_sessions/sync_sessions_metrics.cc ('k') | content/browser/BUILD.gn » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/zoom/page_zoom.h" 5 #include "components/zoom/page_zoom.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 11
12 #include "base/metrics/user_metrics.h"
12 #include "components/prefs/pref_service.h" 13 #include "components/prefs/pref_service.h"
13 #include "components/zoom/page_zoom_constants.h" 14 #include "components/zoom/page_zoom_constants.h"
14 #include "components/zoom/zoom_controller.h" 15 #include "components/zoom/zoom_controller.h"
15 #include "content/public/browser/host_zoom_map.h" 16 #include "content/public/browser/host_zoom_map.h"
16 #include "content/public/browser/render_view_host.h" 17 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/user_metrics.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/page_zoom.h" 19 #include "content/public/common/page_zoom.h"
20 #include "content/public/common/renderer_preferences.h" 20 #include "content/public/common/renderer_preferences.h"
21 21
22 using base::UserMetricsAction; 22 using base::UserMetricsAction;
23 23
24 namespace { 24 namespace {
25 25
26 enum PageZoomValueType { 26 enum PageZoomValueType {
27 PAGE_ZOOM_VALUE_TYPE_FACTOR, 27 PAGE_ZOOM_VALUE_TYPE_FACTOR,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 zoom::ZoomController::FromWebContents(web_contents); 79 zoom::ZoomController::FromWebContents(web_contents);
80 if (!zoom_controller) 80 if (!zoom_controller)
81 return; 81 return;
82 82
83 double current_zoom_level = zoom_controller->GetZoomLevel(); 83 double current_zoom_level = zoom_controller->GetZoomLevel();
84 double default_zoom_level = zoom_controller->GetDefaultZoomLevel(); 84 double default_zoom_level = zoom_controller->GetDefaultZoomLevel();
85 85
86 if (zoom == content::PAGE_ZOOM_RESET) { 86 if (zoom == content::PAGE_ZOOM_RESET) {
87 zoom_controller->SetZoomLevel(default_zoom_level); 87 zoom_controller->SetZoomLevel(default_zoom_level);
88 web_contents->SetPageScale(1.f); 88 web_contents->SetPageScale(1.f);
89 content::RecordAction(UserMetricsAction("ZoomNormal")); 89 base::RecordAction(UserMetricsAction("ZoomNormal"));
90 return; 90 return;
91 } 91 }
92 92
93 // Generate a vector of zoom levels from an array of known presets along with 93 // Generate a vector of zoom levels from an array of known presets along with
94 // the default level added if necessary. 94 // the default level added if necessary.
95 std::vector<double> zoom_levels = PresetZoomLevels(default_zoom_level); 95 std::vector<double> zoom_levels = PresetZoomLevels(default_zoom_level);
96 96
97 if (zoom == content::PAGE_ZOOM_OUT) { 97 if (zoom == content::PAGE_ZOOM_OUT) {
98 // Iterate through the zoom levels in reverse order to find the next 98 // Iterate through the zoom levels in reverse order to find the next
99 // lower level based on the current zoom level for this page. 99 // lower level based on the current zoom level for this page.
100 for (std::vector<double>::reverse_iterator i = zoom_levels.rbegin(); 100 for (std::vector<double>::reverse_iterator i = zoom_levels.rbegin();
101 i != zoom_levels.rend(); ++i) { 101 i != zoom_levels.rend(); ++i) {
102 double zoom_level = *i; 102 double zoom_level = *i;
103 if (content::ZoomValuesEqual(zoom_level, current_zoom_level)) 103 if (content::ZoomValuesEqual(zoom_level, current_zoom_level))
104 continue; 104 continue;
105 if (zoom_level < current_zoom_level) { 105 if (zoom_level < current_zoom_level) {
106 zoom_controller->SetZoomLevel(zoom_level); 106 zoom_controller->SetZoomLevel(zoom_level);
107 content::RecordAction(UserMetricsAction("ZoomMinus")); 107 base::RecordAction(UserMetricsAction("ZoomMinus"));
108 return; 108 return;
109 } 109 }
110 } 110 }
111 content::RecordAction(UserMetricsAction("ZoomMinus_AtMinimum")); 111 base::RecordAction(UserMetricsAction("ZoomMinus_AtMinimum"));
112 } else { 112 } else {
113 // Iterate through the zoom levels in normal order to find the next 113 // Iterate through the zoom levels in normal order to find the next
114 // higher level based on the current zoom level for this page. 114 // higher level based on the current zoom level for this page.
115 for (std::vector<double>::const_iterator i = zoom_levels.begin(); 115 for (std::vector<double>::const_iterator i = zoom_levels.begin();
116 i != zoom_levels.end(); ++i) { 116 i != zoom_levels.end(); ++i) {
117 double zoom_level = *i; 117 double zoom_level = *i;
118 if (content::ZoomValuesEqual(zoom_level, current_zoom_level)) 118 if (content::ZoomValuesEqual(zoom_level, current_zoom_level))
119 continue; 119 continue;
120 if (zoom_level > current_zoom_level) { 120 if (zoom_level > current_zoom_level) {
121 zoom_controller->SetZoomLevel(zoom_level); 121 zoom_controller->SetZoomLevel(zoom_level);
122 content::RecordAction(UserMetricsAction("ZoomPlus")); 122 base::RecordAction(UserMetricsAction("ZoomPlus"));
123 return; 123 return;
124 } 124 }
125 } 125 }
126 content::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum")); 126 base::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum"));
127 } 127 }
128 } 128 }
129 129
130 } // namespace zoom 130 } // namespace zoom
OLDNEW
« no previous file with comments | « components/sync_sessions/sync_sessions_metrics.cc ('k') | content/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698