OLD | NEW |
---|---|
(Empty) | |
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 #import "chrome/browser/ui/cocoa/extensions/extension_action_platform_delegate_c ocoa.h" | |
6 | |
7 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" | |
8 #import "chrome/browser/ui/cocoa/toolbar/toolbar_action_view_delegate_cocoa.h" | |
9 #include "extensions/common/extension.h" | |
10 | |
11 // static | |
12 scoped_ptr<ExtensionActionPlatformDelegate> | |
13 ExtensionActionPlatformDelegate::Create( | |
14 ExtensionActionViewController* controller) { | |
15 return make_scoped_ptr(new ExtensionActionPlatformDelegateCocoa(controller)); | |
16 } | |
17 | |
18 ExtensionActionPlatformDelegateCocoa::ExtensionActionPlatformDelegateCocoa( | |
19 ExtensionActionViewController* controller) | |
20 : controller_(controller) { | |
21 } | |
22 | |
23 ExtensionActionPlatformDelegateCocoa::~ExtensionActionPlatformDelegateCocoa() { | |
24 } | |
25 | |
26 gfx::NativeView ExtensionActionPlatformDelegateCocoa::GetPopupNativeView() { | |
27 ExtensionPopupController* popup = GetPopup(); | |
28 return popup != nil ? [popup view] : nullptr; | |
Avi (use Gerrit)
2014/10/30 23:21:26
NativeView is an NSView, so nil rather than nullpt
Devlin
2014/10/31 17:50:43
Done.
| |
29 } | |
30 | |
31 bool ExtensionActionPlatformDelegateCocoa::IsMenuRunning() const { | |
32 // TODO(devlin): Also account for context menus. | |
33 return GetPopup() != nil; | |
34 } | |
35 | |
36 void ExtensionActionPlatformDelegateCocoa::RegisterCommand() { | |
37 // Commands are handled elsewhere for cocoa. | |
38 } | |
39 | |
40 void ExtensionActionPlatformDelegateCocoa::OnDelegateSet() { | |
41 } | |
42 | |
43 bool ExtensionActionPlatformDelegateCocoa::IsShowingPopup() const { | |
44 return GetPopup() != nil; | |
45 } | |
46 | |
47 void ExtensionActionPlatformDelegateCocoa::CloseActivePopup() { | |
48 ExtensionPopupController* popup = [ExtensionPopupController popup]; | |
49 if (popup) | |
50 [popup close]; | |
51 } | |
52 | |
53 void ExtensionActionPlatformDelegateCocoa::CloseOwnPopup() { | |
54 ExtensionPopupController* popup = GetPopup(); | |
55 DCHECK(popup); | |
56 [popup close]; | |
57 } | |
58 | |
59 bool ExtensionActionPlatformDelegateCocoa::ShowPopupWithUrl( | |
60 ExtensionActionViewController::PopupShowAction show_action, | |
61 const GURL& popup_url, | |
62 bool grant_tab_permissions) { | |
63 NSPoint arrowPoint = GetDelegateCocoa()->GetPopupPoint(); | |
64 [ExtensionPopupController showURL:popup_url | |
65 inBrowser:controller_->browser() | |
66 anchoredAt:arrowPoint | |
67 arrowLocation:info_bubble::kTopRight | |
68 devMode:NO]; | |
69 return true; | |
70 } | |
71 | |
72 ToolbarActionViewDelegateCocoa* | |
73 ExtensionActionPlatformDelegateCocoa::GetDelegateCocoa() { | |
74 return static_cast<ToolbarActionViewDelegateCocoa*>( | |
75 controller_->view_delegate()); | |
76 } | |
77 | |
78 ExtensionPopupController* ExtensionActionPlatformDelegateCocoa::GetPopup() | |
79 const { | |
80 ExtensionPopupController* popup = [ExtensionPopupController popup]; | |
81 return popup && [popup extensionId] == controller_->extension()->id() ? | |
82 popup : nil; | |
83 } | |
OLD | NEW |