Commit 8aecd2dd authored by vasilii's avatar vasilii Committed by Commit bot

Close the password bubble when the fullscreen state has changed.

BUG=401707

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

Cr-Commit-Position: refs/heads/master@{#300707}
parent c3e32b06
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
#include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
#include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h"
...@@ -14,6 +16,7 @@ ...@@ -14,6 +16,7 @@
#include "chrome/browser/ui/views/passwords/manage_password_item_view.h" #include "chrome/browser/ui/views/passwords/manage_password_item_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
...@@ -30,6 +33,7 @@ ...@@ -30,6 +33,7 @@
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/grid_layout.h" #include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h" #include "ui/views/layout/layout_constants.h"
#include "ui/wm/core/window_animations.h"
// Helpers -------------------------------------------------------------------- // Helpers --------------------------------------------------------------------
...@@ -775,6 +779,13 @@ ManagePasswordsBubbleView::ManagePasswordsBubbleView( ...@@ -775,6 +779,13 @@ ManagePasswordsBubbleView::ManagePasswordsBubbleView(
if (anchor_view) if (anchor_view)
anchor_view->SetActive(true); anchor_view->SetActive(true);
mouse_handler_.reset(new WebContentMouseHandler(this)); mouse_handler_.reset(new WebContentMouseHandler(this));
// Add observers to close the bubble if the fullscreen state changes.
Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
registrar_.Add(
this,
chrome::NOTIFICATION_FULLSCREEN_CHANGED,
content::Source<FullscreenController>(browser->fullscreen_controller()));
} }
ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { ManagePasswordsBubbleView::~ManagePasswordsBubbleView() {
...@@ -856,3 +867,13 @@ void ManagePasswordsBubbleView::WindowClosing() { ...@@ -856,3 +867,13 @@ void ManagePasswordsBubbleView::WindowClosing() {
views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() { views::View* ManagePasswordsBubbleView::GetInitiallyFocusedView() {
return initially_focused_view_; return initially_focused_view_;
} }
void ManagePasswordsBubbleView::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED);
aura::Window* window = GetWidget()->GetNativeView();
wm::SetWindowVisibilityAnimationTransition(window, wm::ANIMATE_NONE);
CloseBubble();
}
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_
#include "chrome/browser/ui/passwords/manage_passwords_bubble.h" #include "chrome/browser/ui/passwords/manage_passwords_bubble.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/views/bubble/bubble_delegate.h" #include "ui/views/bubble/bubble_delegate.h"
class ManagePasswordsIconView; class ManagePasswordsIconView;
...@@ -23,7 +25,8 @@ class WebContents; ...@@ -23,7 +25,8 @@ class WebContents;
// 3. BlacklistedView: Informs the user that the current page is blacklisted. // 3. BlacklistedView: Informs the user that the current page is blacklisted.
// //
class ManagePasswordsBubbleView : public ManagePasswordsBubble, class ManagePasswordsBubbleView : public ManagePasswordsBubble,
public views::BubbleDelegateView { public views::BubbleDelegateView,
public content::NotificationObserver {
public: public:
// Shows the bubble. // Shows the bubble.
static void ShowBubble(content::WebContents* web_contents, static void ShowBubble(content::WebContents* web_contents,
...@@ -90,9 +93,14 @@ class ManagePasswordsBubbleView : public ManagePasswordsBubble, ...@@ -90,9 +93,14 @@ class ManagePasswordsBubbleView : public ManagePasswordsBubble,
virtual void Init() override; virtual void Init() override;
virtual void WindowClosing() override; virtual void WindowClosing() override;
// views::WidgetDelegate // views::WidgetDelegate:
virtual views::View* GetInitiallyFocusedView() override; virtual views::View* GetInitiallyFocusedView() override;
// content::NotificationObserver:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
void set_initially_focused_view(views::View* view) { void set_initially_focused_view(views::View* view) {
DCHECK(!initially_focused_view_); DCHECK(!initially_focused_view_);
initially_focused_view_ = view; initially_focused_view_ = view;
...@@ -116,6 +124,9 @@ class ManagePasswordsBubbleView : public ManagePasswordsBubble, ...@@ -116,6 +124,9 @@ class ManagePasswordsBubbleView : public ManagePasswordsBubble,
class WebContentMouseHandler; class WebContentMouseHandler;
scoped_ptr<WebContentMouseHandler> mouse_handler_; scoped_ptr<WebContentMouseHandler> mouse_handler_;
// Used to register for fullscreen change notifications.
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView); DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView);
}; };
......
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