Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 #include "base/memory/ptr_util.h" | |
| 6 #include "chrome/browser/chooser_controller/chooser_controller.h" | |
| 7 #include "chrome/browser/platform_util.h" | |
| 8 #include "chrome/browser/ui/browser.h" | |
| 9 #include "chrome/browser/ui/browser_window.h" | |
| 10 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | |
| 11 #import "chrome/browser/ui/cocoa/bubble_anchor_helper.h" | |
| 12 #import "chrome/browser/ui/cocoa/bubble_anchor_helper_views.h" | |
| 13 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | |
| 14 #import "chrome/browser/ui/cocoa/permission_bubble/chooser_bubble_ui_cocoa.h" | |
| 15 #include "chrome/browser/ui/permission_bubble/chooser_bubble_delegate.h" | |
| 16 #include "chrome/browser/ui/views/permission_bubble/chooser_bubble_ui.h" | |
|
juncai
2017/05/04 18:27:15
maybe move this include to the top of the include
varkha
2017/05/05 18:23:29
Done.
| |
| 17 #import "ui/base/cocoa/cocoa_base_utils.h" | |
| 18 #include "ui/base/material_design/material_design_controller.h" | |
| 19 #import "ui/gfx/mac/coordinate_conversion.h" | |
| 20 #include "ui/views/bubble/bubble_dialog_delegate.h" | |
| 21 | |
| 22 // Implementation of ChooserBubbleUiView's anchor methods for Cocoa browsers. In | |
| 23 // Cocoa browsers there is no parent views::View for the permission bubble, so | |
| 24 // these methods supply an anchor point instead. | |
| 25 | |
| 26 std::unique_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() { | |
| 27 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) { | |
| 28 return base::MakeUnique<ChooserBubbleUiCocoa>( | |
| 29 browser_, std::move(chooser_controller_)); | |
| 30 } | |
| 31 return base::MakeUnique<ChooserBubbleUi>(browser_, | |
| 32 std::move(chooser_controller_)); | |
| 33 } | |
| 34 | |
| 35 void ChooserBubbleUi::CreateAndShow(views::BubbleDialogDelegateView* delegate) { | |
| 36 // Set |parent_window| because some valid anchors can become hidden. | |
|
juncai
2017/05/04 18:27:15
nit: s/|parent_window|/|parent_window_|
varkha
2017/05/05 18:23:29
Done.
| |
| 37 gfx::NativeView parent = | |
| 38 platform_util::GetViewForWindow(browser_->window()->GetNativeWindow()); | |
| 39 DCHECK(parent); | |
| 40 delegate->set_parent_window(parent); | |
| 41 views::BubbleDialogDelegateView::CreateBubble(delegate)->Show(); | |
| 42 KeepBubbleAnchored(delegate); | |
| 43 } | |
| 44 | |
| 45 views::View* ChooserBubbleUi::GetAnchorView() { | |
| 46 return nullptr; | |
| 47 } | |
| 48 | |
| 49 gfx::Point ChooserBubbleUi::GetAnchorPoint() { | |
| 50 return gfx::ScreenPointFromNSPoint(GetPermissionBubbleAnchorPointForBrowser( | |
| 51 browser_, HasVisibleLocationBarForBrowser(browser_))); | |
| 52 } | |
| 53 | |
| 54 views::BubbleBorder::Arrow ChooserBubbleUi::GetAnchorArrow() { | |
| 55 return HasVisibleLocationBarForBrowser(browser_) | |
| 56 ? views::BubbleBorder::TOP_LEFT | |
| 57 : views::BubbleBorder::NONE; | |
| 58 } | |
| OLD | NEW |