| 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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 ManagePasswordsIconViews* anchor_view = | 745 ManagePasswordsIconViews* anchor_view = |
| 746 is_fullscreen | 746 is_fullscreen |
| 747 ? NULL | 747 ? NULL |
| 748 : browser_view->GetLocationBarView()->manage_passwords_icon_view(); | 748 : browser_view->GetLocationBarView()->manage_passwords_icon_view(); |
| 749 manage_passwords_bubble_ = new ManagePasswordsBubbleView( | 749 manage_passwords_bubble_ = new ManagePasswordsBubbleView( |
| 750 web_contents, anchor_view, reason); | 750 web_contents, anchor_view, reason); |
| 751 | 751 |
| 752 if (is_fullscreen) | 752 if (is_fullscreen) |
| 753 manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView()); | 753 manage_passwords_bubble_->set_parent_window(web_contents->GetNativeView()); |
| 754 | 754 |
| 755 views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_); | 755 views::Widget* manage_passwords_bubble_widget = |
| 756 views::BubbleDelegateView::CreateBubble(manage_passwords_bubble_); |
| 757 manage_passwords_bubble_widget->AddObserver(anchor_view); |
| 756 | 758 |
| 757 // Adjust for fullscreen after creation as it relies on the content size. | 759 // Adjust for fullscreen after creation as it relies on the content size. |
| 758 if (is_fullscreen) { | 760 if (is_fullscreen) { |
| 759 manage_passwords_bubble_->AdjustForFullscreen( | 761 manage_passwords_bubble_->AdjustForFullscreen( |
| 760 browser_view->GetBoundsInScreen()); | 762 browser_view->GetBoundsInScreen()); |
| 761 } | 763 } |
| 762 | 764 |
| 763 manage_passwords_bubble_->ShowForReason(reason); | 765 manage_passwords_bubble_->ShowForReason(reason); |
| 764 } | 766 } |
| 765 | 767 |
| 766 // static | 768 // static |
| 767 void ManagePasswordsBubbleView::CloseBubble() { | 769 void ManagePasswordsBubbleView::CloseBubble() { |
| 768 if (manage_passwords_bubble_) | 770 if (manage_passwords_bubble_) |
| 769 manage_passwords_bubble_->Close(); | 771 manage_passwords_bubble_->Close(); |
| 770 } | 772 } |
| 771 | 773 |
| 772 // static | 774 // static |
| 773 void ManagePasswordsBubbleView::ActivateBubble() { | 775 void ManagePasswordsBubbleView::ActivateBubble() { |
| 774 DCHECK(manage_passwords_bubble_); | 776 DCHECK(manage_passwords_bubble_); |
| 775 DCHECK(manage_passwords_bubble_->GetWidget()->IsVisible()); | 777 DCHECK(manage_passwords_bubble_->GetWidget()->IsVisible()); |
| 776 manage_passwords_bubble_->GetWidget()->Activate(); | 778 manage_passwords_bubble_->GetWidget()->Activate(); |
| 777 } | 779 } |
| 778 | 780 |
| 779 content::WebContents* ManagePasswordsBubbleView::web_contents() const { | 781 content::WebContents* ManagePasswordsBubbleView::web_contents() const { |
| 780 return model_.web_contents(); | 782 return model_.web_contents(); |
| 781 } | 783 } |
| 782 | 784 |
| 783 ManagePasswordsBubbleView::ManagePasswordsBubbleView( | 785 ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
| 784 content::WebContents* web_contents, | 786 content::WebContents* web_contents, |
| 785 ManagePasswordsIconViews* anchor_view, | 787 views::View* anchor_view, |
| 786 DisplayReason reason) | 788 DisplayReason reason) |
| 787 : LocationBarBubbleDelegateView(anchor_view, web_contents), | 789 : LocationBarBubbleDelegateView(anchor_view, web_contents), |
| 788 model_(web_contents, | 790 model_(web_contents, |
| 789 reason == AUTOMATIC ? ManagePasswordsBubbleModel::AUTOMATIC | 791 reason == AUTOMATIC ? ManagePasswordsBubbleModel::AUTOMATIC |
| 790 : ManagePasswordsBubbleModel::USER_ACTION), | 792 : ManagePasswordsBubbleModel::USER_ACTION), |
| 791 anchor_view_(anchor_view), | |
| 792 initially_focused_view_(nullptr) { | 793 initially_focused_view_(nullptr) { |
| 793 // Compensate for built-in vertical padding in the anchor view's image. | 794 // Compensate for built-in vertical padding in the anchor view's image. |
| 794 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); | 795 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
| 795 | 796 |
| 796 const int top_margin = ShouldShowCloseButton() ? margins().top() | 797 const int top_margin = ShouldShowCloseButton() ? margins().top() |
| 797 : views::kPanelVertMargin; | 798 : views::kPanelVertMargin; |
| 798 set_margins(gfx::Insets(top_margin, views::kPanelHorizMargin, | 799 set_margins(gfx::Insets(top_margin, views::kPanelHorizMargin, |
| 799 views::kPanelVertMargin, views::kPanelHorizMargin)); | 800 views::kPanelVertMargin, views::kPanelHorizMargin)); |
| 800 mouse_handler_.reset(new WebContentMouseHandler(this)); | 801 mouse_handler_.reset(new WebContentMouseHandler(this)); |
| 801 } | 802 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 AddChildView(new UpdatePendingView(this)); | 836 AddChildView(new UpdatePendingView(this)); |
| 836 } else if (model_.state() == password_manager::ui::CONFIRMATION_STATE) { | 837 } else if (model_.state() == password_manager::ui::CONFIRMATION_STATE) { |
| 837 AddChildView(new SaveConfirmationView(this)); | 838 AddChildView(new SaveConfirmationView(this)); |
| 838 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { | 839 } else if (model_.state() == password_manager::ui::AUTO_SIGNIN_STATE) { |
| 839 AddChildView(new AutoSigninView(this)); | 840 AddChildView(new AutoSigninView(this)); |
| 840 } else { | 841 } else { |
| 841 AddChildView(new ManageView(this)); | 842 AddChildView(new ManageView(this)); |
| 842 } | 843 } |
| 843 GetLayoutManager()->Layout(this); | 844 GetLayoutManager()->Layout(this); |
| 844 } | 845 } |
| OLD | NEW |