Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / extensions / extension_action_platform_delegate_cocoa.h
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.
4
5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_ACTION_PLATFORM_DELEGATE_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_ACTION_PLATFORM_DELEGATE_COCOA_H_
7
8 #include "base/mac/scoped_nsobject.h"
9 #include "chrome/browser/ui/extensions/extension_action_platform_delegate.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
12
13 @class ExtensionActionContextMenuController;
14 @class ExtensionPopupController;
15 class ToolbarActionViewDelegateCocoa;
16
17 // The cocoa-specific implementation for ExtensionActionPlatformDelegate.
18 class ExtensionActionPlatformDelegateCocoa
19     : public ExtensionActionPlatformDelegate,
20       public content::NotificationObserver {
21  public:
22   ExtensionActionPlatformDelegateCocoa(
23       ExtensionActionViewController* controller);
24   ~ExtensionActionPlatformDelegateCocoa() override;
25
26  private:
27   // ExtensionActionPlatformDelegate:
28   gfx::NativeView GetPopupNativeView() override;
29   bool IsMenuRunning() const override;
30   void RegisterCommand() override;
31   void OnDelegateSet() override;
32   bool IsShowingPopup() const override;
33   void CloseActivePopup() override;
34   void CloseOwnPopup() override;
35   bool ShowPopupWithUrl(
36       ExtensionActionViewController::PopupShowAction show_action,
37       const GURL& popup_url,
38       bool grant_tab_permissions) override;
39
40   // content::NotificationObserver:
41   void Observe(int type,
42                const content::NotificationSource& source,
43                const content::NotificationDetails& details) override;
44
45   // Returns the popup shown by this extension action, if one exists.
46   ExtensionPopupController* GetPopup() const;
47
48   // Returns the delegate in its cocoa implementation.
49   ToolbarActionViewDelegateCocoa* GetDelegateCocoa();
50
51   // The main controller for this extension action.
52   ExtensionActionViewController* controller_;
53
54   // The context menu controller for the extension action, if any.
55   base::scoped_nsobject<ExtensionActionContextMenuController> menuController_;
56
57   content::NotificationRegistrar registrar_;
58
59   DISALLOW_COPY_AND_ASSIGN(ExtensionActionPlatformDelegateCocoa);
60 };
61
62 #endif  // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_ACTION_PLATFORM_DELEGATE_COCOA_H_