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/passwords/manage_passwords_bubble_ui_controller.h" | 5 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" |
6 | 6 |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
9 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 12 #include "chrome/browser/ui/chrome_pages.h" |
10 #include "chrome/browser/ui/omnibox/location_bar.h" | 13 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 14 #include "chrome/common/url_constants.h" |
11 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
12 | 16 |
13 using autofill::PasswordFormMap; | 17 using autofill::PasswordFormMap; |
14 | 18 |
15 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagePasswordsBubbleUIController); | 19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagePasswordsBubbleUIController); |
16 | 20 |
17 ManagePasswordsBubbleUIController::ManagePasswordsBubbleUIController( | 21 ManagePasswordsBubbleUIController::ManagePasswordsBubbleUIController( |
18 content::WebContents* web_contents) | 22 content::WebContents* web_contents) |
19 : content::WebContentsObserver(web_contents), | 23 : content::WebContentsObserver(web_contents), |
20 manage_passwords_icon_to_be_shown_(false), | 24 manage_passwords_icon_to_be_shown_(false), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 74 |
71 void ManagePasswordsBubbleUIController::RemoveFromBestMatches( | 75 void ManagePasswordsBubbleUIController::RemoveFromBestMatches( |
72 autofill::PasswordForm password_form) { | 76 autofill::PasswordForm password_form) { |
73 password_form_map_.erase(password_form.username_value); | 77 password_form_map_.erase(password_form.username_value); |
74 } | 78 } |
75 | 79 |
76 void ManagePasswordsBubbleUIController::OnBubbleShown() { | 80 void ManagePasswordsBubbleUIController::OnBubbleShown() { |
77 unset_manage_passwords_bubble_needs_showing(); | 81 unset_manage_passwords_bubble_needs_showing(); |
78 } | 82 } |
79 | 83 |
| 84 Profile* ManagePasswordsBubbleUIController::profile() const { |
| 85 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 86 } |
| 87 |
80 void ManagePasswordsBubbleUIController::SavePassword() { | 88 void ManagePasswordsBubbleUIController::SavePassword() { |
81 DCHECK(form_manager_.get()); | 89 DCHECK(form_manager_.get()); |
82 form_manager_->Save(); | 90 form_manager_->Save(); |
83 } | 91 } |
84 | 92 |
85 void ManagePasswordsBubbleUIController::NeverSavePassword() { | 93 void ManagePasswordsBubbleUIController::NeverSavePassword() { |
86 DCHECK(form_manager_.get()); | 94 DCHECK(form_manager_.get()); |
87 form_manager_->PermanentlyBlacklist(); | 95 form_manager_->PermanentlyBlacklist(); |
88 } | 96 } |
89 | 97 |
90 void ManagePasswordsBubbleUIController::DidNavigateMainFrame( | 98 void ManagePasswordsBubbleUIController::DidNavigateMainFrame( |
91 const content::LoadCommittedDetails& details, | 99 const content::LoadCommittedDetails& details, |
92 const content::FrameNavigateParams& params) { | 100 const content::FrameNavigateParams& params) { |
93 if (details.is_in_page) | 101 if (details.is_in_page) |
94 return; | 102 return; |
95 // Reset password states for next page. | 103 // Reset password states for next page. |
96 manage_passwords_icon_to_be_shown_ = false; | 104 manage_passwords_icon_to_be_shown_ = false; |
97 password_to_be_saved_ = false; | 105 password_to_be_saved_ = false; |
98 manage_passwords_bubble_needs_showing_ = false; | 106 manage_passwords_bubble_needs_showing_ = false; |
99 password_submitted_ = false; | 107 password_submitted_ = false; |
100 UpdateBubbleAndIconVisibility(); | 108 UpdateBubbleAndIconVisibility(); |
101 } | 109 } |
| 110 |
| 111 void ManagePasswordsBubbleUIController::NavigateToPasswordManagerSettingsPage() |
| 112 const { |
| 113 chrome::ShowSettingsSubPage( |
| 114 chrome::FindBrowserWithWebContents(web_contents()), |
| 115 chrome::kPasswordManagerSubPage); |
| 116 } |
OLD | NEW |