| 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_model.h" | 5 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 case password_manager::ui::PENDING_PASSWORD_UPDATE_STATE: | 261 case password_manager::ui::PENDING_PASSWORD_UPDATE_STATE: |
| 262 display_disposition = | 262 display_disposition = |
| 263 metrics_util::MANUAL_WITH_PASSWORD_PENDING_UPDATE; | 263 metrics_util::MANUAL_WITH_PASSWORD_PENDING_UPDATE; |
| 264 break; | 264 break; |
| 265 case password_manager::ui::MANAGE_STATE: | 265 case password_manager::ui::MANAGE_STATE: |
| 266 display_disposition = metrics_util::MANUAL_MANAGE_PASSWORDS; | 266 display_disposition = metrics_util::MANUAL_MANAGE_PASSWORDS; |
| 267 break; | 267 break; |
| 268 case password_manager::ui::CONFIRMATION_STATE: | 268 case password_manager::ui::CONFIRMATION_STATE: |
| 269 case password_manager::ui::CREDENTIAL_REQUEST_STATE: | 269 case password_manager::ui::CREDENTIAL_REQUEST_STATE: |
| 270 case password_manager::ui::AUTO_SIGNIN_STATE: | 270 case password_manager::ui::AUTO_SIGNIN_STATE: |
| 271 case password_manager::ui::CHROME_SIGN_IN_PROMO_STATE: |
| 271 case password_manager::ui::INACTIVE_STATE: | 272 case password_manager::ui::INACTIVE_STATE: |
| 272 NOTREACHED(); | 273 NOTREACHED(); |
| 273 break; | 274 break; |
| 274 } | 275 } |
| 275 } else { | 276 } else { |
| 276 switch (state_) { | 277 switch (state_) { |
| 277 case password_manager::ui::PENDING_PASSWORD_STATE: | 278 case password_manager::ui::PENDING_PASSWORD_STATE: |
| 278 display_disposition = metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING; | 279 display_disposition = metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING; |
| 279 break; | 280 break; |
| 280 case password_manager::ui::PENDING_PASSWORD_UPDATE_STATE: | 281 case password_manager::ui::PENDING_PASSWORD_UPDATE_STATE: |
| 281 display_disposition = | 282 display_disposition = |
| 282 metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING_UPDATE; | 283 metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING_UPDATE; |
| 283 break; | 284 break; |
| 284 case password_manager::ui::CONFIRMATION_STATE: | 285 case password_manager::ui::CONFIRMATION_STATE: |
| 285 display_disposition = | 286 display_disposition = |
| 286 metrics_util::AUTOMATIC_GENERATED_PASSWORD_CONFIRMATION; | 287 metrics_util::AUTOMATIC_GENERATED_PASSWORD_CONFIRMATION; |
| 287 break; | 288 break; |
| 288 case password_manager::ui::AUTO_SIGNIN_STATE: | 289 case password_manager::ui::AUTO_SIGNIN_STATE: |
| 289 display_disposition = metrics_util::AUTOMATIC_SIGNIN_TOAST; | 290 display_disposition = metrics_util::AUTOMATIC_SIGNIN_TOAST; |
| 290 break; | 291 break; |
| 291 case password_manager::ui::MANAGE_STATE: | 292 case password_manager::ui::MANAGE_STATE: |
| 292 case password_manager::ui::CREDENTIAL_REQUEST_STATE: | 293 case password_manager::ui::CREDENTIAL_REQUEST_STATE: |
| 294 case password_manager::ui::CHROME_SIGN_IN_PROMO_STATE: |
| 293 case password_manager::ui::INACTIVE_STATE: | 295 case password_manager::ui::INACTIVE_STATE: |
| 294 NOTREACHED(); | 296 NOTREACHED(); |
| 295 break; | 297 break; |
| 296 } | 298 } |
| 297 } | 299 } |
| 298 metrics_util::LogUIDisplayDisposition(display_disposition); | 300 metrics_util::LogUIDisplayDisposition(display_disposition); |
| 299 interaction_keeper_.reset(new InteractionKeeper(std::move(interaction_stats), | 301 interaction_keeper_.reset(new InteractionKeeper(std::move(interaction_stats), |
| 300 display_disposition)); | 302 display_disposition)); |
| 301 | 303 |
| 302 delegate->OnBubbleShown(); | 304 delegate->OnBubbleShown(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 password_manager::PasswordStore* password_store = | 388 password_manager::PasswordStore* password_store = |
| 387 PasswordStoreFactory::GetForProfile( | 389 PasswordStoreFactory::GetForProfile( |
| 388 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); | 390 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); |
| 389 DCHECK(password_store); | 391 DCHECK(password_store); |
| 390 if (action == REMOVE_PASSWORD) | 392 if (action == REMOVE_PASSWORD) |
| 391 password_store->RemoveLogin(password_form); | 393 password_store->RemoveLogin(password_form); |
| 392 else | 394 else |
| 393 password_store->AddLogin(password_form); | 395 password_store->AddLogin(password_form); |
| 394 } | 396 } |
| 395 | 397 |
| 398 void ManagePasswordsBubbleModel::OnSignInToChromeClicked() { |
| 399 |
| 400 } |
| 401 |
| 402 void ManagePasswordsBubbleModel::OnSkipSignInClicked() { |
| 403 |
| 404 } |
| 405 |
| 396 Profile* ManagePasswordsBubbleModel::GetProfile() const { | 406 Profile* ManagePasswordsBubbleModel::GetProfile() const { |
| 397 return GetProfileFromWebContents(web_contents()); | 407 return GetProfileFromWebContents(web_contents()); |
| 398 } | 408 } |
| 399 | 409 |
| 400 bool ManagePasswordsBubbleModel::ShouldShowMultipleAccountUpdateUI() const { | 410 bool ManagePasswordsBubbleModel::ShouldShowMultipleAccountUpdateUI() const { |
| 401 return state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE && | 411 return state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE && |
| 402 local_credentials_.size() > 1 && !password_overridden_; | 412 local_credentials_.size() > 1 && !password_overridden_; |
| 403 } | 413 } |
| 404 | 414 |
| 405 bool ManagePasswordsBubbleModel::ShouldShowGoogleSmartLockWelcome() const { | 415 bool ManagePasswordsBubbleModel::ShouldShowGoogleSmartLockWelcome() const { |
| 406 Profile* profile = GetProfile(); | 416 Profile* profile = GetProfile(); |
| 407 if (GetSmartLockBrandingState(profile) == | 417 if (GetSmartLockBrandingState(profile) == |
| 408 password_bubble_experiment::SmartLockBranding::FULL) { | 418 password_bubble_experiment::SmartLockBranding::FULL) { |
| 409 PrefService* prefs = profile->GetPrefs(); | 419 PrefService* prefs = profile->GetPrefs(); |
| 410 return !prefs->GetBoolean( | 420 return !prefs->GetBoolean( |
| 411 password_manager::prefs::kWasSavePrompFirstRunExperienceShown); | 421 password_manager::prefs::kWasSavePrompFirstRunExperienceShown); |
| 412 } | 422 } |
| 413 return false; | 423 return false; |
| 414 } | 424 } |
| 415 | 425 |
| 426 bool ManagePasswordsBubbleModel::ReplaceToShowSignInPromoIfNeeded() { |
| 427 DCHECK_EQ(password_manager::ui::PENDING_PASSWORD_STATE, state_); |
| 428 if (false /*TODO(crbug.com/615825): there will be a real condition soon*/) { |
| 429 title_brand_link_range_ = gfx::Range(); |
| 430 title_ = l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SIGNIN_PROMO_TITLE); |
| 431 state_ = password_manager::ui::CHROME_SIGN_IN_PROMO_STATE; |
| 432 return true; |
| 433 } |
| 434 return false; |
| 435 } |
| 436 |
| 416 void ManagePasswordsBubbleModel::SetClockForTesting( | 437 void ManagePasswordsBubbleModel::SetClockForTesting( |
| 417 std::unique_ptr<base::Clock> clock) { | 438 std::unique_ptr<base::Clock> clock) { |
| 418 interaction_keeper_->SetClockForTesting(std::move(clock)); | 439 interaction_keeper_->SetClockForTesting(std::move(clock)); |
| 419 } | 440 } |
| 420 | 441 |
| 421 void ManagePasswordsBubbleModel::UpdatePendingStateTitle() { | 442 void ManagePasswordsBubbleModel::UpdatePendingStateTitle() { |
| 422 title_brand_link_range_ = gfx::Range(); | 443 title_brand_link_range_ = gfx::Range(); |
| 423 PasswordTittleType type = | 444 PasswordTittleType type = |
| 424 state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE | 445 state_ == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE |
| 425 ? PasswordTittleType::UPDATE_PASSWORD | 446 ? PasswordTittleType::UPDATE_PASSWORD |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 return metrics_util::NO_UPDATE_SUBMISSION; | 482 return metrics_util::NO_UPDATE_SUBMISSION; |
| 462 } | 483 } |
| 463 if (state_ != password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) | 484 if (state_ != password_manager::ui::PENDING_PASSWORD_UPDATE_STATE) |
| 464 return metrics_util::NO_UPDATE_SUBMISSION; | 485 return metrics_util::NO_UPDATE_SUBMISSION; |
| 465 if (password_overridden_) | 486 if (password_overridden_) |
| 466 return update_events[3][behavior]; | 487 return update_events[3][behavior]; |
| 467 if (ShouldShowMultipleAccountUpdateUI()) | 488 if (ShouldShowMultipleAccountUpdateUI()) |
| 468 return update_events[2][behavior]; | 489 return update_events[2][behavior]; |
| 469 return update_events[1][behavior]; | 490 return update_events[1][behavior]; |
| 470 } | 491 } |
| OLD | NEW |