| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/ptr_util.h" | 5 #include "base/memory/ptr_util.h" |
| 6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/browser_dialogs.h" | 7 #include "chrome/browser/ui/browser_dialogs.h" |
| 8 #include "chrome/browser/ui/browser_window.h" | 8 #include "chrome/browser/ui/browser_window.h" |
| 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 10 #include "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h" |
| 10 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" | 11 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" |
| 11 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h
" | 12 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h
" |
| 12 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 13 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 13 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" | 14 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" |
| 14 #import "ui/base/cocoa/cocoa_base_utils.h" | 15 #import "ui/base/cocoa/cocoa_base_utils.h" |
| 15 #import "ui/gfx/mac/coordinate_conversion.h" | 16 #import "ui/gfx/mac/coordinate_conversion.h" |
| 16 | 17 |
| 17 // Implementation of PermissionBubbleViewViews' anchor methods for Cocoa | 18 // Implementation of PermissionBubbleViewViews' anchor methods for Cocoa |
| 18 // browsers. In Cocoa browsers there is no parent views::View for the permission | 19 // browsers. In Cocoa browsers there is no parent views::View for the permission |
| 19 // bubble, so these methods supply an anchor point instead. | 20 // bubble, so these methods supply an anchor point instead. |
| 20 | 21 |
| 21 views::View* PermissionBubbleViewViews::GetAnchorView() { | 22 views::View* PermissionBubbleViewViews::GetAnchorView() { |
| 22 return nullptr; | 23 return nullptr; |
| 23 } | 24 } |
| 24 | 25 |
| 25 gfx::Point PermissionBubbleViewViews::GetAnchorPoint() { | 26 gfx::Point PermissionBubbleViewViews::GetAnchorPoint() { |
| 26 return gfx::ScreenPointFromNSPoint( | 27 return gfx::ScreenPointFromNSPoint( |
| 27 [PermissionBubbleController getAnchorPointForBrowser:browser_]); | 28 [PermissionBubbleController getAnchorPointForBrowser:browser_]); |
| 28 } | 29 } |
| 29 | 30 |
| 30 views::BubbleBorder::Arrow PermissionBubbleViewViews::GetAnchorArrow() { | 31 views::BubbleBorder::Arrow PermissionBubbleViewViews::GetAnchorArrow() { |
| 31 return [PermissionBubbleController hasVisibleLocationBarForBrowser:browser_] | 32 return [PermissionBubbleController hasVisibleLocationBarForBrowser:browser_] |
| 32 ? views::BubbleBorder::TOP_LEFT | 33 ? views::BubbleBorder::TOP_LEFT |
| 33 : views::BubbleBorder::NONE; | 34 : views::BubbleBorder::NONE; |
| 34 } | 35 } |
| 35 | 36 |
| 37 gfx::NativeView PermissionBubbleViewViews::GetExclusiveAccessNativeView() { |
| 38 BrowserWindowController* controller = [BrowserWindowController |
| 39 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]; |
| 40 return [controller exclusiveAccessController]->GetNativeView(); |
| 41 } |
| 42 |
| 36 // static | 43 // static |
| 37 std::unique_ptr<PermissionBubbleView> PermissionBubbleView::Create( | 44 std::unique_ptr<PermissionBubbleView> PermissionBubbleView::Create( |
| 38 Browser* browser) { | 45 Browser* browser) { |
| 39 if (chrome::ToolkitViewsWebUIDialogsEnabled()) | 46 if (chrome::ToolkitViewsWebUIDialogsEnabled()) |
| 40 return base::WrapUnique(new PermissionBubbleViewViews(browser)); | 47 return base::WrapUnique(new PermissionBubbleViewViews(browser)); |
| 41 return base::WrapUnique(new PermissionBubbleCocoa(browser)); | 48 return base::WrapUnique(new PermissionBubbleCocoa(browser)); |
| 42 } | 49 } |
| OLD | NEW |