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, ...@@ -320,9 +320,6 @@ class LocationBarView : public LocationBar,
// Updates |manage_passwords_icon_view_|. Returns true if visibility changed. // Updates |manage_passwords_icon_view_|. Returns true if visibility changed.
bool RefreshManagePasswordsIconView(); bool RefreshManagePasswordsIconView();
// Shows the manage passwords bubble if there is a savable password.
void ShowManagePasswordsBubbleIfNeeded();
// Helper to show the first run info bubble. // Helper to show the first run info bubble.
void ShowFirstRunBubbleInternal(); void ShowFirstRunBubbleInternal();
......
...@@ -139,6 +139,11 @@ void AddTitleRow(views::GridLayout* layout, ManagePasswordsBubbleModel* model) { ...@@ -139,6 +139,11 @@ void AddTitleRow(views::GridLayout* layout, ManagePasswordsBubbleModel* model) {
namespace chrome { namespace chrome {
void ShowManagePasswordsBubble(content::WebContents* web_contents) { 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* controller =
ManagePasswordsUIController::FromWebContents(web_contents); ManagePasswordsUIController::FromWebContents(web_contents);
ManagePasswordsBubbleView::ShowBubble( ManagePasswordsBubbleView::ShowBubble(
...@@ -501,11 +506,6 @@ void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed( ...@@ -501,11 +506,6 @@ void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed(
ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ =
NULL; NULL;
// static
const ManagePasswordsBubbleView* ManagePasswordsBubbleView::Bubble() {
return ManagePasswordsBubbleView::manage_passwords_bubble_;
}
// static // static
void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents,
DisplayReason reason) { DisplayReason reason) {
......
...@@ -163,7 +163,9 @@ class ManagePasswordsBubbleView : public ManagePasswordsBubble, ...@@ -163,7 +163,9 @@ class ManagePasswordsBubbleView : public ManagePasswordsBubble,
static bool IsShowing(); static bool IsShowing();
// Returns a pointer to the bubble. // Returns a pointer to the bubble.
static const ManagePasswordsBubbleView* Bubble(); static const ManagePasswordsBubbleView* manage_password_bubble() {
return manage_passwords_bubble_;
}
private: private:
ManagePasswordsBubbleView(content::WebContents* web_contents, ManagePasswordsBubbleView(content::WebContents* web_contents,
......
...@@ -82,10 +82,11 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, ...@@ -82,10 +82,11 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest,
SetupPendingPassword(); SetupPendingPassword();
// Bubble should not be focused by default. // Bubble should not be focused by default.
EXPECT_FALSE( EXPECT_FALSE(ManagePasswordsBubbleView::manage_password_bubble()->
ManagePasswordsBubbleView::Bubble()->GetFocusManager()->GetFocusedView()); GetFocusManager()->GetFocusedView());
// Bubble can be active if user clicks it. // 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( scoped_ptr<base::HistogramSamples> samples(
GetSamples(kDisplayDispositionMetric)); GetSamples(kDisplayDispositionMetric));
......
...@@ -66,3 +66,10 @@ bool ManagePasswordsIconView::IsBubbleShowing() const { ...@@ -66,3 +66,10 @@ bool ManagePasswordsIconView::IsBubbleShowing() const {
void ManagePasswordsIconView::OnExecuting( void ManagePasswordsIconView::OnExecuting(
BubbleIconView::ExecuteSource source) { 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, ...@@ -24,6 +24,7 @@ class ManagePasswordsIconView : public ManagePasswordsIcon,
// BubbleIconView: // BubbleIconView:
virtual bool IsBubbleShowing() const OVERRIDE; virtual bool IsBubbleShowing() const OVERRIDE;
virtual void OnExecuting(BubbleIconView::ExecuteSource source) OVERRIDE; virtual void OnExecuting(BubbleIconView::ExecuteSource source) OVERRIDE;
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
#if defined(UNIT_TEST) #if defined(UNIT_TEST)
int icon_id() const { return icon_id_; } int icon_id() const { return icon_id_; }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_view_test.h" #include "chrome/browser/ui/views/passwords/manage_passwords_view_test.h"
#include "components/password_manager/core/common/password_manager_ui.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/generated_resources.h"
#include "grit/theme_resources.h" #include "grit/theme_resources.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -59,3 +60,16 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsIconViewTest, BlacklistedState) { ...@@ -59,3 +60,16 @@ IN_PROC_BROWSER_TEST_F(ManagePasswordsIconViewTest, BlacklistedState) {
view()->SetActive(false); view()->SetActive(false);
EXPECT_EQ(IDR_SAVE_PASSWORD_DISABLED_INACTIVE, view()->icon_id()); 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