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" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 153 } |
154 ManagePasswordsUIController* controller = | 154 ManagePasswordsUIController* controller = |
155 ManagePasswordsUIController::FromWebContents(web_contents); | 155 ManagePasswordsUIController::FromWebContents(web_contents); |
156 ManagePasswordsBubbleView::ShowBubble( | 156 ManagePasswordsBubbleView::ShowBubble( |
157 web_contents, | 157 web_contents, |
158 password_manager::ui::IsAutomaticDisplayState(controller->state()) | 158 password_manager::ui::IsAutomaticDisplayState(controller->state()) |
159 ? ManagePasswordsBubbleView::AUTOMATIC | 159 ? ManagePasswordsBubbleView::AUTOMATIC |
160 : ManagePasswordsBubbleView::USER_ACTION); | 160 : ManagePasswordsBubbleView::USER_ACTION); |
161 } | 161 } |
162 | 162 |
| 163 void CloseManagePasswordsBubble(content::WebContents* web_contents) { |
| 164 if (!ManagePasswordsBubbleView::IsShowing()) |
| 165 return; |
| 166 content::WebContents* bubble_web_contents = |
| 167 ManagePasswordsBubbleView::manage_password_bubble()->web_contents(); |
| 168 if (web_contents == bubble_web_contents) |
| 169 ManagePasswordsBubbleView::CloseBubble(); |
| 170 } |
| 171 |
163 } // namespace chrome | 172 } // namespace chrome |
164 | 173 |
165 | 174 |
166 // ManagePasswordsBubbleView::PendingView ------------------------------------- | 175 // ManagePasswordsBubbleView::PendingView ------------------------------------- |
167 | 176 |
168 // A view offering the user the ability to save credentials. Contains a | 177 // A view offering the user the ability to save credentials. Contains a |
169 // single ManagePasswordItemView, along with a "Save Passwords" button | 178 // single ManagePasswordItemView, along with a "Save Passwords" button |
170 // and a rejection combobox. | 179 // and a rejection combobox. |
171 class ManagePasswordsBubbleView::PendingView : public views::View, | 180 class ManagePasswordsBubbleView::PendingView : public views::View, |
172 public views::ButtonListener, | 181 public views::ButtonListener, |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 manage_passwords_bubble_->GetWidget()->Activate(); | 773 manage_passwords_bubble_->GetWidget()->Activate(); |
765 } | 774 } |
766 | 775 |
767 // static | 776 // static |
768 bool ManagePasswordsBubbleView::IsShowing() { | 777 bool ManagePasswordsBubbleView::IsShowing() { |
769 // The bubble may be in the process of closing. | 778 // The bubble may be in the process of closing. |
770 return (manage_passwords_bubble_ != NULL) && | 779 return (manage_passwords_bubble_ != NULL) && |
771 manage_passwords_bubble_->GetWidget()->IsVisible(); | 780 manage_passwords_bubble_->GetWidget()->IsVisible(); |
772 } | 781 } |
773 | 782 |
| 783 content::WebContents* ManagePasswordsBubbleView::web_contents() const { |
| 784 return model()->web_contents(); |
| 785 } |
| 786 |
774 ManagePasswordsBubbleView::ManagePasswordsBubbleView( | 787 ManagePasswordsBubbleView::ManagePasswordsBubbleView( |
775 content::WebContents* web_contents, | 788 content::WebContents* web_contents, |
776 ManagePasswordsIconView* anchor_view, | 789 ManagePasswordsIconView* anchor_view, |
777 DisplayReason reason) | 790 DisplayReason reason) |
778 : ManagePasswordsBubble(web_contents, reason), | 791 : ManagePasswordsBubble(web_contents, reason), |
779 BubbleDelegateView(anchor_view, | 792 BubbleDelegateView(anchor_view, |
780 anchor_view ? views::BubbleBorder::TOP_RIGHT | 793 anchor_view ? views::BubbleBorder::TOP_RIGHT |
781 : views::BubbleBorder::NONE), | 794 : views::BubbleBorder::NONE), |
782 anchor_view_(anchor_view), | 795 anchor_view_(anchor_view), |
783 never_save_passwords_(false), | 796 never_save_passwords_(false), |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 if (!fadeout_observer_) | 912 if (!fadeout_observer_) |
900 return; | 913 return; |
901 fadeout_observer_.reset(); | 914 fadeout_observer_.reset(); |
902 aura::Window* window = GetWidget()->GetNativeView(); | 915 aura::Window* window = GetWidget()->GetNativeView(); |
903 window->layer()->SetOpacity(1); | 916 window->layer()->SetOpacity(1); |
904 } | 917 } |
905 | 918 |
906 void ManagePasswordsBubbleView::OnBubbleDisappeared() { | 919 void ManagePasswordsBubbleView::OnBubbleDisappeared() { |
907 Close(); | 920 Close(); |
908 } | 921 } |
OLD | NEW |