Chromium Code Reviews| Index: chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm |
| diff --git a/chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm b/chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm |
| index 00a7030d32307c603a0b453bacbc603a275b7a9d..af6437117ebd19c1671d313c5922380e0433c1dd 100644 |
| --- a/chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm |
| +++ b/chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.mm |
| @@ -4,99 +4,53 @@ |
| #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" |
| -#include "chrome/browser/ui/browser_window.h" |
| +#include "chrome/browser/ui/browser_finder.h" |
| #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| -#import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| -#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h" |
| -#import "chrome/browser/ui/website_settings/permission_bubble_view.h" |
| +#import "chrome/browser/ui/website_settings/permission_bubble_delegate.h" |
| +#import "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
| #include "content/public/browser/web_contents.h" |
| #import "ui/base/cocoa/nsview_additions.h" |
| -PermissionBubbleCocoa::PermissionBubbleCocoa(Browser* browser) |
| - : browser_(browser), delegate_(nullptr), bubbleController_(nil) { |
| - DCHECK(browser); |
| +PermissionBubbleCocoa::PermissionBubbleCocoa(PermissionBubbleManager* manager) |
| + : manager_(manager), bubbleController_(nil) { |
| + DCHECK(manager_); |
| } |
| PermissionBubbleCocoa::~PermissionBubbleCocoa() { |
| } |
| // static |
| -scoped_ptr<PermissionBubbleView> PermissionBubbleView::Create( |
| - Browser* browser) { |
| - return make_scoped_ptr(new PermissionBubbleCocoa(browser)); |
| +scoped_ptr<BubbleUI> PermissionBubbleDelegate::CreateBubble( |
| + PermissionBubbleManager* manager) { |
| + return make_scoped_ptr(new PermissionBubbleCocoa(manager)); |
| } |
| -void PermissionBubbleCocoa::Show( |
| - const std::vector<PermissionBubbleRequest*>& requests, |
| - const std::vector<bool>& accept_state) { |
| +void PermissionBubbleCocoa::Show() { |
| if (!bubbleController_) { |
|
groby-ooo-7-16
2015/08/14 18:26:04
Can we migrate this out so it's shared across bubb
|
| bubbleController_ = [[PermissionBubbleController alloc] |
| - initWithParentWindow:GetParentWindow() |
| - bridge:this]; |
| + initWithBrowser:chrome::FindBrowserWithWebContents( |
| + manager_->web_contents()) |
| + bridge:this]; |
| } |
| - [bubbleController_ showAtAnchor:GetAnchorPoint() |
| - withDelegate:delegate_ |
| - forRequests:requests |
| - acceptStates:accept_state]; |
| + [bubbleController_ showWithManager:manager_ |
| + forRequests:manager_->requests() |
| + acceptStates:manager_->accept_states()]; |
| } |
| void PermissionBubbleCocoa::Hide() { |
| [bubbleController_ close]; |
| } |
| -bool PermissionBubbleCocoa::IsVisible() { |
| - return bubbleController_ != nil; |
| -} |
| - |
| -void PermissionBubbleCocoa::SetDelegate(Delegate* delegate) { |
| - if (delegate_ == delegate) |
| - return; |
| - delegate_ = delegate; |
| -} |
| - |
| -bool PermissionBubbleCocoa::CanAcceptRequestUpdate() { |
| - return ![[[bubbleController_ window] contentView] cr_isMouseInView]; |
| -} |
| - |
| void PermissionBubbleCocoa::UpdateAnchorPosition() { |
| - [bubbleController_ setParentWindow:GetParentWindow()]; |
| - [bubbleController_ setAnchorPoint:GetAnchorPoint()]; |
| + [bubbleController_ updateAnchorPosition]; |
| } |
| -gfx::NativeWindow PermissionBubbleCocoa::GetNativeWindow() { |
| - return [bubbleController_ window]; |
| +bool PermissionBubbleCocoa::CanAcceptUpdate() const { |
| + return ![[[bubbleController_ window] contentView] cr_isMouseInView]; |
| } |
| void PermissionBubbleCocoa::OnBubbleClosing() { |
| bubbleController_ = nil; |
| } |
| - |
| -NSPoint PermissionBubbleCocoa::GetAnchorPoint() { |
| - NSPoint anchor; |
| - if (HasLocationBar()) { |
| - LocationBarViewMac* location_bar = |
| - [[GetParentWindow() windowController] locationBarBridge]; |
| - anchor = location_bar->GetPageInfoBubblePoint(); |
| - } else { |
| - // Center the bubble if there's no location bar. |
| - NSView* content_view = [GetParentWindow() contentView]; |
| - anchor.y = NSMaxY(content_view.frame); |
| - anchor.x = NSMidX(content_view.frame); |
| - } |
| - |
| - return [GetParentWindow() convertBaseToScreen:anchor]; |
| -} |
| - |
| -bool PermissionBubbleCocoa::HasLocationBar() { |
| - return browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); |
| -} |
| - |
| -info_bubble::BubbleArrowLocation PermissionBubbleCocoa::GetArrowLocation() { |
| - return HasLocationBar() ? info_bubble::kTopLeft : info_bubble::kNoArrow; |
| -} |
| - |
| -NSWindow* PermissionBubbleCocoa::GetParentWindow() { |
| - return browser_->window()->GetNativeWindow(); |
| -} |