| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_install_prompt.h" | 5 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/extensions/bundle_installer.h" | 16 #include "chrome/browser/extensions/bundle_installer.h" |
| 17 #include "chrome/browser/extensions/extension_install_ui.h" | 17 #include "chrome/browser/extensions/extension_install_ui.h" |
| 18 #include "chrome/browser/extensions/extension_util.h" | 18 #include "chrome/browser/extensions/extension_util.h" |
| 19 #include "chrome/browser/extensions/image_loader.h" | 19 #include "chrome/browser/extensions/image_loader.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | |
| 22 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" | |
| 26 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 27 #include "components/signin/core/browser/profile_oauth2_token_service.h" | |
| 28 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 29 #include "extensions/browser/extension_prefs.h" | 26 #include "extensions/browser/extension_prefs.h" |
| 30 #include "extensions/browser/extension_util.h" | 27 #include "extensions/browser/extension_util.h" |
| 31 #include "extensions/common/constants.h" | 28 #include "extensions/common/constants.h" |
| 32 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
| 33 #include "extensions/common/extension_icon_set.h" | 30 #include "extensions/common/extension_icon_set.h" |
| 34 #include "extensions/common/extension_resource.h" | 31 #include "extensions/common/extension_resource.h" |
| 35 #include "extensions/common/feature_switch.h" | 32 #include "extensions/common/feature_switch.h" |
| 36 #include "extensions/common/manifest.h" | 33 #include "extensions/common/manifest.h" |
| 37 #include "extensions/common/manifest_constants.h" | 34 #include "extensions/common/manifest_constants.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, | 111 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, |
| 115 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, | 112 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, |
| 116 IDS_EXTENSION_PROMPT_THESE_WILL_HAVE_ACCESS_TO, | 113 IDS_EXTENSION_PROMPT_THESE_WILL_HAVE_ACCESS_TO, |
| 117 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO, | 114 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO, |
| 118 IDS_EXTENSION_PROMPT_WANTS_ACCESS_TO, | 115 IDS_EXTENSION_PROMPT_WANTS_ACCESS_TO, |
| 119 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, | 116 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, |
| 120 IDS_EXTENSION_PROMPT_CAN_ACCESS, | 117 IDS_EXTENSION_PROMPT_CAN_ACCESS, |
| 121 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, | 118 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, |
| 122 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, | 119 IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO, |
| 123 }; | 120 }; |
| 124 static const int kOAuthHeaderIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { | |
| 125 IDS_EXTENSION_PROMPT_OAUTH_HEADER, | |
| 126 0, // Inline installs don't show OAuth permissions. | |
| 127 0, // Bundle installs don't show OAuth permissions. | |
| 128 IDS_EXTENSION_PROMPT_OAUTH_REENABLE_HEADER, | |
| 129 IDS_EXTENSION_PROMPT_OAUTH_PERMISSIONS_HEADER, | |
| 130 0, | |
| 131 0, | |
| 132 IDS_EXTENSION_PROMPT_OAUTH_HEADER, | |
| 133 IDS_EXTENSION_PROMPT_OAUTH_HEADER, | |
| 134 }; | |
| 135 | 121 |
| 136 // Size of extension icon in top left of dialog. | 122 // Size of extension icon in top left of dialog. |
| 137 const int kIconSize = 69; | 123 const int kIconSize = 69; |
| 138 | 124 |
| 139 // Returns pixel size under maximal scale factor for the icon whose device | 125 // Returns pixel size under maximal scale factor for the icon whose device |
| 140 // independent size is |size_in_dip| | 126 // independent size is |size_in_dip| |
| 141 int GetSizeForMaxScaleFactor(int size_in_dip) { | 127 int GetSizeForMaxScaleFactor(int size_in_dip) { |
| 142 return static_cast<int>(size_in_dip * gfx::ImageSkia::GetMaxSupportedScale()); | 128 return static_cast<int>(size_in_dip * gfx::ImageSkia::GetMaxSupportedScale()); |
| 143 } | 129 } |
| 144 | 130 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 } | 214 } |
| 229 | 215 |
| 230 void ExtensionInstallPrompt::Prompt::SetIsShowingDetails( | 216 void ExtensionInstallPrompt::Prompt::SetIsShowingDetails( |
| 231 DetailsType type, | 217 DetailsType type, |
| 232 size_t index, | 218 size_t index, |
| 233 bool is_showing_details) { | 219 bool is_showing_details) { |
| 234 switch (type) { | 220 switch (type) { |
| 235 case PERMISSIONS_DETAILS: | 221 case PERMISSIONS_DETAILS: |
| 236 is_showing_details_for_permissions_[index] = is_showing_details; | 222 is_showing_details_for_permissions_[index] = is_showing_details; |
| 237 break; | 223 break; |
| 238 case OAUTH_DETAILS: | |
| 239 is_showing_details_for_oauth_[index] = is_showing_details; | |
| 240 break; | |
| 241 case RETAINED_FILES_DETAILS: | 224 case RETAINED_FILES_DETAILS: |
| 242 is_showing_details_for_retained_files_ = is_showing_details; | 225 is_showing_details_for_retained_files_ = is_showing_details; |
| 243 break; | 226 break; |
| 244 } | 227 } |
| 245 } | 228 } |
| 246 | 229 |
| 247 void ExtensionInstallPrompt::Prompt::SetOAuthIssueAdvice( | |
| 248 const IssueAdviceInfo& issue_advice) { | |
| 249 is_showing_details_for_oauth_.clear(); | |
| 250 for (size_t i = 0; i < issue_advice.size(); ++i) | |
| 251 is_showing_details_for_oauth_.push_back(false); | |
| 252 | |
| 253 oauth_issue_advice_ = issue_advice; | |
| 254 } | |
| 255 | |
| 256 void ExtensionInstallPrompt::Prompt::SetUserNameFromProfile(Profile* profile) { | |
| 257 // |profile| can be NULL in unit tests. | |
| 258 if (profile) { | |
| 259 oauth_user_name_ = base::UTF8ToUTF16(profile->GetPrefs()->GetString( | |
| 260 prefs::kGoogleServicesUsername)); | |
| 261 } else { | |
| 262 oauth_user_name_.clear(); | |
| 263 } | |
| 264 } | |
| 265 | |
| 266 void ExtensionInstallPrompt::Prompt::SetWebstoreData( | 230 void ExtensionInstallPrompt::Prompt::SetWebstoreData( |
| 267 const std::string& localized_user_count, | 231 const std::string& localized_user_count, |
| 268 bool show_user_count, | 232 bool show_user_count, |
| 269 double average_rating, | 233 double average_rating, |
| 270 int rating_count) { | 234 int rating_count) { |
| 271 CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT); | 235 CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT); |
| 272 localized_user_count_ = localized_user_count; | 236 localized_user_count_ = localized_user_count; |
| 273 show_user_count_ = show_user_count; | 237 show_user_count_ = show_user_count; |
| 274 average_rating_ = average_rating; | 238 average_rating_ = average_rating; |
| 275 rating_count_ = rating_count; | 239 rating_count_ = rating_count; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 CHECK(HasAbortButtonLabel()); | 333 CHECK(HasAbortButtonLabel()); |
| 370 if (ShouldShowExplanationText()) | 334 if (ShouldShowExplanationText()) |
| 371 return experiment_->GetCancelButtonText(); | 335 return experiment_->GetCancelButtonText(); |
| 372 return l10n_util::GetStringUTF16(kAbortButtonIds[type_]); | 336 return l10n_util::GetStringUTF16(kAbortButtonIds[type_]); |
| 373 } | 337 } |
| 374 | 338 |
| 375 base::string16 ExtensionInstallPrompt::Prompt::GetPermissionsHeading() const { | 339 base::string16 ExtensionInstallPrompt::Prompt::GetPermissionsHeading() const { |
| 376 return l10n_util::GetStringUTF16(kPermissionsHeaderIds[type_]); | 340 return l10n_util::GetStringUTF16(kPermissionsHeaderIds[type_]); |
| 377 } | 341 } |
| 378 | 342 |
| 379 base::string16 ExtensionInstallPrompt::Prompt::GetOAuthHeading() const { | |
| 380 return l10n_util::GetStringFUTF16(kOAuthHeaderIds[type_], oauth_user_name_); | |
| 381 } | |
| 382 | |
| 383 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const { | 343 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFilesHeading() const { |
| 384 const int kRetainedFilesMessageIDs[6] = { | 344 const int kRetainedFilesMessageIDs[6] = { |
| 385 IDS_EXTENSION_PROMPT_RETAINED_FILES_DEFAULT, | 345 IDS_EXTENSION_PROMPT_RETAINED_FILES_DEFAULT, |
| 386 IDS_EXTENSION_PROMPT_RETAINED_FILE_SINGULAR, | 346 IDS_EXTENSION_PROMPT_RETAINED_FILE_SINGULAR, |
| 387 IDS_EXTENSION_PROMPT_RETAINED_FILES_ZERO, | 347 IDS_EXTENSION_PROMPT_RETAINED_FILES_ZERO, |
| 388 IDS_EXTENSION_PROMPT_RETAINED_FILES_TWO, | 348 IDS_EXTENSION_PROMPT_RETAINED_FILES_TWO, |
| 389 IDS_EXTENSION_PROMPT_RETAINED_FILES_FEW, | 349 IDS_EXTENSION_PROMPT_RETAINED_FILES_FEW, |
| 390 IDS_EXTENSION_PROMPT_RETAINED_FILES_MANY, | 350 IDS_EXTENSION_PROMPT_RETAINED_FILES_MANY, |
| 391 }; | 351 }; |
| 392 std::vector<int> message_ids; | 352 std::vector<int> message_ids; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 CHECK_LT(index, details_.size()); | 424 CHECK_LT(index, details_.size()); |
| 465 return details_[index]; | 425 return details_[index]; |
| 466 } | 426 } |
| 467 | 427 |
| 468 bool ExtensionInstallPrompt::Prompt::GetIsShowingDetails( | 428 bool ExtensionInstallPrompt::Prompt::GetIsShowingDetails( |
| 469 DetailsType type, size_t index) const { | 429 DetailsType type, size_t index) const { |
| 470 switch (type) { | 430 switch (type) { |
| 471 case PERMISSIONS_DETAILS: | 431 case PERMISSIONS_DETAILS: |
| 472 CHECK_LT(index, is_showing_details_for_permissions_.size()); | 432 CHECK_LT(index, is_showing_details_for_permissions_.size()); |
| 473 return is_showing_details_for_permissions_[index]; | 433 return is_showing_details_for_permissions_[index]; |
| 474 case OAUTH_DETAILS: | |
| 475 CHECK_LT(index, is_showing_details_for_oauth_.size()); | |
| 476 return is_showing_details_for_oauth_[index]; | |
| 477 case RETAINED_FILES_DETAILS: | 434 case RETAINED_FILES_DETAILS: |
| 478 return is_showing_details_for_retained_files_; | 435 return is_showing_details_for_retained_files_; |
| 479 } | 436 } |
| 480 return false; | 437 return false; |
| 481 } | 438 } |
| 482 | 439 |
| 483 size_t ExtensionInstallPrompt::Prompt::GetOAuthIssueCount() const { | |
| 484 return oauth_issue_advice_.size(); | |
| 485 } | |
| 486 | |
| 487 const IssueAdviceInfoEntry& ExtensionInstallPrompt::Prompt::GetOAuthIssue( | |
| 488 size_t index) const { | |
| 489 CHECK_LT(index, oauth_issue_advice_.size()); | |
| 490 return oauth_issue_advice_[index]; | |
| 491 } | |
| 492 | |
| 493 size_t ExtensionInstallPrompt::Prompt::GetRetainedFileCount() const { | 440 size_t ExtensionInstallPrompt::Prompt::GetRetainedFileCount() const { |
| 494 return retained_files_.size(); | 441 return retained_files_.size(); |
| 495 } | 442 } |
| 496 | 443 |
| 497 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFile(size_t index) | 444 base::string16 ExtensionInstallPrompt::Prompt::GetRetainedFile(size_t index) |
| 498 const { | 445 const { |
| 499 CHECK_LT(index, retained_files_.size()); | 446 CHECK_LT(index, retained_files_.size()); |
| 500 return retained_files_[index].AsUTF16Unsafe(); | 447 return retained_files_[index].AsUTF16Unsafe(); |
| 501 } | 448 } |
| 502 | 449 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 return Extension::Create( | 490 return Extension::Create( |
| 544 base::FilePath(), | 491 base::FilePath(), |
| 545 Manifest::INTERNAL, | 492 Manifest::INTERNAL, |
| 546 localized_manifest.get() ? *localized_manifest.get() : *manifest, | 493 localized_manifest.get() ? *localized_manifest.get() : *manifest, |
| 547 flags, | 494 flags, |
| 548 id, | 495 id, |
| 549 error); | 496 error); |
| 550 } | 497 } |
| 551 | 498 |
| 552 ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents) | 499 ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents) |
| 553 : OAuth2TokenService::Consumer("extensions_install"), | 500 : ui_loop_(base::MessageLoop::current()), |
| 554 record_oauth2_grant_(false), | |
| 555 ui_loop_(base::MessageLoop::current()), | |
| 556 extension_(NULL), | 501 extension_(NULL), |
| 557 bundle_(NULL), | 502 bundle_(NULL), |
| 558 install_ui_(ExtensionInstallUI::Create(ProfileForWebContents(contents))), | 503 install_ui_(ExtensionInstallUI::Create(ProfileForWebContents(contents))), |
| 559 show_params_(contents), | 504 show_params_(contents), |
| 560 delegate_(NULL), | 505 delegate_(NULL), |
| 561 prompt_(UNSET_PROMPT_TYPE) { | 506 prompt_(UNSET_PROMPT_TYPE) {} |
| 562 prompt_.SetUserNameFromProfile(install_ui_->profile()); | |
| 563 } | |
| 564 | 507 |
| 565 ExtensionInstallPrompt::ExtensionInstallPrompt( | 508 ExtensionInstallPrompt::ExtensionInstallPrompt( |
| 566 Profile* profile, | 509 Profile* profile, |
| 567 gfx::NativeWindow native_window, | 510 gfx::NativeWindow native_window, |
| 568 content::PageNavigator* navigator) | 511 content::PageNavigator* navigator) |
| 569 : OAuth2TokenService::Consumer("extensions_install"), | 512 : ui_loop_(base::MessageLoop::current()), |
| 570 record_oauth2_grant_(false), | |
| 571 ui_loop_(base::MessageLoop::current()), | |
| 572 extension_(NULL), | 513 extension_(NULL), |
| 573 bundle_(NULL), | 514 bundle_(NULL), |
| 574 install_ui_(ExtensionInstallUI::Create(profile)), | 515 install_ui_(ExtensionInstallUI::Create(profile)), |
| 575 show_params_(native_window, navigator), | 516 show_params_(native_window, navigator), |
| 576 delegate_(NULL), | 517 delegate_(NULL), |
| 577 prompt_(UNSET_PROMPT_TYPE) { | 518 prompt_(UNSET_PROMPT_TYPE) {} |
| 578 prompt_.SetUserNameFromProfile(install_ui_->profile()); | |
| 579 } | |
| 580 | 519 |
| 581 ExtensionInstallPrompt::~ExtensionInstallPrompt() { | 520 ExtensionInstallPrompt::~ExtensionInstallPrompt() { |
| 582 } | 521 } |
| 583 | 522 |
| 584 void ExtensionInstallPrompt::ConfirmBundleInstall( | 523 void ExtensionInstallPrompt::ConfirmBundleInstall( |
| 585 extensions::BundleInstaller* bundle, | 524 extensions::BundleInstaller* bundle, |
| 586 const PermissionSet* permissions) { | 525 const PermissionSet* permissions) { |
| 587 DCHECK(ui_loop_ == base::MessageLoop::current()); | 526 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 588 bundle_ = bundle; | 527 bundle_ = bundle; |
| 589 permissions_ = permissions; | 528 permissions_ = permissions; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 const PermissionSet* permissions) { | 630 const PermissionSet* permissions) { |
| 692 DCHECK(ui_loop_ == base::MessageLoop::current()); | 631 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 693 extension_ = extension; | 632 extension_ = extension; |
| 694 permissions_ = permissions; | 633 permissions_ = permissions; |
| 695 delegate_ = delegate; | 634 delegate_ = delegate; |
| 696 prompt_.set_type(PERMISSIONS_PROMPT); | 635 prompt_.set_type(PERMISSIONS_PROMPT); |
| 697 | 636 |
| 698 LoadImageIfNeeded(); | 637 LoadImageIfNeeded(); |
| 699 } | 638 } |
| 700 | 639 |
| 701 void ExtensionInstallPrompt::ConfirmIssueAdvice( | |
| 702 Delegate* delegate, | |
| 703 const Extension* extension, | |
| 704 const IssueAdviceInfo& issue_advice) { | |
| 705 DCHECK(ui_loop_ == base::MessageLoop::current()); | |
| 706 extension_ = extension; | |
| 707 delegate_ = delegate; | |
| 708 prompt_.set_type(PERMISSIONS_PROMPT); | |
| 709 | |
| 710 record_oauth2_grant_ = true; | |
| 711 prompt_.SetOAuthIssueAdvice(issue_advice); | |
| 712 | |
| 713 LoadImageIfNeeded(); | |
| 714 } | |
| 715 | |
| 716 void ExtensionInstallPrompt::ReviewPermissions( | 640 void ExtensionInstallPrompt::ReviewPermissions( |
| 717 Delegate* delegate, | 641 Delegate* delegate, |
| 718 const Extension* extension, | 642 const Extension* extension, |
| 719 const std::vector<base::FilePath>& retained_file_paths) { | 643 const std::vector<base::FilePath>& retained_file_paths) { |
| 720 DCHECK(ui_loop_ == base::MessageLoop::current()); | 644 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 721 extension_ = extension; | 645 extension_ = extension; |
| 722 permissions_ = extension->GetActivePermissions(); | 646 permissions_ = extension->GetActivePermissions(); |
| 723 prompt_.set_retained_files(retained_file_paths); | 647 prompt_.set_retained_files(retained_file_paths); |
| 724 delegate_ = delegate; | 648 delegate_ = delegate; |
| 725 prompt_.set_type(POST_INSTALL_PERMISSIONS_PROMPT); | 649 prompt_.set_type(POST_INSTALL_PERMISSIONS_PROMPT); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 // Load the icon whose pixel size is large enough to be displayed under | 698 // Load the icon whose pixel size is large enough to be displayed under |
| 775 // maximal supported scale factor. UI code will scale the icon down if needed. | 699 // maximal supported scale factor. UI code will scale the icon down if needed. |
| 776 // TODO(tbarzic): We should use IconImage here and load the required bitmap | 700 // TODO(tbarzic): We should use IconImage here and load the required bitmap |
| 777 // lazily. | 701 // lazily. |
| 778 int pixel_size = GetSizeForMaxScaleFactor(kIconSize); | 702 int pixel_size = GetSizeForMaxScaleFactor(kIconSize); |
| 779 extensions::ImageLoader::Get(install_ui_->profile())->LoadImageAsync( | 703 extensions::ImageLoader::Get(install_ui_->profile())->LoadImageAsync( |
| 780 extension_, image, gfx::Size(pixel_size, pixel_size), | 704 extension_, image, gfx::Size(pixel_size, pixel_size), |
| 781 base::Bind(&ExtensionInstallPrompt::OnImageLoaded, AsWeakPtr())); | 705 base::Bind(&ExtensionInstallPrompt::OnImageLoaded, AsWeakPtr())); |
| 782 } | 706 } |
| 783 | 707 |
| 784 void ExtensionInstallPrompt::OnGetTokenSuccess( | |
| 785 const OAuth2TokenService::Request* request, | |
| 786 const std::string& access_token, | |
| 787 const base::Time& expiration_time) { | |
| 788 DCHECK_EQ(login_token_request_.get(), request); | |
| 789 login_token_request_.reset(); | |
| 790 | |
| 791 const extensions::OAuth2Info& oauth2_info = | |
| 792 extensions::OAuth2Info::GetOAuth2Info(extension_); | |
| 793 | |
| 794 token_flow_.reset(new OAuth2MintTokenFlow( | |
| 795 install_ui_->profile()->GetRequestContext(), | |
| 796 this, | |
| 797 OAuth2MintTokenFlow::Parameters( | |
| 798 access_token, | |
| 799 extension_->id(), | |
| 800 oauth2_info.client_id, | |
| 801 oauth2_info.scopes, | |
| 802 OAuth2MintTokenFlow::MODE_ISSUE_ADVICE))); | |
| 803 token_flow_->Start(); | |
| 804 } | |
| 805 | |
| 806 void ExtensionInstallPrompt::OnGetTokenFailure( | |
| 807 const OAuth2TokenService::Request* request, | |
| 808 const GoogleServiceAuthError& error) { | |
| 809 DCHECK_EQ(login_token_request_.get(), request); | |
| 810 login_token_request_.reset(); | |
| 811 ShowConfirmation(); | |
| 812 } | |
| 813 | |
| 814 void ExtensionInstallPrompt::OnIssueAdviceSuccess( | |
| 815 const IssueAdviceInfo& advice_info) { | |
| 816 prompt_.SetOAuthIssueAdvice(advice_info); | |
| 817 record_oauth2_grant_ = true; | |
| 818 ShowConfirmation(); | |
| 819 } | |
| 820 | |
| 821 void ExtensionInstallPrompt::OnMintTokenFailure( | |
| 822 const GoogleServiceAuthError& error) { | |
| 823 ShowConfirmation(); | |
| 824 } | |
| 825 | |
| 826 void ExtensionInstallPrompt::ShowConfirmation() { | 708 void ExtensionInstallPrompt::ShowConfirmation() { |
| 827 if (prompt_.type() == INSTALL_PROMPT) | 709 if (prompt_.type() == INSTALL_PROMPT) |
| 828 prompt_.set_experiment(ExtensionInstallPromptExperiment::Find()); | 710 prompt_.set_experiment(ExtensionInstallPromptExperiment::Find()); |
| 829 else | 711 else |
| 830 prompt_.set_experiment(ExtensionInstallPromptExperiment::ControlGroup()); | 712 prompt_.set_experiment(ExtensionInstallPromptExperiment::ControlGroup()); |
| 831 | 713 |
| 832 if (permissions_.get() && | 714 if (permissions_.get() && |
| 833 (!extension_ || | 715 (!extension_ || |
| 834 !extensions::PermissionsData::ShouldSkipPermissionWarnings( | 716 !extensions::PermissionsData::ShouldSkipPermissionWarnings( |
| 835 extension_))) { | 717 extension_))) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 866 } | 748 } |
| 867 | 749 |
| 868 if (AutoConfirmPrompt(delegate_)) | 750 if (AutoConfirmPrompt(delegate_)) |
| 869 return; | 751 return; |
| 870 | 752 |
| 871 if (show_dialog_callback_.is_null()) | 753 if (show_dialog_callback_.is_null()) |
| 872 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); | 754 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); |
| 873 else | 755 else |
| 874 show_dialog_callback_.Run(show_params_, delegate_, prompt_); | 756 show_dialog_callback_.Run(show_params_, delegate_, prompt_); |
| 875 } | 757 } |
| OLD | NEW |