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 "chrome/browser/platform_util.h" | |
| 6 #include "chrome/browser/ui/browser.h" | |
| 7 #include "chrome/browser/ui/browser_finder.h" | |
| 8 #include "chrome/browser/ui/browser_window.h" | |
| 9 #import "chrome/browser/ui/cocoa/bubble_anchor_helper_views.h" | |
| 10 #import "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h" | |
| 11 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | |
| 12 #import "ui/base/cocoa/cocoa_base_utils.h" | |
| 13 #import "ui/gfx/mac/coordinate_conversion.h" | |
| 14 | |
|
varkha
2017/04/19 08:34:17
I think this can be rolled in Mac-views-specific T
| |
| 15 void ShowViewsManagePasswordsBubbleOnCocoaBrowser( | |
| 16 NSPoint anchor, | |
| 17 content::WebContents* web_contents, | |
| 18 bool user_action) { | |
| 19 // Don't show the bubble again if it's already showing. A second click on the | |
| 20 // location icon in the omnibox will dismiss an open bubble. This behaviour is | |
| 21 // consistent with the non-Mac views implementation. | |
| 22 // Note that when the browser is toolkit-views, IsBubbleShown() is checked | |
| 23 // earlier because the bubble is shown on mouse release (but dismissed on | |
| 24 // mouse pressed). A Cocoa browser does both on mouse pressed, so a check | |
| 25 // when showing is sufficient. | |
| 26 if (ManagePasswordsBubbleView::manage_password_bubble()) | |
| 27 return; | |
| 28 | |
| 29 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | |
| 30 gfx::Point anchor_point = | |
| 31 gfx::ScreenPointFromNSPoint(ui::ConvertPointFromWindowToScreen( | |
| 32 browser->window()->GetNativeWindow(), anchor)); | |
| 33 gfx::NativeView parent = | |
| 34 platform_util::GetViewForWindow(browser->window()->GetNativeWindow()); | |
| 35 DCHECK(parent); | |
| 36 | |
| 37 LocationBarBubbleDelegateView::DisplayReason reason = | |
| 38 user_action ? LocationBarBubbleDelegateView::USER_GESTURE | |
| 39 : LocationBarBubbleDelegateView::AUTOMATIC; | |
| 40 ManagePasswordsBubbleView* bubble_view = new ManagePasswordsBubbleView( | |
| 41 web_contents, nullptr, anchor_point, reason); | |
| 42 bubble_view->set_arrow(views::BubbleBorder::TOP_RIGHT); | |
| 43 bubble_view->set_parent_window(parent); | |
| 44 views::BubbleDialogDelegateView::CreateBubble(bubble_view); | |
| 45 bubble_view->ShowForReason(reason); | |
| 46 KeepBubbleAnchored(bubble_view); | |
| 47 } | |
| OLD | NEW |