Index: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
index 720ba64948116f828f4ae87147d209d637a5fd97..cb90bc7df336d084871f1415c4a7e3c4733df6df 100644 |
--- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
+++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc |
@@ -14,6 +14,7 @@ |
#include "chrome/browser/ui/views/passwords/manage_password_item_view.h" |
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
#include "chrome/grit/generated_resources.h" |
+#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/web_contents.h" |
#include "ui/aura/window.h" |
#include "ui/base/l10n/l10n_util.h" |
@@ -636,37 +637,56 @@ void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed( |
// ManagePasswordsBubbleView::WebContentMouseHandler -------------------------- |
// The class listens for WebContentsView events and notifies the bubble if the |
-// view was clicked on. |
+// view was clicked on or received keystrokes. |
class ManagePasswordsBubbleView::WebContentMouseHandler |
: public ui::EventHandler { |
public: |
- explicit WebContentMouseHandler(ManagePasswordsBubbleView* bubble) |
- : bubble_(bubble) { |
- GetWebContentsWindow()->AddPreTargetHandler(this); |
- } |
- |
- virtual ~WebContentMouseHandler() { |
- aura::Window* window = GetWebContentsWindow(); |
- if (window) |
- window->RemovePreTargetHandler(this); |
- } |
+ explicit WebContentMouseHandler(ManagePasswordsBubbleView* bubble); |
+ virtual ~WebContentMouseHandler(); |
- virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
- if (event->type() == ui::ET_MOUSE_PRESSED) |
- bubble_->StartFadingOut(); |
- } |
+ virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
+ virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
private: |
- aura::Window* GetWebContentsWindow() { |
- content::WebContents* web_contents = bubble_->model()->web_contents(); |
- return web_contents ? web_contents->GetNativeView() : NULL; |
- } |
+ aura::Window* GetWebContentsWindow(); |
ManagePasswordsBubbleView* bubble_; |
DISALLOW_COPY_AND_ASSIGN(WebContentMouseHandler); |
}; |
+ManagePasswordsBubbleView::WebContentMouseHandler::WebContentMouseHandler( |
+ ManagePasswordsBubbleView* bubble) : bubble_(bubble) { |
Mike West
2014/09/08 14:53:16
Nit: Shouldn't the initialization be on a separate
vasilii
2014/09/08 16:25:44
Done.
|
+ GetWebContentsWindow()->AddPreTargetHandler(this); |
+} |
+ |
+ManagePasswordsBubbleView::WebContentMouseHandler::~WebContentMouseHandler() { |
+ aura::Window* window = GetWebContentsWindow(); |
+ if (window) |
Mike West
2014/09/08 14:53:16
Nit: You can do this in one line. `if (aura::Windo
vasilii
2014/09/08 16:25:44
Done. Some reviewers don't like assignment in if()
|
+ window->RemovePreTargetHandler(this); |
+} |
+ |
+void ManagePasswordsBubbleView::WebContentMouseHandler::OnKeyEvent( |
+ ui::KeyEvent* event) { |
+ content::WebContents* web_contents = bubble_->model()->web_contents(); |
Mike West
2014/09/08 14:53:16
Nit: I'd skip |web_contents|; it'll never be NULL,
vasilii
2014/09/08 16:25:44
content::RenderViewHost* rvh = bubble_->model()->w
|
+ content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); |
+ if (rvh->IsFocusedElementEditable() && |
+ event->type() == ui::ET_KEY_PRESSED) |
+ bubble_->StartFadingOut(); |
+} |
+ |
+void ManagePasswordsBubbleView::WebContentMouseHandler::OnMouseEvent( |
+ ui::MouseEvent* event) { |
+ if (event->type() == ui::ET_MOUSE_PRESSED) |
+ bubble_->StartFadingOut(); |
+} |
+ |
+aura::Window* |
+ManagePasswordsBubbleView::WebContentMouseHandler::GetWebContentsWindow() { |
+ content::WebContents* web_contents = bubble_->model()->web_contents(); |
+ return web_contents ? web_contents->GetNativeView() : NULL; |
Mike West
2014/09/08 14:53:16
Nit: Will |web_contents| ever be null? Doesn't the
vasilii
2014/09/08 16:25:44
It's NULL if you close the tab with the bubble. Th
|
+} |
+ |
// ManagePasswordsBubbleView::FadeOutObserver --------------------------------- |
// The class notifies the bubble when it faded out completely. |