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

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

Issue 339153002: Use suggested filename for "Save Link As" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test case Created 6 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/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" 10 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
11 #include "content/public/browser/notification_service.h" 11 #include "content/public/browser/notification_service.h"
12 12
13 ContextMenuNotificationObserver::ContextMenuNotificationObserver( 13 ContextMenuNotificationObserver::ContextMenuNotificationObserver(
14 int command_to_execute) 14 int command_to_execute)
15 : command_to_execute_(command_to_execute) { 15 : command_to_execute_(command_to_execute) {
16 registrar_.Add(this, 16 registrar_.Add(this,
17 chrome::NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN, 17 chrome::NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN,
18 content::NotificationService::AllSources()); 18 content::NotificationService::AllSources());
19 } 19 }
20 20
21 ContextMenuNotificationObserver::~ContextMenuNotificationObserver() { 21 ContextMenuNotificationObserver::~ContextMenuNotificationObserver() {
22 } 22 }
23 23
24 void ContextMenuNotificationObserver::Observe( 24 void ContextMenuNotificationObserver::Observe(
25 int type, 25 int type,
26 const content::NotificationSource& source, 26 const content::NotificationSource& source,
27 const content::NotificationDetails& details) { 27 const content::NotificationDetails& details) {
28 switch (type) { 28 switch (type) {
29 case chrome::NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN: { 29 case chrome::NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN: {
30 RenderViewContextMenu* context_menu = 30 context_menu_ = content::Source<RenderViewContextMenu>(source).ptr();
31 content::Source<RenderViewContextMenu>(source).ptr();
32 base::MessageLoop::current()->PostTask( 31 base::MessageLoop::current()->PostTask(
33 FROM_HERE, 32 FROM_HERE,
34 base::Bind(&ContextMenuNotificationObserver::ExecuteCommand, 33 base::Bind(&ContextMenuNotificationObserver::ExecuteCommand,
35 base::Unretained(this), context_menu)); 34 base::Unretained(this),
35 context_menu_));
36 break; 36 break;
37 } 37 }
38 38
39 default: 39 default:
40 NOTREACHED(); 40 NOTREACHED();
41 } 41 }
42 } 42 }
43 43
44 base::string16 ContextMenuNotificationObserver::GetSuggestedFilename() {
45 return context_menu_->params().suggested_filename;
46 }
47
44 void ContextMenuNotificationObserver::ExecuteCommand( 48 void ContextMenuNotificationObserver::ExecuteCommand(
45 RenderViewContextMenu* context_menu) { 49 RenderViewContextMenu* context_menu) {
46 context_menu->ExecuteCommand(command_to_execute_, 0); 50 context_menu->ExecuteCommand(command_to_execute_, 0);
47 context_menu->Cancel(); 51 context_menu->Cancel();
48 } 52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698