| 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/extensions/api/inline_install_private/inline_install_pr
ivate_api.h" | 5 #include "chrome/browser/extensions/api/inline_install_private/inline_install_pr
ivate_api.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "chrome/browser/extensions/webstore_install_with_prompt.h" | 10 #include "chrome/browser/extensions/webstore_install_with_prompt.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 content::WebContents* web_contents = GetAssociatedWebContents(); | 109 content::WebContents* web_contents = GetAssociatedWebContents(); |
| 110 if (!web_contents) | 110 if (!web_contents) |
| 111 return RespondNow(CreateResponse("Must be called from a foreground page", | 111 return RespondNow(CreateResponse("Must be called from a foreground page", |
| 112 webstore_install::NOT_PERMITTED)); | 112 webstore_install::NOT_PERMITTED)); |
| 113 | 113 |
| 114 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context()); | 114 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context()); |
| 115 if (registry->GetExtensionById(params->id, ExtensionRegistry::EVERYTHING)) | 115 if (registry->GetExtensionById(params->id, ExtensionRegistry::EVERYTHING)) |
| 116 return RespondNow(CreateResponse("Already installed", | 116 return RespondNow(CreateResponse("Already installed", |
| 117 webstore_install::OTHER_ERROR)); | 117 webstore_install::OTHER_ERROR)); |
| 118 | 118 |
| 119 scoped_refptr<Installer> installer = | 119 scoped_refptr<Installer> installer = new Installer( |
| 120 new Installer( | 120 params->id, source_url(), Profile::FromBrowserContext(browser_context()), |
| 121 params->id, | 121 base::Bind(&InlineInstallPrivateInstallFunction::InstallerCallback, |
| 122 source_url_, | 122 this)); |
| 123 Profile::FromBrowserContext(browser_context()), | |
| 124 base::Bind( | |
| 125 &InlineInstallPrivateInstallFunction::InstallerCallback, | |
| 126 this)); | |
| 127 installer->BeginInstall(); | 123 installer->BeginInstall(); |
| 128 | 124 |
| 129 return RespondLater(); | 125 return RespondLater(); |
| 130 } | 126 } |
| 131 | 127 |
| 132 void InlineInstallPrivateInstallFunction::InstallerCallback( | 128 void InlineInstallPrivateInstallFunction::InstallerCallback( |
| 133 bool success, | 129 bool success, |
| 134 const std::string& error, | 130 const std::string& error, |
| 135 webstore_install::Result result) { | 131 webstore_install::Result result) { |
| 136 | 132 |
| 137 Respond(CreateResponse(success ? std::string() : error, result)); | 133 Respond(CreateResponse(success ? std::string() : error, result)); |
| 138 } | 134 } |
| 139 | 135 |
| 140 ExtensionFunction::ResponseValue | 136 ExtensionFunction::ResponseValue |
| 141 InlineInstallPrivateInstallFunction::CreateResponse( | 137 InlineInstallPrivateInstallFunction::CreateResponse( |
| 142 const std::string& error, webstore_install::Result result) { | 138 const std::string& error, webstore_install::Result result) { |
| 143 return ArgumentList(api::inline_install_private::Install::Results::Create( | 139 return ArgumentList(api::inline_install_private::Install::Results::Create( |
| 144 error, | 140 error, |
| 145 api::webstore::kInstallResultCodes[result])); | 141 api::webstore::kInstallResultCodes[result])); |
| 146 } | 142 } |
| 147 | 143 |
| 148 } // namespace extensions | 144 } // namespace extensions |
| OLD | NEW |