| 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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "ui/views/controls/link.h" | 26 #include "ui/views/controls/link.h" |
| 27 #include "ui/views/controls/link_listener.h" | 27 #include "ui/views/controls/link_listener.h" |
| 28 #include "ui/views/controls/separator.h" | 28 #include "ui/views/controls/separator.h" |
| 29 #include "ui/views/controls/styled_label.h" | 29 #include "ui/views/controls/styled_label.h" |
| 30 #include "ui/views/controls/styled_label_listener.h" | 30 #include "ui/views/controls/styled_label_listener.h" |
| 31 #include "ui/views/event_monitor.h" | 31 #include "ui/views/event_monitor.h" |
| 32 #include "ui/views/layout/fill_layout.h" | 32 #include "ui/views/layout/fill_layout.h" |
| 33 #include "ui/views/layout/grid_layout.h" | 33 #include "ui/views/layout/grid_layout.h" |
| 34 #include "ui/views/layout/layout_constants.h" | 34 #include "ui/views/layout/layout_constants.h" |
| 35 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
| 36 #include "ui/views/widget/widget_observer_view.h" |
| 36 | 37 |
| 37 int ManagePasswordsBubbleView::auto_signin_toast_timeout_ = 3; | 38 int ManagePasswordsBubbleView::auto_signin_toast_timeout_ = 3; |
| 38 | 39 |
| 39 // Helpers -------------------------------------------------------------------- | 40 // Helpers -------------------------------------------------------------------- |
| 40 | 41 |
| 41 namespace { | 42 namespace { |
| 42 | 43 |
| 43 const int kDesiredBubbleWidth = 370; | 44 const int kDesiredBubbleWidth = 370; |
| 44 const SkColor kWarmWelcomeColor = SkColorSetARGB(0xFF, 0x64, 0x64, 0x64); | 45 const SkColor kWarmWelcomeColor = SkColorSetARGB(0xFF, 0x64, 0x64, 0x64); |
| 45 | 46 |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 content::WebContents* web_contents, | 736 content::WebContents* web_contents, |
| 736 DisplayReason reason) { | 737 DisplayReason reason) { |
| 737 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 738 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 738 DCHECK(browser); | 739 DCHECK(browser); |
| 739 DCHECK(browser->window()); | 740 DCHECK(browser->window()); |
| 740 DCHECK(!manage_passwords_bubble_ || | 741 DCHECK(!manage_passwords_bubble_ || |
| 741 !manage_passwords_bubble_->GetWidget()->IsVisible()); | 742 !manage_passwords_bubble_->GetWidget()->IsVisible()); |
| 742 | 743 |
| 743 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 744 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 744 bool is_fullscreen = browser_view->IsFullscreen(); | 745 bool is_fullscreen = browser_view->IsFullscreen(); |
| 745 ManagePasswordsIconViews* anchor_view = | 746 views::WidgetObserverView* anchor_view = |
| 746 is_fullscreen | 747 is_fullscreen |
| 747 ? NULL | 748 ? NULL |
| 748 : browser_view->GetLocationBarView()->manage_passwords_icon_view(); | 749 : browser_view->GetLocationBarView()->manage_passwords_icon_view(); |
| 749 manage_passwords_bubble_ = new ManagePasswordsBubbleView( | 750 manage_passwords_bubble_ = new ManagePasswordsBubbleView( |
| 750 web_contents, anchor_view, reason); | 751 web_contents, anchor_view, reason); |
| 751 | 752 |
| 752 if (is_fullscreen) | 753 if (is_fullscreen) |
| 753 manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView()); | 754 manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView()); |
| 754 | 755 |
| 755 views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_); | 756 views::Widget* manage_passwords_bubble_widget = |
| 757 views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_); |
| 758 anchor_view->ObserveWidget(manage_passwords_bubble_widget); |
| 756 | 759 |
| 757 // Adjust for fullscreen after creation as it relies on the content size. | 760 // Adjust for fullscreen after creation as it relies on the content size. |
| 758 if (is_fullscreen) { | 761 if (is_fullscreen) { |
| 759 manage_passwords_bubble_->AdjustForFullscreen( | 762 manage_passwords_bubble_->AdjustForFullscreen( |
| 760 browser_view->GetBoundsInScreen()); | 763 browser_view->GetBoundsInScreen()); |
| 761 } | 764 } |
| 762 | 765 |
| 763 manage_passwords_bubble_->ShowForReason(reason); | 766 manage_passwords_bubble_->ShowForReason(reason); |
| 764 } | 767 } |
| 765 | 768 |
| 766 // static | 769 // static |
| 767 void ManagePasswordsBubbleView::CloseBubble() { | 770 void ManagePasswordsBubbleView::CloseBubble() { |
| 768 if (manage_passwords_bubble_) | 771 if (manage_passwords_bubble_) |
| 769 manage_passwords_bubble_->Close(); | 772 manage_passwords_bubble_->Close(); |
| 770 } | 773 } |
| 771 | 774 |
| 772 // static | 775 // static |
| 773 void ManagePasswordsBubbleView::ActivateBubble() { | 776 void ManagePasswordsBubbleView::ActivateBubble() { |
| 774 DCHECK(manage_passwords_bubble_); | 777 DCHECK(manage_passwords_bubble_); |
| 775 DCHECK(manage_passwords_bubble_->GetWidget()->IsVisible()); | 778 DCHECK(manage_passwords_bubble_->GetWidget()->IsVisible()); |
| 776 manage_passwords_bubble_->GetWidget()->Activate(); | 779 manage_passwords_bubble_->GetWidget()->Activate(); |
| 777 } | 780 } |
| 778 | 781 |
| 779 content::WebContents* ManagePasswordsBubbleView::web_contents() const { | 782 content::WebContents* ManagePasswordsBubbleView::web_contents() const { |
| 780 return model_.web_contents(); | 783 return model_.web_contents(); |
| 781 } | 784 } |
| 782 | 785 |
| 783 ManagePasswordsBubbleView::ManagePasswordsBubbleView( | 786 ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
| 784 content::WebContents* web_contents, | 787 content::WebContents* web_contents, |
| 785 ManagePasswordsIconViews* anchor_view, | 788 views::View* anchor_view, |
| 786 DisplayReason reason) | 789 DisplayReason reason) |
| 787 : LocationBarBubbleDelegateView(anchor_view, web_contents), | 790 : LocationBarBubbleDelegateView(anchor_view, web_contents), |
| 788 model_(web_contents, | 791 model_(web_contents, |
| 789 reason == AUTOMATIC ? ManagePasswordsBubbleModel::AUTOMATIC | 792 reason == AUTOMATIC ? ManagePasswordsBubbleModel::AUTOMATIC |
| 790 : ManagePasswordsBubbleModel::USER_ACTION), | 793 : ManagePasswordsBubbleModel::USER_ACTION), |
| 791 anchor_view_(anchor_view), | |
| 792 initially_focused_view_(nullptr) { | 794 initially_focused_view_(nullptr) { |
| 793 // Compensate for built-in vertical padding in the anchor view's image. | 795 // Compensate for built-in vertical padding in the anchor view's image. |
| 794 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); | 796 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
| 795 | 797 |
| 796 const int top_margin = ShouldShowCloseButton() ? margins().top() | 798 const int top_margin = ShouldShowCloseButton() ? margins().top() |
| 797 : views::kPanelVertMargin; | 799 : views::kPanelVertMargin; |
| 798 set_margins(gfx::Insets(top_margin, views::kPanelHorizMargin, | 800 set_margins(gfx::Insets(top_margin, views::kPanelHorizMargin, |
| 799 views::kPanelVertMargin, views::kPanelHorizMargin)); | 801 views::kPanelVertMargin, views::kPanelHorizMargin)); |
| 800 mouse_handler_.reset(new WebContentMouseHandler(this)); | 802 mouse_handler_.reset(new WebContentMouseHandler(this)); |
| 801 } | 803 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 AddChildView(new UpdatePendingView(this)); | 837 AddChildView(new UpdatePendingView(this)); |
| 836 } else if (model_.state() == password_manager::ui::CONFIRMATION_STATE) { | 838 } else if (model_.state() == password_manager::ui::CONFIRMATION_STATE) { |
| 837 AddChildView(new SaveConfirmationView(this)); | 839 AddChildView(new SaveConfirmationView(this)); |
| 838 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { | 840 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { |
| 839 AddChildView(new AutoSigninView(this)); | 841 AddChildView(new AutoSigninView(this)); |
| 840 } else { | 842 } else { |
| 841 AddChildView(new ManageView(this)); | 843 AddChildView(new ManageView(this)); |
| 842 } | 844 } |
| 843 GetLayoutManager()->Layout(this); | 845 GetLayoutManager()->Layout(this); |
| 844 } | 846 } |
| OLD | NEW |