| 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_finder.h" | 7 #include "chrome/browser/ui/browser_finder.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 #import "chrome/browser/ui/cocoa/bubble_anchor_helper.h" |
| 10 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 11 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 11 #import "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_cocoa.h" | 12 #import "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_cocoa.h" |
| 12 #import "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_controller.
h" | 13 #import "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_controller.
h" |
| 13 #include "chrome/browser/ui/views/permission_bubble/permission_prompt_impl.h" | 14 #include "chrome/browser/ui/views/permission_bubble/permission_prompt_impl.h" |
| 14 #import "ui/base/cocoa/cocoa_base_utils.h" | 15 #import "ui/base/cocoa/cocoa_base_utils.h" |
| 15 #include "ui/base/material_design/material_design_controller.h" | 16 #include "ui/base/material_design/material_design_controller.h" |
| 16 #import "ui/gfx/mac/coordinate_conversion.h" | 17 #import "ui/gfx/mac/coordinate_conversion.h" |
| 17 | 18 |
| 18 // Implementation of PermissionPromptImpl's anchor methods for Cocoa | 19 // Implementation of PermissionPromptImpl's anchor methods for Cocoa |
| 19 // browsers. In Cocoa browsers there is no parent views::View for the permission | 20 // browsers. In Cocoa browsers there is no parent views::View for the permission |
| 20 // bubble, so these methods supply an anchor point instead. | 21 // bubble, so these methods supply an anchor point instead. |
| 21 | 22 |
| 22 views::View* PermissionPromptImpl::GetAnchorView() { | 23 views::View* PermissionPromptImpl::GetAnchorView() { |
| 23 return nullptr; | 24 return nullptr; |
| 24 } | 25 } |
| 25 | 26 |
| 26 gfx::Point PermissionPromptImpl::GetAnchorPoint() { | 27 gfx::Point PermissionPromptImpl::GetAnchorPoint() { |
| 27 return gfx::ScreenPointFromNSPoint( | 28 return gfx::ScreenPointFromNSPoint(GetPermissionBubbleAnchorPointForBrowser( |
| 28 [PermissionBubbleController getAnchorPointForBrowser:browser_]); | 29 browser_, HasVisibleLocationBarForBrowser(browser_))); |
| 29 } | 30 } |
| 30 | 31 |
| 31 views::BubbleBorder::Arrow PermissionPromptImpl::GetAnchorArrow() { | 32 views::BubbleBorder::Arrow PermissionPromptImpl::GetAnchorArrow() { |
| 32 return views::BubbleBorder::TOP_LEFT; | 33 return views::BubbleBorder::TOP_LEFT; |
| 33 } | 34 } |
| 34 | 35 |
| 35 // static | 36 // static |
| 36 std::unique_ptr<PermissionPrompt> PermissionPrompt::Create( | 37 std::unique_ptr<PermissionPrompt> PermissionPrompt::Create( |
| 37 content::WebContents* web_contents) { | 38 content::WebContents* web_contents) { |
| 38 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | 39 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 39 return base::WrapUnique(new PermissionPromptImpl( | 40 return base::WrapUnique(new PermissionPromptImpl( |
| 40 chrome::FindBrowserWithWebContents(web_contents))); | 41 chrome::FindBrowserWithWebContents(web_contents))); |
| 41 } | 42 } |
| 42 return base::MakeUnique<PermissionBubbleCocoa>( | 43 return base::MakeUnique<PermissionBubbleCocoa>( |
| 43 chrome::FindBrowserWithWebContents(web_contents)); | 44 chrome::FindBrowserWithWebContents(web_contents)); |
| 44 } | 45 } |
| OLD | NEW |