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/ui/browser_window.h" | |
| 8 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | |
| 9 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | |
| 10 #import "chrome/browser/ui/cocoa/permission_bubble/chooser_bubble_ui_cocoa.h" | |
| 11 #include "chrome/browser/ui/permission_bubble/chooser_bubble_delegate.h" | |
| 12 #include "chrome/browser/ui/views/permission_bubble/chooser_bubble_ui_view.h" | |
| 13 #import "ui/base/cocoa/cocoa_base_utils.h" | |
| 14 #include "ui/base/material_design/material_design_controller.h" | |
| 15 #include "ui/base/ui_features.h" | |
| 16 #import "ui/gfx/mac/coordinate_conversion.h" | |
| 17 | |
| 18 namespace { | |
| 19 | |
| 20 // Takes in the parent window, which should be a BrowserWindow, and gets the | |
| 21 // proper anchor point for the bubble. The returned point is in screen | |
| 22 // coordinates. | |
| 23 NSPoint AnchorPointForWindow(NSWindow* parent) { | |
|
varkha
2017/05/02 12:25:48
Self review: simplify with inlines.
varkha
2017/05/03 05:01:20
Acknowledged.
| |
| 24 BrowserWindowController* controller = [parent windowController]; | |
| 25 NSPoint origin = NSZeroPoint; | |
| 26 if ([controller isKindOfClass:[BrowserWindowController class]]) { | |
| 27 LocationBarViewMac* location_bar = [controller locationBarBridge]; | |
| 28 if (location_bar) { | |
| 29 NSPoint bubble_point = location_bar->GetPageInfoBubblePoint(); | |
| 30 origin = ui::ConvertPointFromWindowToScreen(parent, bubble_point); | |
| 31 } | |
|
tapted
2017/05/03 01:10:53
Do we need an else?
Maybe we can move this method
varkha
2017/05/03 05:01:20
Acknowledged. I'll look into this.
| |
| 32 } | |
| 33 return origin; | |
| 34 } | |
| 35 | |
| 36 } // namespace | |
| 37 | |
| 38 #if !BUILDFLAG(MAC_VIEWS_BROWSER) | |
|
tapted
2017/05/03 01:10:53
Can we exclude the entire file under the mac_views
varkha
2017/05/03 05:01:20
Please see if the refactoring I've done makes sens
| |
| 39 std::unique_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() { | |
| 40 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | |
|
varkha
2017/05/02 12:25:48
Self review: simplify by reversing the condition a
varkha
2017/05/03 05:01:20
Done.
| |
| 41 NSWindow* parent = browser_->window()->GetNativeWindow(); | |
| 42 gfx::Point anchor_point = | |
| 43 gfx::ScreenPointFromNSPoint(AnchorPointForWindow(parent)); | |
| 44 return base::MakeUnique<ChooserBubbleUiView>( | |
| 45 browser_, std::move(chooser_controller_), anchor_point); | |
| 46 } | |
| 47 return base::MakeUnique<ChooserBubbleUiCocoa>(browser_, | |
| 48 std::move(chooser_controller_)); | |
| 49 } | |
| 50 #endif | |
| OLD | NEW |