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 | |
15 void ShowManagePasswordsBubbleOnCocoaBrowser(NSPoint anchor, | |
16 content::WebContents* web_contents, | |
17 bool user_action) { | |
18 // Don't show the bubble again if it's already showing. A second click on the | |
19 // location icon in the omnibox will dismiss an open bubble. This behaviour is | |
20 // consistent with the non-Mac views implementation. | |
21 // Note that when the browser is toolkit-views, IsBubbleShown() is checked | |
22 // earlier because the bubble is shown on mouse release (but dismissed on | |
23 // mouse pressed). A Cocoa browser does both on mouse pressed, so a check | |
24 // when showing is sufficient. | |
25 if (ManagePasswordsBubbleView::IsBubbleShown()) | |
26 return; | |
27 | |
28 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | |
29 gfx::Point anchor_point = | |
30 gfx::ScreenPointFromNSPoint(ui::ConvertPointFromWindowToScreen( | |
31 browser->window()->GetNativeWindow(), anchor)); | |
32 gfx::NativeView parent = | |
33 platform_util::GetViewForWindow(browser->window()->GetNativeWindow()); | |
34 DCHECK(parent); | |
35 | |
36 ManagePasswordsBubbleView* bubble_view = new ManagePasswordsBubbleView( | |
37 web_contents, nullptr, anchor_point, | |
38 user_action ? LocationBarBubbleDelegateView::USER_GESTURE | |
39 : LocationBarBubbleDelegateView::AUTOMATIC); | |
40 bubble_view->set_parent_window(parent); | |
41 views::BubbleDialogDelegateView::CreateBubble(bubble_view); | |
42 bubble_view->GetWidget()->Show(); | |
43 KeepBubbleAnchored(bubble_view); | |
44 return; | |
tapted
2017/04/11 07:48:58
nit: no return
varkha
2017/04/12 01:57:28
Done.
| |
45 } | |
OLD | NEW |