OLD | NEW |
---|---|
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/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
9 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
10 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 10 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
11 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" | 11 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" |
12 #include "chrome/browser/ui/views/frame/browser_view.h" | 12 #include "chrome/browser/ui/views/frame/browser_view.h" |
13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
14 #include "chrome/browser/ui/views/passwords/manage_password_item_view.h" | 14 #include "chrome/browser/ui/views/passwords/manage_password_item_view.h" |
15 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | 15 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
16 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
17 #include "content/public/browser/render_view_host.h" | |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
18 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/compositor/layer_animation_observer.h" | 22 #include "ui/compositor/layer_animation_observer.h" |
22 #include "ui/compositor/scoped_layer_animation_settings.h" | 23 #include "ui/compositor/scoped_layer_animation_settings.h" |
23 #include "ui/views/controls/button/blue_button.h" | 24 #include "ui/views/controls/button/blue_button.h" |
24 #include "ui/views/controls/button/label_button.h" | 25 #include "ui/views/controls/button/label_button.h" |
25 #include "ui/views/controls/combobox/combobox.h" | 26 #include "ui/views/controls/combobox/combobox.h" |
26 #include "ui/views/controls/combobox/combobox_listener.h" | 27 #include "ui/views/controls/combobox/combobox_listener.h" |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed( | 630 void ManagePasswordsBubbleView::SaveConfirmationView::ButtonPressed( |
630 views::Button* sender, const ui::Event& event) { | 631 views::Button* sender, const ui::Event& event) { |
631 DCHECK_EQ(sender, ok_button_); | 632 DCHECK_EQ(sender, ok_button_); |
632 parent_->model()->OnOKClicked(); | 633 parent_->model()->OnOKClicked(); |
633 parent_->Close(); | 634 parent_->Close(); |
634 } | 635 } |
635 | 636 |
636 // ManagePasswordsBubbleView::WebContentMouseHandler -------------------------- | 637 // ManagePasswordsBubbleView::WebContentMouseHandler -------------------------- |
637 | 638 |
638 // The class listens for WebContentsView events and notifies the bubble if the | 639 // The class listens for WebContentsView events and notifies the bubble if the |
639 // view was clicked on. | 640 // view was clicked on or received keystrokes. |
640 class ManagePasswordsBubbleView::WebContentMouseHandler | 641 class ManagePasswordsBubbleView::WebContentMouseHandler |
641 : public ui::EventHandler { | 642 : public ui::EventHandler { |
642 public: | 643 public: |
643 explicit WebContentMouseHandler(ManagePasswordsBubbleView* bubble) | 644 explicit WebContentMouseHandler(ManagePasswordsBubbleView* bubble); |
644 : bubble_(bubble) { | 645 virtual ~WebContentMouseHandler(); |
645 GetWebContentsWindow()->AddPreTargetHandler(this); | |
646 } | |
647 | 646 |
648 virtual ~WebContentMouseHandler() { | 647 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
649 aura::Window* window = GetWebContentsWindow(); | 648 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
650 if (window) | |
651 window->RemovePreTargetHandler(this); | |
652 } | |
653 | |
654 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | |
655 if (event->type() == ui::ET_MOUSE_PRESSED) | |
656 bubble_->StartFadingOut(); | |
657 } | |
658 | 649 |
659 private: | 650 private: |
660 aura::Window* GetWebContentsWindow() { | 651 aura::Window* GetWebContentsWindow(); |
661 content::WebContents* web_contents = bubble_->model()->web_contents(); | |
662 return web_contents ? web_contents->GetNativeView() : NULL; | |
663 } | |
664 | 652 |
665 ManagePasswordsBubbleView* bubble_; | 653 ManagePasswordsBubbleView* bubble_; |
666 | 654 |
667 DISALLOW_COPY_AND_ASSIGN(WebContentMouseHandler); | 655 DISALLOW_COPY_AND_ASSIGN(WebContentMouseHandler); |
668 }; | 656 }; |
669 | 657 |
658 ManagePasswordsBubbleView::WebContentMouseHandler::WebContentMouseHandler( | |
659 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.
| |
660 GetWebContentsWindow()->AddPreTargetHandler(this); | |
661 } | |
662 | |
663 ManagePasswordsBubbleView::WebContentMouseHandler::~WebContentMouseHandler() { | |
664 aura::Window* window = GetWebContentsWindow(); | |
665 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()
| |
666 window->RemovePreTargetHandler(this); | |
667 } | |
668 | |
669 void ManagePasswordsBubbleView::WebContentMouseHandler::OnKeyEvent( | |
670 ui::KeyEvent* event) { | |
671 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
| |
672 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); | |
673 if (rvh->IsFocusedElementEditable() && | |
674 event->type() == ui::ET_KEY_PRESSED) | |
675 bubble_->StartFadingOut(); | |
676 } | |
677 | |
678 void ManagePasswordsBubbleView::WebContentMouseHandler::OnMouseEvent( | |
679 ui::MouseEvent* event) { | |
680 if (event->type() == ui::ET_MOUSE_PRESSED) | |
681 bubble_->StartFadingOut(); | |
682 } | |
683 | |
684 aura::Window* | |
685 ManagePasswordsBubbleView::WebContentMouseHandler::GetWebContentsWindow() { | |
686 content::WebContents* web_contents = bubble_->model()->web_contents(); | |
687 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
| |
688 } | |
689 | |
670 // ManagePasswordsBubbleView::FadeOutObserver --------------------------------- | 690 // ManagePasswordsBubbleView::FadeOutObserver --------------------------------- |
671 | 691 |
672 // The class notifies the bubble when it faded out completely. | 692 // The class notifies the bubble when it faded out completely. |
673 class ManagePasswordsBubbleView::FadeOutObserver | 693 class ManagePasswordsBubbleView::FadeOutObserver |
674 : public ui::ImplicitAnimationObserver { | 694 : public ui::ImplicitAnimationObserver { |
675 public: | 695 public: |
676 explicit FadeOutObserver(ManagePasswordsBubbleView* bubble) | 696 explicit FadeOutObserver(ManagePasswordsBubbleView* bubble) |
677 : bubble_(bubble) { | 697 : bubble_(bubble) { |
678 } | 698 } |
679 | 699 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
879 if (!fadeout_observer_) | 899 if (!fadeout_observer_) |
880 return; | 900 return; |
881 fadeout_observer_.reset(); | 901 fadeout_observer_.reset(); |
882 aura::Window* window = GetWidget()->GetNativeView(); | 902 aura::Window* window = GetWidget()->GetNativeView(); |
883 window->layer()->SetOpacity(1); | 903 window->layer()->SetOpacity(1); |
884 } | 904 } |
885 | 905 |
886 void ManagePasswordsBubbleView::OnBubbleDisappeared() { | 906 void ManagePasswordsBubbleView::OnBubbleDisappeared() { |
887 Close(); | 907 Close(); |
888 } | 908 } |
OLD | NEW |