BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / renderer_context_menu / render_view_context_menu_browsertest_util.h
blobe2b578359d7bf869be25c7e4e5217a81e9f62f39
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BROWSERTEST_UTIL_H_
6 #define CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BROWSERTEST_UTIL_H_
8 #include "base/basictypes.h"
9 #include "base/strings/string16.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
12 #include "content/public/common/context_menu_params.h"
14 class RenderViewContextMenu;
16 class ContextMenuNotificationObserver : public content::NotificationObserver {
17 public:
18 // Wait for a context menu to be shown, and then execute |command_to_execute|.
19 explicit ContextMenuNotificationObserver(int command_to_execute);
20 ~ContextMenuNotificationObserver() override;
22 private:
23 void Observe(int type,
24 const content::NotificationSource& source,
25 const content::NotificationDetails& details) override;
27 void ExecuteCommand(RenderViewContextMenu* context_menu);
29 content::NotificationRegistrar registrar_;
30 int command_to_execute_;
32 DISALLOW_COPY_AND_ASSIGN(ContextMenuNotificationObserver);
35 class ContextMenuWaiter : public content::NotificationObserver {
36 public:
37 // Register to listen for notifications of
38 // NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN from either
39 // a specific source, or from all sources if |source| is
40 // NotificationService::AllSources().
41 explicit ContextMenuWaiter(const content::NotificationSource& source);
42 ~ContextMenuWaiter() override;
44 content::ContextMenuParams& params();
46 // Wait until the context menu is opened and closed.
47 void WaitForMenuOpenAndClose();
49 private:
50 void Observe(int type,
51 const content::NotificationSource& source,
52 const content::NotificationDetails& details) override;
54 void Cancel(RenderViewContextMenu* context_menu);
56 bool menu_visible_;
57 content::ContextMenuParams params_;
58 content::NotificationRegistrar registrar_;
60 DISALLOW_COPY_AND_ASSIGN(ContextMenuWaiter);
63 #endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_RENDER_VIEW_CONTEXT_MENU_BROWSERTEST_UTIL_H_