| 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/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/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/image_loader.h" | 18 #include "chrome/browser/extensions/image_loader.h" |
| 19 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/signin/token_service.h" | 21 #include "chrome/browser/signin/token_service.h" |
| 22 #include "chrome/browser/signin/token_service_factory.h" | 22 #include "chrome/browser/signin/token_service_factory.h" |
| 23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" |
| 26 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
| 27 #include "chrome/common/extensions/extension_constants.h" | 28 #include "chrome/common/extensions/extension_constants.h" |
| 28 #include "chrome/common/extensions/extension_icon_set.h" | 29 #include "chrome/common/extensions/extension_icon_set.h" |
| 29 #include "chrome/common/extensions/extension_manifest_constants.h" | 30 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 30 #include "chrome/common/extensions/extension_resource.h" | 31 #include "chrome/common/extensions/extension_resource.h" |
| 31 #include "chrome/common/extensions/feature_switch.h" | 32 #include "chrome/common/extensions/feature_switch.h" |
| 32 #include "chrome/common/extensions/permissions/permission_set.h" | 33 #include "chrome/common/extensions/permissions/permission_set.h" |
| 33 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 34 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
| 35 #include "content/public/browser/web_contents_view.h" | 36 #include "content/public/browser/web_contents_view.h" |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 // |extension_| may be NULL, e.g. in the bundle install case. | 587 // |extension_| may be NULL, e.g. in the bundle install case. |
| 587 if (!extension_ || | 588 if (!extension_ || |
| 588 prompt_.type() == BUNDLE_INSTALL_PROMPT || | 589 prompt_.type() == BUNDLE_INSTALL_PROMPT || |
| 589 prompt_.type() == INLINE_INSTALL_PROMPT || | 590 prompt_.type() == INLINE_INSTALL_PROMPT || |
| 590 prompt_.type() == EXTERNAL_INSTALL_PROMPT || | 591 prompt_.type() == EXTERNAL_INSTALL_PROMPT || |
| 591 prompt_.GetOAuthIssueCount() != 0U) { | 592 prompt_.GetOAuthIssueCount() != 0U) { |
| 592 ShowConfirmation(); | 593 ShowConfirmation(); |
| 593 return; | 594 return; |
| 594 } | 595 } |
| 595 | 596 |
| 596 const Extension::OAuth2Info& oauth2_info = extension_->oauth2_info(); | 597 const extensions::OAuth2Info* oauth2_info = |
| 597 if (oauth2_info.client_id.empty() || | 598 extensions::OAuth2Info::GetOAuth2Info(extension_); |
| 598 oauth2_info.scopes.empty()) { | 599 if (oauth2_info->client_id.empty() || |
| 600 oauth2_info->scopes.empty()) { |
| 599 ShowConfirmation(); | 601 ShowConfirmation(); |
| 600 return; | 602 return; |
| 601 } | 603 } |
| 602 | 604 |
| 603 Profile* profile = install_ui_->profile(); | 605 Profile* profile = install_ui_->profile(); |
| 604 TokenService* token_service = TokenServiceFactory::GetForProfile(profile); | 606 TokenService* token_service = TokenServiceFactory::GetForProfile(profile); |
| 605 | 607 |
| 606 token_flow_.reset(new OAuth2MintTokenFlow( | 608 token_flow_.reset(new OAuth2MintTokenFlow( |
| 607 profile->GetRequestContext(), | 609 profile->GetRequestContext(), |
| 608 this, | 610 this, |
| 609 OAuth2MintTokenFlow::Parameters( | 611 OAuth2MintTokenFlow::Parameters( |
| 610 token_service->GetOAuth2LoginRefreshToken(), | 612 token_service->GetOAuth2LoginRefreshToken(), |
| 611 extension_->id(), | 613 extension_->id(), |
| 612 oauth2_info.client_id, | 614 oauth2_info->client_id, |
| 613 oauth2_info.scopes, | 615 oauth2_info->scopes, |
| 614 OAuth2MintTokenFlow::MODE_ISSUE_ADVICE))); | 616 OAuth2MintTokenFlow::MODE_ISSUE_ADVICE))); |
| 615 token_flow_->Start(); | 617 token_flow_->Start(); |
| 616 } | 618 } |
| 617 | 619 |
| 618 void ExtensionInstallPrompt::OnIssueAdviceSuccess( | 620 void ExtensionInstallPrompt::OnIssueAdviceSuccess( |
| 619 const IssueAdviceInfo& advice_info) { | 621 const IssueAdviceInfo& advice_info) { |
| 620 prompt_.SetOAuthIssueAdvice(advice_info); | 622 prompt_.SetOAuthIssueAdvice(advice_info); |
| 621 record_oauth2_grant_ = true; | 623 record_oauth2_grant_ = true; |
| 622 ShowConfirmation(); | 624 ShowConfirmation(); |
| 623 } | 625 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 } | 657 } |
| 656 | 658 |
| 657 if (AutoConfirmPrompt(delegate_)) | 659 if (AutoConfirmPrompt(delegate_)) |
| 658 return; | 660 return; |
| 659 | 661 |
| 660 if (show_dialog_callback_.is_null()) | 662 if (show_dialog_callback_.is_null()) |
| 661 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); | 663 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); |
| 662 else | 664 else |
| 663 show_dialog_callback_.Run(show_params_, delegate_, prompt_); | 665 show_dialog_callback_.Run(show_params_, delegate_, prompt_); |
| 664 } | 666 } |
| OLD | NEW |