OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/password_manager/chrome_password_manager_client.h" | 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "chrome/browser/password_manager/password_manager_util.h" | 11 #include "chrome/browser/password_manager/password_manager_util.h" |
12 #include "chrome/browser/password_manager/password_store_factory.h" | 12 #include "chrome/browser/password_manager/password_store_factory.h" |
13 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" | 13 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/sync/profile_sync_service.h" | 15 #include "chrome/browser/sync/profile_sync_service.h" |
16 #include "chrome/browser/sync/profile_sync_service_factory.h" | 16 #include "chrome/browser/sync/profile_sync_service_factory.h" |
17 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" | 17 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" |
18 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" | 18 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/chrome_version_info.h" | 20 #include "chrome/common/chrome_version_info.h" |
21 #include "components/autofill/content/common/autofill_messages.h" | 21 #include "components/autofill/content/common/autofill_messages.h" |
22 #include "components/autofill/core/browser/password_generator.h" | 22 #include "components/autofill/core/browser/password_generator.h" |
23 #include "components/autofill/core/common/password_form.h" | 23 #include "components/autofill/core/common/password_form.h" |
24 #include "components/password_manager/core/browser/password_form_manager.h" | 24 #include "components/password_manager/core/browser/password_form_manager.h" |
25 #include "components/password_manager/core/browser/password_manager.h" | 25 #include "components/password_manager/core/browser/password_manager.h" |
26 #include "components/password_manager/core/browser/password_manager_logger.h" | 26 #include "components/password_manager/core/browser/password_manager_logger.h" |
27 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 27 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
| 28 #include "components/password_manager/core/common/password_manager_switches.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
29 #include "content/public/browser/web_contents_view.h" | 30 #include "content/public/browser/web_contents_view.h" |
30 #include "ipc/ipc_message_macros.h" | 31 #include "ipc/ipc_message_macros.h" |
31 | 32 |
32 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
33 #include "chrome/browser/android/password_authentication_manager.h" | 34 #include "chrome/browser/android/password_authentication_manager.h" |
34 #endif // OS_ANDROID | 35 #endif // OS_ANDROID |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
(...skipping 18 matching lines...) Expand all Loading... |
56 ChromePasswordManagerClient::ChromePasswordManagerClient( | 57 ChromePasswordManagerClient::ChromePasswordManagerClient( |
57 content::WebContents* web_contents) | 58 content::WebContents* web_contents) |
58 : content::WebContentsObserver(web_contents), | 59 : content::WebContentsObserver(web_contents), |
59 driver_(web_contents, this), | 60 driver_(web_contents, this), |
60 observer_(NULL), | 61 observer_(NULL), |
61 weak_factory_(this), | 62 weak_factory_(this), |
62 logger_(NULL) {} | 63 logger_(NULL) {} |
63 | 64 |
64 ChromePasswordManagerClient::~ChromePasswordManagerClient() {} | 65 ChromePasswordManagerClient::~ChromePasswordManagerClient() {} |
65 | 66 |
| 67 bool ChromePasswordManagerClient::IsAutomaticPasswordSavingEnabled() const { |
| 68 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 69 password_manager::switches::kEnableAutomaticPasswordSaving); |
| 70 } |
| 71 |
66 void ChromePasswordManagerClient::PromptUserToSavePassword( | 72 void ChromePasswordManagerClient::PromptUserToSavePassword( |
67 password_manager::PasswordFormManager* form_to_save) { | 73 password_manager::PasswordFormManager* form_to_save) { |
68 if (IsTheHotNewBubbleUIEnabled()) { | 74 if (IsTheHotNewBubbleUIEnabled()) { |
69 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = | 75 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = |
70 ManagePasswordsBubbleUIController::FromWebContents(web_contents()); | 76 ManagePasswordsBubbleUIController::FromWebContents(web_contents()); |
71 if (manage_passwords_bubble_ui_controller) { | 77 if (manage_passwords_bubble_ui_controller) { |
72 manage_passwords_bubble_ui_controller->OnPasswordSubmitted(form_to_save); | 78 manage_passwords_bubble_ui_controller->OnPasswordSubmitted(form_to_save); |
73 } else { | 79 } else { |
74 delete form_to_save; | 80 delete form_to_save; |
75 } | 81 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 web_contents(), | 290 web_contents(), |
285 web_contents()->GetView()->GetNativeView()); | 291 web_contents()->GetView()->GetNativeView()); |
286 popup_controller_->Show(false /* display_password */); | 292 popup_controller_->Show(false /* display_password */); |
287 #endif // #if defined(USE_AURA) | 293 #endif // #if defined(USE_AURA) |
288 } | 294 } |
289 | 295 |
290 void ChromePasswordManagerClient::CommitFillPasswordForm( | 296 void ChromePasswordManagerClient::CommitFillPasswordForm( |
291 autofill::PasswordFormFillData* data) { | 297 autofill::PasswordFormFillData* data) { |
292 driver_.FillPasswordForm(*data); | 298 driver_.FillPasswordForm(*data); |
293 } | 299 } |
OLD | NEW |