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