| Index: chrome/browser/ui/cocoa/tab_dialogs_views_mac.mm
|
| diff --git a/chrome/browser/ui/cocoa/tab_dialogs_views_mac.mm b/chrome/browser/ui/cocoa/tab_dialogs_views_mac.mm
|
| index d71c1f239b9f957b6f8c11b4e3a784cb5a5031a8..6cf7a6eeaf211c09b0455ac70ce53c284364c659 100644
|
| --- a/chrome/browser/ui/cocoa/tab_dialogs_views_mac.mm
|
| +++ b/chrome/browser/ui/cocoa/tab_dialogs_views_mac.mm
|
| @@ -4,8 +4,20 @@
|
|
|
| #include "chrome/browser/ui/cocoa/tab_dialogs_views_mac.h"
|
|
|
| +#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"
|
| +#include "chrome/browser/ui/cocoa/browser_window_controller.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/collected_cookies_views.h"
|
| +#include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
|
| #include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.h"
|
| +#include "content/public/browser/web_contents.h"
|
| +#import "ui/base/cocoa/cocoa_base_utils.h"
|
| +#include "ui/base/material_design/material_design_controller.h"
|
| +#import "ui/gfx/mac/coordinate_conversion.h"
|
|
|
| TabDialogsViewsMac::TabDialogsViewsMac(content::WebContents* contents)
|
| : TabDialogsCocoa(contents) {}
|
| @@ -25,3 +37,55 @@ void TabDialogsViewsMac::ShowProfileSigninConfirmation(
|
| ProfileSigninConfirmationDialogViews::ShowDialog(browser, profile, username,
|
| std::move(delegate));
|
| }
|
| +
|
| +void TabDialogsViewsMac::ShowManagePasswordsBubble(bool user_action) {
|
| + if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) {
|
| + TabDialogsCocoa::ShowManagePasswordsBubble(user_action);
|
| + return;
|
| + }
|
| + NSWindow* window = [web_contents()->GetNativeView() window];
|
| + if (!window) {
|
| + // The tab isn't active right now.
|
| + return;
|
| + }
|
| +
|
| + // 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());
|
| + BrowserWindowController* bwc =
|
| + [BrowserWindowController browserWindowControllerForWindow:window];
|
| + gfx::Point anchor_point =
|
| + gfx::ScreenPointFromNSPoint(ui::ConvertPointFromWindowToScreen(
|
| + browser->window()->GetNativeWindow(), [bwc bookmarkBubblePoint]));
|
| + 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);
|
| +}
|
| +
|
| +void TabDialogsViewsMac::HideManagePasswordsBubble() {
|
| + // Close toolkit-views bubble.
|
| + if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) {
|
| + TabDialogsCocoa::HideManagePasswordsBubble();
|
| + return;
|
| + }
|
| + ManagePasswordsBubbleView::CloseCurrentBubble();
|
| +}
|
|
|