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_UI_COCOA_EXTENSIONS_EXTENSION_ACTION_PLATFORM_DELEGATE_COCOA_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_ACTION_PLATFORM_DELEGATE_COCOA_H_
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"
13 @class ExtensionActionContextMenuController;
14 @class ExtensionPopupController;
15 class ToolbarActionViewDelegateCocoa;
17 // The cocoa-specific implementation for ExtensionActionPlatformDelegate.
18 class ExtensionActionPlatformDelegateCocoa
19 : public ExtensionActionPlatformDelegate,
20 public content::NotificationObserver {
22 ExtensionActionPlatformDelegateCocoa(
23 ExtensionActionViewController* controller);
24 ~ExtensionActionPlatformDelegateCocoa() override;
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;
40 // content::NotificationObserver:
41 void Observe(int type,
42 const content::NotificationSource& source,
43 const content::NotificationDetails& details) override;
45 // Returns the popup shown by this extension action, if one exists.
46 ExtensionPopupController* GetPopup() const;
48 // Returns the delegate in its cocoa implementation.
49 ToolbarActionViewDelegateCocoa* GetDelegateCocoa();
51 // The main controller for this extension action.
52 ExtensionActionViewController* controller_;
54 // The context menu controller for the extension action, if any.
55 base::scoped_nsobject<ExtensionActionContextMenuController> menuController_;
57 content::NotificationRegistrar registrar_;
59 DISALLOW_COPY_AND_ASSIGN(ExtensionActionPlatformDelegateCocoa);
62 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_EXTENSION_ACTION_PLATFORM_DELEGATE_COCOA_H_