Commit 4046634c authored by vasilii@chromium.org's avatar vasilii@chromium.org

Close the password bubble on the icon click.

After the password bubble became focusless we need additional code to close it by clicking the "key" icon.

BUG=394680

Review URL: https://codereview.chromium.org/394403003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285641 0039d316-1c4b-4281-b951-d872f2087c98
parent ce2c56b8
......@@ -320,9 +320,6 @@ class LocationBarView : public LocationBar,
// Updates |manage_passwords_icon_view_|. Returns true if visibility changed.
bool RefreshManagePasswordsIconView();
// Shows the manage passwords bubble if there is a savable password.
void ShowManagePasswordsBubbleIfNeeded();
// Helper to show the first run info bubble.
void ShowFirstRunBubbleInternal();
......
......@@ -139,6 +139,11 @@ void AddTitleRow(views::GridLayout* layout, ManagePasswordsBubbleModel* model) {
namespace chrome {
void ShowManagePasswordsBubble(content::WebContents* web_contents) {
if (ManagePasswordsBubbleView::IsShowing()) {
// The bubble is currently shown for some other tab. We should close it now
// and open for |web_contents|.
ManagePasswordsBubbleView::CloseBubble();
}
ManagePasswordsUIController* controller =
ManagePasswordsUIController::FromWebContents(web_contents);
ManagePasswordsBubbleView::ShowBubble(
......@@ -501,11 +506,6 @@ void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed(
ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ =
NULL;
// static
const ManagePasswordsBubbleView* ManagePasswordsBubbleView::Bubble() {
return ManagePasswordsBubbleView::manage_passwords_bubble_;
}
// static
void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents,
DisplayReason reason) {
......
......@@ -163,7 +163,9 @@ class ManagePasswordsBubbleView : public ManagePasswordsBubble,
static bool IsShowing();
// Returns a pointer to the bubble.
static const ManagePasswordsBubbleView* Bubble();
static const ManagePasswordsBubbleView* manage_password_bubble() {
return manage_passwords_bubble_;
}
private:
ManagePasswordsBubbleView(content::WebContents* web_contents,
......
......@@ -82,10 +82,11 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest,
SetupPendingPassword();
// Bubble should not be focused by default.
EXPECT_FALSE(
ManagePasswordsBubbleView::Bubble()->GetFocusManager()->GetFocusedView());
EXPECT_FALSE(ManagePasswordsBubbleView::manage_password_bubble()->
GetFocusManager()->GetFocusedView());
// Bubble can be active if user clicks it.
EXPECT_TRUE(ManagePasswordsBubbleView::Bubble()->CanActivate());
EXPECT_TRUE(ManagePasswordsBubbleView::manage_password_bubble()->
CanActivate());
scoped_ptr<base::HistogramSamples> samples(
GetSamples(kDisplayDispositionMetric));
......
......@@ -66,3 +66,10 @@ bool ManagePasswordsIconView::IsBubbleShowing() const {
void ManagePasswordsIconView::OnExecuting(
BubbleIconView::ExecuteSource source) {
}
bool ManagePasswordsIconView::OnMousePressed(const ui::MouseEvent& event) {
bool result = BubbleIconView::OnMousePressed(event);
if (IsBubbleShowing())
ManagePasswordsBubbleView::CloseBubble();
return result;
}
......@@ -24,6 +24,7 @@ class ManagePasswordsIconView : public ManagePasswordsIcon,
// BubbleIconView:
virtual bool IsBubbleShowing() const OVERRIDE;
virtual void OnExecuting(BubbleIconView::ExecuteSource source) OVERRIDE;
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
#if defined(UNIT_TEST)
int icon_id() const { return icon_id_; }
......
......@@ -8,6 +8,7 @@
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_view_test.h"
#include "components/password_manager/core/common/password_manager_ui.h"
#include "content/public/test/test_utils.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -59,3 +60,16 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsIconViewTest, BlacklistedState) {
view()->SetActive(false);
EXPECT_EQ(IDR_SAVE_PASSWORD_DISABLED_INACTIVE, view()->icon_id());
}
IN_PROC_BROWSER_TEST_F(ManagePasswordsIconViewTest, CloseOnClick) {
SetupPendingPassword();
EXPECT_TRUE(view()->visible());
EXPECT_TRUE(view()->active());
ui::MouseEvent mouse_down(ui::ET_MOUSE_PRESSED,
gfx::Point(10, 10), gfx::Point(900, 60),
ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
static_cast<views::View*>(view())->OnMousePressed(mouse_down);
// Wait for the command execution to close the bubble.
content::RunAllPendingInMessageLoop();
EXPECT_FALSE(view()->active());
}
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