Commit ed096ee3 authored by Leonard Grey's avatar Leonard Grey Committed by Commit Bot

[Mac] Account for Harmony version of password bubble in closing logic

Bug: 806660
Change-Id: I8c9561b6f456db3fdea0bf31a65bf0af9321cb2c
Reviewed-on: https://chromium-review.googlesource.com/924341Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537413}
parent 11b3e903
......@@ -68,6 +68,10 @@ class ManagePasswordsDecoration : public ImageDecoration {
// Updates child view states.
void UpdateUIState();
// Whether a bubble is already showing. Handles both views and Cocoa
// bubbles.
bool IsBubbleShowing();
// Shows the manage passwords bubble.
CommandUpdater* command_updater_; // Weak, owned by Browser.
......
......@@ -7,10 +7,12 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/ui/cocoa/browser_dialogs_views_mac.h"
#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
#include "chrome/browser/ui/cocoa/passwords/passwords_bubble_cocoa.h"
#import "chrome/browser/ui/cocoa/themed_window.h"
#include "chrome/browser/ui/views/passwords/password_bubble_view_base.h"
#include "ui/base/l10n/l10n_util_mac.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/gfx/color_palette.h"
......@@ -61,8 +63,8 @@ AcceptsPress ManagePasswordsDecoration::AcceptsMousePress() {
}
bool ManagePasswordsDecoration::OnMousePressed(NSRect frame, NSPoint location) {
if (ManagePasswordsBubbleCocoa::instance())
ManagePasswordsBubbleCocoa::instance()->Close();
if (IsBubbleShowing())
HideBubble();
else
command_updater_->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE);
return true;
......@@ -100,8 +102,12 @@ void ManagePasswordsDecoration::UpdateVisibleUI() {
}
void ManagePasswordsDecoration::HideBubble() {
if (icon()->active() && ManagePasswordsBubbleCocoa::instance())
if (chrome::ShowAllDialogsWithViewsToolkit()) {
if (IsBubbleShowing())
PasswordBubbleViewBase::CloseCurrentBubble();
} else if (icon()->active() && ManagePasswordsBubbleCocoa::instance()) {
ManagePasswordsBubbleCocoa::instance()->Close();
}
}
const gfx::VectorIcon* ManagePasswordsDecoration::GetMaterialVectorIcon()
......@@ -110,3 +116,9 @@ const gfx::VectorIcon* ManagePasswordsDecoration::GetMaterialVectorIcon()
// there).
return &kKeyIcon;
}
bool ManagePasswordsDecoration::IsBubbleShowing() {
if (chrome::ShowAllDialogsWithViewsToolkit())
return PasswordBubbleViewBase::manage_password_bubble() != nullptr;
return ManagePasswordsBubbleCocoa::instance() != nullptr;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment