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" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 UserDataKey(), | 62 UserDataKey(), |
63 new ChromePasswordManagerClient(contents, autofill_client)); | 63 new ChromePasswordManagerClient(contents, autofill_client)); |
64 } | 64 } |
65 | 65 |
66 ChromePasswordManagerClient::ChromePasswordManagerClient( | 66 ChromePasswordManagerClient::ChromePasswordManagerClient( |
67 content::WebContents* web_contents, | 67 content::WebContents* web_contents, |
68 autofill::AutofillClient* autofill_client) | 68 autofill::AutofillClient* autofill_client) |
69 : content::WebContentsObserver(web_contents), | 69 : content::WebContentsObserver(web_contents), |
70 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), | 70 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), |
71 driver_(web_contents, this, autofill_client), | 71 driver_(web_contents, this, autofill_client), |
| 72 credential_manager_dispatcher_(web_contents, this), |
72 observer_(NULL), | 73 observer_(NULL), |
73 can_use_log_router_(false), | 74 can_use_log_router_(false), |
74 autofill_sync_state_(ALLOW_SYNC_CREDENTIALS), | 75 autofill_sync_state_(ALLOW_SYNC_CREDENTIALS), |
75 sync_credential_was_filtered_(false), | 76 sync_credential_was_filtered_(false), |
76 weak_factory_(this) { | 77 weak_factory_(this) { |
77 PasswordManagerInternalsService* service = | 78 PasswordManagerInternalsService* service = |
78 PasswordManagerInternalsServiceFactory::GetForBrowserContext(profile_); | 79 PasswordManagerInternalsServiceFactory::GetForBrowserContext(profile_); |
79 if (service) | 80 if (service) |
80 can_use_log_router_ = service->RegisterClient(this); | 81 can_use_log_router_ = service->RegisterClient(this); |
81 SetUpAutofillSyncState(); | 82 SetUpAutofillSyncState(); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 if (service) | 289 if (service) |
289 service->ProcessLog(text); | 290 service->ProcessLog(text); |
290 } | 291 } |
291 | 292 |
292 bool ChromePasswordManagerClient::IsLoggingActive() const { | 293 bool ChromePasswordManagerClient::IsLoggingActive() const { |
293 // WebUI tabs do not need to log password saving progress. In particular, the | 294 // WebUI tabs do not need to log password saving progress. In particular, the |
294 // internals page itself should not send any logs. | 295 // internals page itself should not send any logs. |
295 return can_use_log_router_ && !web_contents()->GetWebUI(); | 296 return can_use_log_router_ && !web_contents()->GetWebUI(); |
296 } | 297 } |
297 | 298 |
298 void ChromePasswordManagerClient::OnNotifyFailedSignIn( | |
299 int request_id, | |
300 const password_manager::CredentialInfo&) { | |
301 // TODO(mkwst): This is a stub. | |
302 web_contents()->GetRenderViewHost()->Send( | |
303 new CredentialManagerMsg_AcknowledgeFailedSignIn( | |
304 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); | |
305 } | |
306 | |
307 void ChromePasswordManagerClient::OnNotifySignedIn( | |
308 int request_id, | |
309 const password_manager::CredentialInfo&) { | |
310 // TODO(mkwst): This is a stub. | |
311 web_contents()->GetRenderViewHost()->Send( | |
312 new CredentialManagerMsg_AcknowledgeSignedIn( | |
313 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); | |
314 } | |
315 | |
316 void ChromePasswordManagerClient::OnNotifySignedOut(int request_id) { | |
317 // TODO(mkwst): This is a stub. | |
318 web_contents()->GetRenderViewHost()->Send( | |
319 new CredentialManagerMsg_AcknowledgeSignedOut( | |
320 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); | |
321 } | |
322 | |
323 void ChromePasswordManagerClient::OnRequestCredential( | |
324 int request_id, | |
325 bool zero_click_only, | |
326 const std::vector<GURL>& federations) { | |
327 // TODO(mkwst): This is a stub. | |
328 password_manager::CredentialInfo info(base::ASCIIToUTF16("id"), | |
329 base::ASCIIToUTF16("name"), | |
330 GURL("https://example.com/image.png")); | |
331 web_contents()->GetRenderViewHost()->Send( | |
332 new CredentialManagerMsg_SendCredential( | |
333 web_contents()->GetRenderViewHost()->GetRoutingID(), | |
334 request_id, | |
335 info)); | |
336 } | |
337 | |
338 // static | 299 // static |
339 password_manager::PasswordGenerationManager* | 300 password_manager::PasswordGenerationManager* |
340 ChromePasswordManagerClient::GetGenerationManagerFromWebContents( | 301 ChromePasswordManagerClient::GetGenerationManagerFromWebContents( |
341 content::WebContents* contents) { | 302 content::WebContents* contents) { |
342 ChromePasswordManagerClient* client = | 303 ChromePasswordManagerClient* client = |
343 ChromePasswordManagerClient::FromWebContents(contents); | 304 ChromePasswordManagerClient::FromWebContents(contents); |
344 if (!client) | 305 if (!client) |
345 return NULL; | 306 return NULL; |
346 return client->GetDriver()->GetPasswordGenerationManager(); | 307 return client->GetDriver()->GetPasswordGenerationManager(); |
347 } | 308 } |
(...skipping 21 matching lines...) Expand all Loading... |
369 // Autofill messages: | 330 // Autofill messages: |
370 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordGenerationPopup, | 331 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordGenerationPopup, |
371 ShowPasswordGenerationPopup) | 332 ShowPasswordGenerationPopup) |
372 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordEditingPopup, | 333 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordEditingPopup, |
373 ShowPasswordEditingPopup) | 334 ShowPasswordEditingPopup) |
374 IPC_MESSAGE_HANDLER(AutofillHostMsg_HidePasswordGenerationPopup, | 335 IPC_MESSAGE_HANDLER(AutofillHostMsg_HidePasswordGenerationPopup, |
375 HidePasswordGenerationPopup) | 336 HidePasswordGenerationPopup) |
376 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordAutofillAgentConstructed, | 337 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordAutofillAgentConstructed, |
377 NotifyRendererOfLoggingAvailability) | 338 NotifyRendererOfLoggingAvailability) |
378 | 339 |
379 // Credential Manager messages: | |
380 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_NotifyFailedSignIn, | |
381 OnNotifyFailedSignIn); | |
382 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_NotifySignedIn, | |
383 OnNotifySignedIn); | |
384 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_NotifySignedOut, | |
385 OnNotifySignedOut); | |
386 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_RequestCredential, | |
387 OnRequestCredential); | |
388 | |
389 // Default: | 340 // Default: |
390 IPC_MESSAGE_UNHANDLED(handled = false) | 341 IPC_MESSAGE_UNHANDLED(handled = false) |
391 IPC_END_MESSAGE_MAP() | 342 IPC_END_MESSAGE_MAP() |
392 return handled; | 343 return handled; |
393 } | 344 } |
394 | 345 |
395 gfx::RectF ChromePasswordManagerClient::GetBoundsInScreenSpace( | 346 gfx::RectF ChromePasswordManagerClient::GetBoundsInScreenSpace( |
396 const gfx::RectF& bounds) { | 347 const gfx::RectF& bounds) { |
397 gfx::Rect client_area = web_contents()->GetContainerBounds(); | 348 gfx::Rect client_area = web_contents()->GetContainerBounds(); |
398 return bounds + client_area.OffsetFromOrigin(); | 349 return bounds + client_area.OffsetFromOrigin(); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 506 |
556 if (group_name == "DisallowSyncCredentialsForReauth") { | 507 if (group_name == "DisallowSyncCredentialsForReauth") { |
557 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | 508 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
558 } else if (group_name == "DisallowSyncCredentials") { | 509 } else if (group_name == "DisallowSyncCredentials") { |
559 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; | 510 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; |
560 } else { | 511 } else { |
561 // Allow by default. | 512 // Allow by default. |
562 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; | 513 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; |
563 } | 514 } |
564 } | 515 } |
OLD | NEW |