Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/browser/password_manager/chrome_password_manager_client.cc

Issue 900223005: [Clean up] Clean up some methods in PasswordManagerClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { 251 void ChromePasswordManagerClient::HidePasswordGenerationPopup() {
252 if (popup_controller_) 252 if (popup_controller_)
253 popup_controller_->HideAndDestroy(); 253 popup_controller_->HideAndDestroy();
254 } 254 }
255 255
256 PrefService* ChromePasswordManagerClient::GetPrefs() { 256 PrefService* ChromePasswordManagerClient::GetPrefs() {
257 return profile_->GetPrefs(); 257 return profile_->GetPrefs();
258 } 258 }
259 259
260 password_manager::PasswordStore* 260 password_manager::PasswordStore*
261 ChromePasswordManagerClient::GetPasswordStore() { 261 ChromePasswordManagerClient::GetPasswordStore() const {
262 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord 262 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord
263 // itself when it shouldn't access the PasswordStore. 263 // itself when it shouldn't access the PasswordStore.
264 // TODO(gcasto): Is is safe to change this to 264 // TODO(gcasto): Is is safe to change this to
265 // ServiceAccessType::IMPLICIT_ACCESS? 265 // ServiceAccessType::IMPLICIT_ACCESS?
266 return PasswordStoreFactory::GetForProfile( 266 return PasswordStoreFactory::GetForProfile(
267 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); 267 profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
268 } 268 }
269 269
270 base::FieldTrial::Probability 270 base::FieldTrial::Probability
271 ChromePasswordManagerClient::GetProbabilityForExperiment( 271 ChromePasswordManagerClient::GetProbabilityForExperiment(
272 const std::string& experiment_name) { 272 const std::string& experiment_name) const {
273 base::FieldTrial::Probability enabled_probability = 0; 273 base::FieldTrial::Probability enabled_probability = 0;
274 if (experiment_name == 274 if (experiment_name ==
275 password_manager::PasswordManager::kOtherPossibleUsernamesExperiment) { 275 password_manager::PasswordManager::kOtherPossibleUsernamesExperiment) {
276 switch (chrome::VersionInfo::GetChannel()) { 276 switch (chrome::VersionInfo::GetChannel()) {
277 case chrome::VersionInfo::CHANNEL_DEV: 277 case chrome::VersionInfo::CHANNEL_DEV:
278 case chrome::VersionInfo::CHANNEL_BETA: 278 case chrome::VersionInfo::CHANNEL_BETA:
279 enabled_probability = 50; 279 enabled_probability = 50;
280 break; 280 break;
281 default: 281 default:
282 break; 282 break;
283 } 283 }
284 } 284 }
285 return enabled_probability; 285 return enabled_probability;
286 } 286 }
287 287
288 bool ChromePasswordManagerClient::IsPasswordSyncEnabled( 288 bool ChromePasswordManagerClient::IsPasswordSyncEnabled(
289 password_manager::CustomPassphraseState state) { 289 password_manager::CustomPassphraseState state) const {
290 ProfileSyncService* sync_service = 290 ProfileSyncService* sync_service =
291 ProfileSyncServiceFactory::GetForProfile(profile_); 291 ProfileSyncServiceFactory::GetForProfile(profile_);
292 if (sync_service && sync_service->HasSyncSetupCompleted() && 292 if (sync_service && sync_service->HasSyncSetupCompleted() &&
293 sync_service->SyncActive() && 293 sync_service->SyncActive() &&
294 sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) { 294 sync_service->GetActiveDataTypes().Has(syncer::PASSWORDS)) {
295 if (sync_service->IsUsingSecondaryPassphrase()) { 295 if (sync_service->IsUsingSecondaryPassphrase()) {
296 return state == password_manager::ONLY_CUSTOM_PASSPHRASE; 296 return state == password_manager::ONLY_CUSTOM_PASSPHRASE;
297 } else { 297 } else {
298 return state == password_manager::WITHOUT_CUSTOM_PASSPHRASE; 298 return state == password_manager::WITHOUT_CUSTOM_PASSPHRASE;
299 } 299 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 int http_status_code = entry->GetHttpStatusCode(); 343 int http_status_code = entry->GetHttpStatusCode();
344 344
345 if (logger) 345 if (logger)
346 logger->LogNumber(Logger::STRING_HTTP_STATUS_CODE, http_status_code); 346 logger->LogNumber(Logger::STRING_HTTP_STATUS_CODE, http_status_code);
347 347
348 if (http_status_code >= 400 && http_status_code < 600) 348 if (http_status_code >= 400 && http_status_code < 600)
349 return true; 349 return true;
350 return false; 350 return false;
351 } 351 }
352 352
353 bool ChromePasswordManagerClient::DidLastPageLoadEncounterSSLErrors() { 353 bool ChromePasswordManagerClient::DidLastPageLoadEncounterSSLErrors() const {
354 content::NavigationEntry* entry = 354 content::NavigationEntry* entry =
355 web_contents()->GetController().GetLastCommittedEntry(); 355 web_contents()->GetController().GetLastCommittedEntry();
356 if (!entry) 356 if (!entry)
357 return false; 357 return false;
358 358
359 return net::IsCertStatusError(entry->GetSSL().cert_status); 359 return net::IsCertStatusError(entry->GetSSL().cert_status);
360 } 360 }
361 361
362 bool ChromePasswordManagerClient::IsOffTheRecord() { 362 bool ChromePasswordManagerClient::IsOffTheRecord() const {
363 return web_contents()->GetBrowserContext()->IsOffTheRecord(); 363 return web_contents()->GetBrowserContext()->IsOffTheRecord();
364 } 364 }
365 365
366 password_manager::PasswordManager* 366 password_manager::PasswordManager*
367 ChromePasswordManagerClient::GetPasswordManager() { 367 ChromePasswordManagerClient::GetPasswordManager() {
368 return &password_manager_; 368 return &password_manager_;
369 } 369 }
370 370
371 autofill::AutofillManager* 371 autofill::AutofillManager*
372 ChromePasswordManagerClient::GetAutofillManagerForMainFrame() { 372 ChromePasswordManagerClient::GetAutofillManagerForMainFrame() {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 if (group_name == "DisallowSyncCredentialsForReauth") { 556 if (group_name == "DisallowSyncCredentialsForReauth") {
557 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; 557 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH;
558 } else if (group_name == "DisallowSyncCredentials") { 558 } else if (group_name == "DisallowSyncCredentials") {
559 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; 559 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS;
560 } else { 560 } else {
561 // Allow by default. 561 // Allow by default.
562 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; 562 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS;
563 } 563 }
564 } 564 }
565 565
566 const GURL& ChromePasswordManagerClient::GetMainFrameURL() { 566 const GURL& ChromePasswordManagerClient::GetMainFrameURL() const {
567 return web_contents()->GetVisibleURL(); 567 return web_contents()->GetVisibleURL();
568 } 568 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698