Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc

Issue 512683003: Password bubble should close if user clicks on the web page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 5 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h" 9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/browser_window.h" 10 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 11 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
12 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 12 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
13 #include "chrome/browser/ui/views/frame/browser_view.h" 13 #include "chrome/browser/ui/views/frame/browser_view.h"
14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
15 #include "chrome/browser/ui/views/passwords/manage_password_item_view.h" 15 #include "chrome/browser/ui/views/passwords/manage_password_item_view.h"
16 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" 16 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
17 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
18 #include "components/password_manager/core/common/password_manager_ui.h" 18 #include "components/password_manager/core/common/password_manager_ui.h"
19 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
20 #include "content/public/browser/web_contents.h"
21 #include "ui/aura/window.h"
20 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/models/combobox_model.h" 23 #include "ui/base/models/combobox_model.h"
22 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/gfx/text_utils.h" 25 #include "ui/gfx/text_utils.h"
24 #include "ui/views/controls/button/blue_button.h" 26 #include "ui/views/controls/button/blue_button.h"
25 #include "ui/views/controls/button/label_button.h" 27 #include "ui/views/controls/button/label_button.h"
26 #include "ui/views/controls/combobox/combobox.h" 28 #include "ui/views/controls/combobox/combobox.h"
27 #include "ui/views/controls/styled_label.h" 29 #include "ui/views/controls/styled_label.h"
28 #include "ui/views/layout/fill_layout.h" 30 #include "ui/views/layout/fill_layout.h"
29 #include "ui/views/layout/grid_layout.h" 31 #include "ui/views/layout/grid_layout.h"
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 parent_->Close(); 507 parent_->Close();
506 } 508 }
507 509
508 void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed( 510 void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed(
509 views::Button* sender, const ui::Event& event) { 511 views::Button* sender, const ui::Event& event) {
510 DCHECK_EQ(sender, ok_button_); 512 DCHECK_EQ(sender, ok_button_);
511 parent_->model()->OnOKClicked(); 513 parent_->model()->OnOKClicked();
512 parent_->Close(); 514 parent_->Close();
513 } 515 }
514 516
517 // ManagePasswordsBubbleView::WebContentMouseHandler --------------------------
518
519 // The class listens WebContentsView for mouse clicks.
vabr (Chromium) 2014/08/27 16:43:05 nit: listens -> listens to
vabr (Chromium) 2014/08/27 16:43:05 nit: Could you extend the comment to say what the
vasilii 2014/08/27 17:24:24 Done.
vasilii 2014/08/27 17:24:24 Done.
520 class ManagePasswordsBubbleView::WebContentMouseHandler
521 : public ui::EventHandler {
522 public:
523 explicit WebContentMouseHandler(ManagePasswordsBubbleView* bubble)
524 : bubble_(bubble) {
525 GetWebContentsWindow()->AddPreTargetHandler(this);
526 }
527
528 virtual ~WebContentMouseHandler() {
529 aura::Window* window = GetWebContentsWindow();
530 if (window)
531 window->RemovePreTargetHandler(this);
532 }
533
534 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
535 if (event->type() == ui::ET_MOUSE_PRESSED)
536 bubble_->OnWebContentClicked();
537 }
538
539 private:
540 aura::Window* GetWebContentsWindow() {
541 content::WebContents* web_contents = bubble_->model()->web_contents();
542 return web_contents ? web_contents->GetNativeView() : NULL;
543 }
544
545 ManagePasswordsBubbleView* bubble_;
546
547 DISALLOW_COPY_AND_ASSIGN(WebContentMouseHandler);
548 };
549
515 // ManagePasswordsBubbleView -------------------------------------------------- 550 // ManagePasswordsBubbleView --------------------------------------------------
516 551
517 // static 552 // static
518 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ = 553 ManagePasswordsBubbleView* ManagePasswordsBubbleView::manage_passwords_bubble_ =
519 NULL; 554 NULL;
520 555
521 // static 556 // static
522 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents, 557 void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents,
523 DisplayReason reason) { 558 DisplayReason reason) {
524 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 559 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 anchor_view ? views::BubbleBorder::TOP_RIGHT 621 anchor_view ? views::BubbleBorder::TOP_RIGHT
587 : views::BubbleBorder::NONE), 622 : views::BubbleBorder::NONE),
588 anchor_view_(anchor_view), 623 anchor_view_(anchor_view),
589 never_save_passwords_(false), 624 never_save_passwords_(false),
590 initially_focused_view_(NULL) { 625 initially_focused_view_(NULL) {
591 // Compensate for built-in vertical padding in the anchor view's image. 626 // Compensate for built-in vertical padding in the anchor view's image.
592 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); 627 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0));
593 set_notify_enter_exit_on_child(true); 628 set_notify_enter_exit_on_child(true);
594 if (anchor_view) 629 if (anchor_view)
595 anchor_view->SetActive(true); 630 anchor_view->SetActive(true);
631 mouse_handler_.reset(new WebContentMouseHandler(this));
596 } 632 }
597 633
598 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() { 634 ManagePasswordsBubbleView::~ManagePasswordsBubbleView() {
599 if (anchor_view_) 635 if (anchor_view_)
600 anchor_view_->SetActive(false); 636 anchor_view_->SetActive(false);
601 } 637 }
602 638
603 void ManagePasswordsBubbleView::AdjustForFullscreen( 639 void ManagePasswordsBubbleView::AdjustForFullscreen(
604 const gfx::Rect& screen_bounds) { 640 const gfx::Rect& screen_bounds) {
605 if (GetAnchorView()) 641 if (GetAnchorView())
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 730
695 void ManagePasswordsBubbleView::StartTimerIfNecessary() { 731 void ManagePasswordsBubbleView::StartTimerIfNecessary() {
696 // Active bubble will stay visible until it loses focus. 732 // Active bubble will stay visible until it loses focus.
697 if (GetWidget()->IsActive()) 733 if (GetWidget()->IsActive())
698 return; 734 return;
699 timer_.Start(FROM_HERE, 735 timer_.Start(FROM_HERE,
700 base::TimeDelta::FromSeconds(kBubbleCloseDelay), 736 base::TimeDelta::FromSeconds(kBubbleCloseDelay),
701 this, 737 this,
702 &ManagePasswordsBubbleView::Close); 738 &ManagePasswordsBubbleView::Close);
703 } 739 }
740
741 void ManagePasswordsBubbleView::OnWebContentClicked() {
742 Close();
743 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698