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 "base/strings/string16.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/password_manager/password_manager_util.h" | 13 #include "chrome/browser/password_manager/password_manager_util.h" |
13 #include "chrome/browser/password_manager/password_store_factory.h" | 14 #include "chrome/browser/password_manager/password_store_factory.h" |
14 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" | 15 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" |
15 #include "chrome/browser/password_manager/sync_metrics.h" | 16 #include "chrome/browser/password_manager/sync_metrics.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/sync/profile_sync_service.h" | 18 #include "chrome/browser/sync/profile_sync_service.h" |
18 #include "chrome/browser/sync/profile_sync_service_factory.h" | 19 #include "chrome/browser/sync/profile_sync_service_factory.h" |
19 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" | 20 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" |
20 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 21 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/chrome_version_info.h" | 23 #include "chrome/common/chrome_version_info.h" |
23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
24 #include "components/autofill/content/common/autofill_messages.h" | 25 #include "components/autofill/content/common/autofill_messages.h" |
25 #include "components/autofill/core/browser/password_generator.h" | 26 #include "components/autofill/core/browser/password_generator.h" |
26 #include "components/autofill/core/common/password_form.h" | 27 #include "components/autofill/core/common/password_form.h" |
27 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" | 28 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" |
| 29 #include "components/password_manager/content/common/credential_manager_messages
.h" |
| 30 #include "components/password_manager/content/common/credential_manager_types.h" |
28 #include "components/password_manager/core/browser/log_receiver.h" | 31 #include "components/password_manager/core/browser/log_receiver.h" |
29 #include "components/password_manager/core/browser/password_form_manager.h" | 32 #include "components/password_manager/core/browser/password_form_manager.h" |
30 #include "components/password_manager/core/browser/password_manager.h" | 33 #include "components/password_manager/core/browser/password_manager.h" |
31 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" | 34 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" |
32 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 35 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
33 #include "components/password_manager/core/common/password_manager_switches.h" | 36 #include "components/password_manager/core/common/password_manager_switches.h" |
34 #include "content/public/browser/navigation_entry.h" | 37 #include "content/public/browser/navigation_entry.h" |
35 #include "content/public/browser/render_view_host.h" | 38 #include "content/public/browser/render_view_host.h" |
36 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
37 #include "google_apis/gaia/gaia_urls.h" | 40 #include "google_apis/gaia/gaia_urls.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 if (service) | 278 if (service) |
276 service->ProcessLog(text); | 279 service->ProcessLog(text); |
277 } | 280 } |
278 | 281 |
279 bool ChromePasswordManagerClient::IsLoggingActive() const { | 282 bool ChromePasswordManagerClient::IsLoggingActive() const { |
280 // WebUI tabs do not need to log password saving progress. In particular, the | 283 // WebUI tabs do not need to log password saving progress. In particular, the |
281 // internals page itself should not send any logs. | 284 // internals page itself should not send any logs. |
282 return can_use_log_router_ && !web_contents()->GetWebUI(); | 285 return can_use_log_router_ && !web_contents()->GetWebUI(); |
283 } | 286 } |
284 | 287 |
| 288 void ChromePasswordManagerClient::OnNotifyFailedSignIn( |
| 289 int request_id, |
| 290 const password_manager::CredentialInfo&) { |
| 291 // TODO(mkwst): This is a stub. |
| 292 web_contents()->GetRenderViewHost()->Send( |
| 293 new CredentialManagerMsg_AcknowledgeFailedSignIn( |
| 294 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); |
| 295 } |
| 296 |
| 297 void ChromePasswordManagerClient::OnNotifySignedIn( |
| 298 int request_id, |
| 299 const password_manager::CredentialInfo&) { |
| 300 // TODO(mkwst): This is a stub. |
| 301 web_contents()->GetRenderViewHost()->Send( |
| 302 new CredentialManagerMsg_AcknowledgeSignedIn( |
| 303 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); |
| 304 } |
| 305 |
| 306 void ChromePasswordManagerClient::OnNotifySignedOut(int request_id) { |
| 307 // TODO(mkwst): This is a stub. |
| 308 web_contents()->GetRenderViewHost()->Send( |
| 309 new CredentialManagerMsg_AcknowledgeSignedOut( |
| 310 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); |
| 311 } |
| 312 |
| 313 void ChromePasswordManagerClient::OnRequestCredential( |
| 314 int request_id, |
| 315 bool zero_click_only, |
| 316 const std::vector<GURL>& federations) { |
| 317 // TODO(mkwst): This is a stub. |
| 318 password_manager::CredentialInfo info(base::ASCIIToUTF16("id"), |
| 319 base::ASCIIToUTF16("name"), |
| 320 GURL("https://example.com/image.png")); |
| 321 web_contents()->GetRenderViewHost()->Send( |
| 322 new CredentialManagerMsg_SendCredential( |
| 323 web_contents()->GetRenderViewHost()->GetRoutingID(), |
| 324 request_id, |
| 325 info)); |
| 326 } |
| 327 |
285 // static | 328 // static |
286 password_manager::PasswordGenerationManager* | 329 password_manager::PasswordGenerationManager* |
287 ChromePasswordManagerClient::GetGenerationManagerFromWebContents( | 330 ChromePasswordManagerClient::GetGenerationManagerFromWebContents( |
288 content::WebContents* contents) { | 331 content::WebContents* contents) { |
289 ChromePasswordManagerClient* client = | 332 ChromePasswordManagerClient* client = |
290 ChromePasswordManagerClient::FromWebContents(contents); | 333 ChromePasswordManagerClient::FromWebContents(contents); |
291 if (!client) | 334 if (!client) |
292 return NULL; | 335 return NULL; |
293 return client->GetDriver()->GetPasswordGenerationManager(); | 336 return client->GetDriver()->GetPasswordGenerationManager(); |
294 } | 337 } |
(...skipping 11 matching lines...) Expand all Loading... |
306 | 349 |
307 void ChromePasswordManagerClient::SetTestObserver( | 350 void ChromePasswordManagerClient::SetTestObserver( |
308 autofill::PasswordGenerationPopupObserver* observer) { | 351 autofill::PasswordGenerationPopupObserver* observer) { |
309 observer_ = observer; | 352 observer_ = observer; |
310 } | 353 } |
311 | 354 |
312 bool ChromePasswordManagerClient::OnMessageReceived( | 355 bool ChromePasswordManagerClient::OnMessageReceived( |
313 const IPC::Message& message) { | 356 const IPC::Message& message) { |
314 bool handled = true; | 357 bool handled = true; |
315 IPC_BEGIN_MESSAGE_MAP(ChromePasswordManagerClient, message) | 358 IPC_BEGIN_MESSAGE_MAP(ChromePasswordManagerClient, message) |
| 359 // Autofill messages: |
316 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordGenerationPopup, | 360 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordGenerationPopup, |
317 ShowPasswordGenerationPopup) | 361 ShowPasswordGenerationPopup) |
318 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordEditingPopup, | 362 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordEditingPopup, |
319 ShowPasswordEditingPopup) | 363 ShowPasswordEditingPopup) |
320 IPC_MESSAGE_HANDLER(AutofillHostMsg_HidePasswordGenerationPopup, | 364 IPC_MESSAGE_HANDLER(AutofillHostMsg_HidePasswordGenerationPopup, |
321 HidePasswordGenerationPopup) | 365 HidePasswordGenerationPopup) |
322 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordAutofillAgentConstructed, | 366 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordAutofillAgentConstructed, |
323 NotifyRendererOfLoggingAvailability) | 367 NotifyRendererOfLoggingAvailability) |
| 368 |
| 369 // Credential Manager messages: |
| 370 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_NotifyFailedSignIn, |
| 371 OnNotifyFailedSignIn); |
| 372 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_NotifySignedIn, |
| 373 OnNotifySignedIn); |
| 374 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_NotifySignedOut, |
| 375 OnNotifySignedOut); |
| 376 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_RequestCredential, |
| 377 OnRequestCredential); |
| 378 |
| 379 // Default: |
324 IPC_MESSAGE_UNHANDLED(handled = false) | 380 IPC_MESSAGE_UNHANDLED(handled = false) |
325 IPC_END_MESSAGE_MAP() | 381 IPC_END_MESSAGE_MAP() |
326 return handled; | 382 return handled; |
327 } | 383 } |
328 | 384 |
329 gfx::RectF ChromePasswordManagerClient::GetBoundsInScreenSpace( | 385 gfx::RectF ChromePasswordManagerClient::GetBoundsInScreenSpace( |
330 const gfx::RectF& bounds) { | 386 const gfx::RectF& bounds) { |
331 gfx::Rect client_area = web_contents()->GetContainerBounds(); | 387 gfx::Rect client_area = web_contents()->GetContainerBounds(); |
332 return bounds + client_area.OffsetFromOrigin(); | 388 return bounds + client_area.OffsetFromOrigin(); |
333 } | 389 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 539 |
484 if (group_name == "DisallowSyncCredentialsForReauth") { | 540 if (group_name == "DisallowSyncCredentialsForReauth") { |
485 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | 541 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
486 } else if (group_name == "DisallowSyncCredentials") { | 542 } else if (group_name == "DisallowSyncCredentials") { |
487 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; | 543 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; |
488 } else { | 544 } else { |
489 // Allow by default. | 545 // Allow by default. |
490 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; | 546 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; |
491 } | 547 } |
492 } | 548 } |
OLD | NEW |