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

Side by Side Diff: chrome/browser/ui/views/tabs/alert_indicator_button.cc

Issue 2771233002: Remove the wrapper functions content::RecordAction et al (Closed)
Patch Set: Rebased Created 3 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/views/tabs/alert_indicator_button.h" 5 #include "chrome/browser/ui/views/tabs/alert_indicator_button.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/metrics/user_metrics.h"
8 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
9 #include "chrome/browser/ui/views/tabs/tab.h" 10 #include "chrome/browser/ui/views/tabs/tab.h"
10 #include "chrome/browser/ui/views/tabs/tab_controller.h" 11 #include "chrome/browser/ui/views/tabs/tab_controller.h"
11 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" 12 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h"
12 #include "content/public/browser/user_metrics.h"
13 #include "ui/gfx/animation/animation_delegate.h" 13 #include "ui/gfx/animation/animation_delegate.h"
14 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
15 #include "ui/gfx/image/image.h" 15 #include "ui/gfx/image/image.h"
16 #include "ui/views/metrics.h" 16 #include "ui/views/metrics.h"
17 17
18 using base::UserMetricsAction; 18 using base::UserMetricsAction;
19 19
20 namespace { 20 namespace {
21 21
22 // The minimum required click-to-select area of an inactive Tab before allowing 22 // The minimum required click-to-select area of an inactive Tab before allowing
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return false; // Event to be handled by Tab. 176 return false; // Event to be handled by Tab.
177 } 177 }
178 return ImageButton::OnMousePressed(event); 178 return ImageButton::OnMousePressed(event);
179 } 179 }
180 180
181 bool AlertIndicatorButton::OnMouseDragged(const ui::MouseEvent& event) { 181 bool AlertIndicatorButton::OnMouseDragged(const ui::MouseEvent& event) {
182 const ButtonState previous_state = state(); 182 const ButtonState previous_state = state();
183 const bool ret = ImageButton::OnMouseDragged(event); 183 const bool ret = ImageButton::OnMouseDragged(event);
184 if (previous_state != views::CustomButton::STATE_NORMAL && 184 if (previous_state != views::CustomButton::STATE_NORMAL &&
185 state() == views::CustomButton::STATE_NORMAL) 185 state() == views::CustomButton::STATE_NORMAL)
186 content::RecordAction(UserMetricsAction("AlertIndicatorButton_Dragged")); 186 base::RecordAction(UserMetricsAction("AlertIndicatorButton_Dragged"));
187 return ret; 187 return ret;
188 } 188 }
189 189
190 void AlertIndicatorButton::OnMouseEntered(const ui::MouseEvent& event) { 190 void AlertIndicatorButton::OnMouseEntered(const ui::MouseEvent& event) {
191 // If any modifier keys are being held down, do not turn on hover. 191 // If any modifier keys are being held down, do not turn on hover.
192 if (state() != views::CustomButton::STATE_DISABLED && 192 if (state() != views::CustomButton::STATE_DISABLED &&
193 IsShiftOrControlDown(event)) { 193 IsShiftOrControlDown(event)) {
194 SetState(views::CustomButton::STATE_NORMAL); 194 SetState(views::CustomButton::STATE_NORMAL);
195 return; 195 return;
196 } 196 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 242
243 void AlertIndicatorButton::NotifyClick(const ui::Event& event) { 243 void AlertIndicatorButton::NotifyClick(const ui::Event& event) {
244 EnterDormantPeriod(); 244 EnterDormantPeriod();
245 245
246 // Call TransitionToAlertState() to change the image, providing the user with 246 // Call TransitionToAlertState() to change the image, providing the user with
247 // instant feedback. In the very unlikely event that the mute toggle fails, 247 // instant feedback. In the very unlikely event that the mute toggle fails,
248 // TransitionToAlertState() will be called again, via another code path, to 248 // TransitionToAlertState() will be called again, via another code path, to
249 // set the image to be consistent with the final outcome. 249 // set the image to be consistent with the final outcome.
250 if (alert_state_ == TabAlertState::AUDIO_PLAYING) { 250 if (alert_state_ == TabAlertState::AUDIO_PLAYING) {
251 content::RecordAction(UserMetricsAction("AlertIndicatorButton_Mute")); 251 base::RecordAction(UserMetricsAction("AlertIndicatorButton_Mute"));
252 TransitionToAlertState(TabAlertState::AUDIO_MUTING); 252 TransitionToAlertState(TabAlertState::AUDIO_MUTING);
253 } else { 253 } else {
254 DCHECK(alert_state_ == TabAlertState::AUDIO_MUTING); 254 DCHECK(alert_state_ == TabAlertState::AUDIO_MUTING);
255 content::RecordAction(UserMetricsAction("AlertIndicatorButton_Unmute")); 255 base::RecordAction(UserMetricsAction("AlertIndicatorButton_Unmute"));
256 TransitionToAlertState(TabAlertState::AUDIO_PLAYING); 256 TransitionToAlertState(TabAlertState::AUDIO_PLAYING);
257 } 257 }
258 258
259 GetTab()->controller()->ToggleTabAudioMute(GetTab()); 259 GetTab()->controller()->ToggleTabAudioMute(GetTab());
260 } 260 }
261 261
262 bool AlertIndicatorButton::IsTriggerableEvent(const ui::Event& event) { 262 bool AlertIndicatorButton::IsTriggerableEvent(const ui::Event& event) {
263 if (is_dormant()) 263 if (is_dormant())
264 return false; 264 return false;
265 265
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 &AlertIndicatorButton::ExitDormantPeriod); 314 &AlertIndicatorButton::ExitDormantPeriod);
315 SchedulePaint(); 315 SchedulePaint();
316 } 316 }
317 317
318 void AlertIndicatorButton::ExitDormantPeriod() { 318 void AlertIndicatorButton::ExitDormantPeriod() {
319 const bool needs_repaint = is_dormant(); 319 const bool needs_repaint = is_dormant();
320 wake_up_timer_.reset(); 320 wake_up_timer_.reset();
321 if (needs_repaint) 321 if (needs_repaint)
322 SchedulePaint(); 322 SchedulePaint();
323 } 323 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.cc ('k') | chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698