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

Side by Side Diff: chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.cc

Issue 2063863002: Use DCHECKs when observing only a single notification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/renderer_context_menu/render_view_context_menu_browsert est_util.h" 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 11 matching lines...) Expand all
22 content::NotificationService::AllSources()); 22 content::NotificationService::AllSources());
23 } 23 }
24 24
25 ContextMenuNotificationObserver::~ContextMenuNotificationObserver() { 25 ContextMenuNotificationObserver::~ContextMenuNotificationObserver() {
26 } 26 }
27 27
28 void ContextMenuNotificationObserver::Observe( 28 void ContextMenuNotificationObserver::Observe(
29 int type, 29 int type,
30 const content::NotificationSource& source, 30 const content::NotificationSource& source,
31 const content::NotificationDetails& details) { 31 const content::NotificationDetails& details) {
32 switch (type) { 32 DCHECK_EQ(chrome::NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN, type);
33 case chrome::NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN: {
34 RenderViewContextMenu* context_menu =
35 content::Source<RenderViewContextMenu>(source).ptr();
36 base::ThreadTaskRunnerHandle::Get()->PostTask(
37 FROM_HERE,
38 base::Bind(&ContextMenuNotificationObserver::ExecuteCommand,
39 base::Unretained(this), context_menu));
40 break;
41 }
42 33
43 default: 34 RenderViewContextMenu* context_menu =
44 NOTREACHED(); 35 content::Source<RenderViewContextMenu>(source).ptr();
45 } 36 base::ThreadTaskRunnerHandle::Get()->PostTask(
37 FROM_HERE, base::Bind(&ContextMenuNotificationObserver::ExecuteCommand,
38 base::Unretained(this), context_menu));
46 } 39 }
47 40
48 void ContextMenuNotificationObserver::ExecuteCommand( 41 void ContextMenuNotificationObserver::ExecuteCommand(
49 RenderViewContextMenu* context_menu) { 42 RenderViewContextMenu* context_menu) {
50 context_menu->ExecuteCommand(command_to_execute_, 0); 43 context_menu->ExecuteCommand(command_to_execute_, 0);
51 context_menu->Cancel(); 44 context_menu->Cancel();
52 } 45 }
53 46
54 ContextMenuWaiter::ContextMenuWaiter(const content::NotificationSource& source) 47 ContextMenuWaiter::ContextMenuWaiter(const content::NotificationSource& source)
55 : menu_visible_(false) { 48 : menu_visible_(false) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 84 }
92 85
93 content::ContextMenuParams& ContextMenuWaiter::params() { 86 content::ContextMenuParams& ContextMenuWaiter::params() {
94 return params_; 87 return params_;
95 } 88 }
96 89
97 void ContextMenuWaiter::Cancel(RenderViewContextMenu* context_menu) { 90 void ContextMenuWaiter::Cancel(RenderViewContextMenu* context_menu) {
98 params_ = context_menu->params(); 91 params_ = context_menu->params();
99 context_menu->Cancel(); 92 context_menu->Cancel();
100 } 93 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_shortcut_manager_win.cc ('k') | chrome/browser/safe_browsing/client_side_detection_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698