| Index: chrome/browser/ui/cocoa/passwords/passwords_bubble_controller_views.mm
|
| diff --git a/chrome/browser/ui/cocoa/passwords/passwords_bubble_controller_views.mm b/chrome/browser/ui/cocoa/passwords/passwords_bubble_controller_views.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8d99e68ce06c55e330bb7ac3ac4fc29252ebf2d0
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/cocoa/passwords/passwords_bubble_controller_views.mm
|
| @@ -0,0 +1,51 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/platform_util.h"
|
| +#include "chrome/browser/ui/browser.h"
|
| +#include "chrome/browser/ui/browser_finder.h"
|
| +#include "chrome/browser/ui/browser_window.h"
|
| +#import "chrome/browser/ui/cocoa/bubble_anchor_helper_views.h"
|
| +#import "chrome/browser/ui/cocoa/passwords/passwords_bubble_controller.h"
|
| +#include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
|
| +#import "ui/base/cocoa/cocoa_base_utils.h"
|
| +#import "ui/gfx/mac/coordinate_conversion.h"
|
| +
|
| +void CloseViewsManagePasswordsBubbleOnCocoaBrowser() {
|
| + ManagePasswordsBubbleView::CloseCurrentBubble();
|
| +}
|
| +
|
| +void ShowViewsManagePasswordsBubbleOnCocoaBrowser(
|
| + NSPoint anchor,
|
| + content::WebContents* web_contents,
|
| + bool user_action) {
|
| + // Don't show the bubble again if it's already showing. A second click on the
|
| + // location icon in the omnibox will dismiss an open bubble. This behaviour is
|
| + // consistent with the non-Mac views implementation.
|
| + // Note that when the browser is toolkit-views, IsBubbleShown() is checked
|
| + // earlier because the bubble is shown on mouse release (but dismissed on
|
| + // mouse pressed). A Cocoa browser does both on mouse pressed, so a check
|
| + // when showing is sufficient.
|
| + if (ManagePasswordsBubbleView::manage_password_bubble())
|
| + return;
|
| +
|
| + Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
|
| + gfx::Point anchor_point =
|
| + gfx::ScreenPointFromNSPoint(ui::ConvertPointFromWindowToScreen(
|
| + browser->window()->GetNativeWindow(), anchor));
|
| + gfx::NativeView parent =
|
| + platform_util::GetViewForWindow(browser->window()->GetNativeWindow());
|
| + DCHECK(parent);
|
| +
|
| + LocationBarBubbleDelegateView::DisplayReason reason =
|
| + user_action ? LocationBarBubbleDelegateView::USER_GESTURE
|
| + : LocationBarBubbleDelegateView::AUTOMATIC;
|
| + ManagePasswordsBubbleView* bubble_view = new ManagePasswordsBubbleView(
|
| + web_contents, nullptr, anchor_point, reason);
|
| + bubble_view->set_arrow(views::BubbleBorder::TOP_RIGHT);
|
| + bubble_view->set_parent_window(parent);
|
| + views::BubbleDialogDelegateView::CreateBubble(bubble_view);
|
| + bubble_view->ShowForReason(reason);
|
| + KeepBubbleAnchored(bubble_view);
|
| +}
|
|
|