| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BROWSERTES
T_UTIL_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BROWSERTES
T_UTIL_H_ |
| 6 #define CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BROWSERTES
T_UTIL_H_ | 6 #define CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BROWSERTES
T_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 const content::NotificationDetails& details) override; | 25 const content::NotificationDetails& details) override; |
| 26 | 26 |
| 27 void ExecuteCommand(RenderViewContextMenu* context_menu); | 27 void ExecuteCommand(RenderViewContextMenu* context_menu); |
| 28 | 28 |
| 29 content::NotificationRegistrar registrar_; | 29 content::NotificationRegistrar registrar_; |
| 30 int command_to_execute_; | 30 int command_to_execute_; |
| 31 | 31 |
| 32 DISALLOW_COPY_AND_ASSIGN(ContextMenuNotificationObserver); | 32 DISALLOW_COPY_AND_ASSIGN(ContextMenuNotificationObserver); |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 class SaveLinkAsContextMenuObserver : public ContextMenuNotificationObserver { | 35 class ContextMenuWaiter : public content::NotificationObserver { |
| 36 public: | 36 public: |
| 37 // Register to listen for notifications of | 37 // Register to listen for notifications of |
| 38 // NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN from either | 38 // NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN from either |
| 39 // a specific source, or from all sources if |source| is | 39 // a specific source, or from all sources if |source| is |
| 40 // NotificationService::AllSources(). | 40 // NotificationService::AllSources(). |
| 41 explicit SaveLinkAsContextMenuObserver( | 41 explicit ContextMenuWaiter(const content::NotificationSource& source); |
| 42 const content::NotificationSource& source); | 42 ~ContextMenuWaiter() override; |
| 43 ~SaveLinkAsContextMenuObserver() override; | |
| 44 | 43 |
| 45 // Suggested filename for file downloaded through "Save Link As" option. | 44 content::ContextMenuParams& params(); |
| 46 base::string16 GetSuggestedFilename(); | |
| 47 | 45 |
| 48 // Wait for context menu to be visible. | 46 // Wait until the context menu is opened and closed. |
| 49 void WaitForMenu(); | 47 void WaitForMenuOpenAndClose(); |
| 50 | 48 |
| 51 private: | 49 private: |
| 52 void Observe(int type, | 50 void Observe(int type, |
| 53 const content::NotificationSource& source, | 51 const content::NotificationSource& source, |
| 54 const content::NotificationDetails& details) override; | 52 const content::NotificationDetails& details) override; |
| 55 | 53 |
| 56 void Cancel(RenderViewContextMenu* context_menu); | 54 void Cancel(RenderViewContextMenu* context_menu); |
| 57 | 55 |
| 58 bool menu_visible_; | 56 bool menu_visible_; |
| 59 content::ContextMenuParams params_; | 57 content::ContextMenuParams params_; |
| 58 content::NotificationRegistrar registrar_; |
| 60 | 59 |
| 61 DISALLOW_COPY_AND_ASSIGN(SaveLinkAsContextMenuObserver); | 60 DISALLOW_COPY_AND_ASSIGN(ContextMenuWaiter); |
| 62 }; | 61 }; |
| 63 | 62 |
| 64 #endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BROWSER
TEST_UTIL_H_ | 63 #endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BROWSER
TEST_UTIL_H_ |
| OLD | NEW |