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

Unified 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: Review feedback 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.cc
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.cc b/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.cc
index ef42c55e5c1d9c054a3420b72d1123bc6451f35d..2a27e3c422d2425216d5953b1327a793fe5176d4 100644
--- a/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.cc
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.cc
@@ -6,9 +6,11 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
+#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
#include "content/public/browser/notification_service.h"
+#include "content/public/test/test_utils.h"
ContextMenuNotificationObserver::ContextMenuNotificationObserver(
int command_to_execute)
@@ -32,7 +34,8 @@ void ContextMenuNotificationObserver::Observe(
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&ContextMenuNotificationObserver::ExecuteCommand,
- base::Unretained(this), context_menu));
+ base::Unretained(this),
+ context_menu));
break;
}
@@ -46,3 +49,53 @@ void ContextMenuNotificationObserver::ExecuteCommand(
context_menu->ExecuteCommand(command_to_execute_, 0);
context_menu->Cancel();
}
+
+SaveLinkAsContextMenuObserver::SaveLinkAsContextMenuObserver(
+ const content::NotificationSource& source)
+ : ContextMenuNotificationObserver(IDC_CONTENT_CONTEXT_SAVELINKAS),
+ menu_visible_(false) {
+}
+
+SaveLinkAsContextMenuObserver::~SaveLinkAsContextMenuObserver() {
+}
+
+void SaveLinkAsContextMenuObserver::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ switch (type) {
+ case chrome::NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN: {
+ menu_visible_ = true;
+ RenderViewContextMenu* context_menu =
+ content::Source<RenderViewContextMenu>(source).ptr();
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&SaveLinkAsContextMenuObserver::Cancel,
+ base::Unretained(this),
+ context_menu));
+ break;
+ }
+
+ default:
+ NOTREACHED();
+ }
+}
+
+void SaveLinkAsContextMenuObserver::WaitForMenu() {
+ content::WindowedNotificationObserver menu_observer(
+ chrome::NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN,
+ content::NotificationService::AllSources());
+ if (!menu_visible_)
+ menu_observer.Wait();
+ menu_visible_ = false;
+}
+
+base::string16 SaveLinkAsContextMenuObserver::GetSuggestedFilename() {
+ return params_.suggested_filename;
+}
+
+void SaveLinkAsContextMenuObserver::Cancel(
+ RenderViewContextMenu* context_menu) {
+ params_ = context_menu->params();
+ context_menu->Cancel();
+}
« no previous file with comments | « chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698