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/crx_installer.h" | 5 #include "chrome/browser/extensions/crx_installer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "chrome/browser/download/download_crx_util.h" | 16 #include "chrome/browser/download/download_crx_util.h" |
16 #include "chrome/browser/extensions/browser_action_test_util.h" | 17 #include "chrome/browser/extensions/browser_action_test_util.h" |
17 #include "chrome/browser/extensions/extension_browsertest.h" | 18 #include "chrome/browser/extensions/extension_browsertest.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 const char* manifest_dir, | 229 const char* manifest_dir, |
229 const std::string& id, | 230 const std::string& id, |
230 bool strict_manifest_checks) { | 231 bool strict_manifest_checks) { |
231 scoped_ptr<WebstoreInstaller::Approval> result; | 232 scoped_ptr<WebstoreInstaller::Approval> result; |
232 | 233 |
233 base::FilePath ext_path = test_data_dir_.AppendASCII(manifest_dir); | 234 base::FilePath ext_path = test_data_dir_.AppendASCII(manifest_dir); |
234 std::string error; | 235 std::string error; |
235 scoped_ptr<base::DictionaryValue> parsed_manifest( | 236 scoped_ptr<base::DictionaryValue> parsed_manifest( |
236 file_util::LoadManifest(ext_path, &error)); | 237 file_util::LoadManifest(ext_path, &error)); |
237 if (!parsed_manifest.get() || !error.empty()) | 238 if (!parsed_manifest.get() || !error.empty()) |
238 return result.Pass(); | 239 return result; |
239 | 240 |
240 return WebstoreInstaller::Approval::CreateWithNoInstallPrompt( | 241 return WebstoreInstaller::Approval::CreateWithNoInstallPrompt( |
241 browser()->profile(), | 242 browser()->profile(), id, std::move(parsed_manifest), |
242 id, | |
243 parsed_manifest.Pass(), | |
244 strict_manifest_checks); | 243 strict_manifest_checks); |
245 } | 244 } |
246 | 245 |
247 void RunCrxInstaller(const WebstoreInstaller::Approval* approval, | 246 void RunCrxInstaller(const WebstoreInstaller::Approval* approval, |
248 scoped_ptr<ExtensionInstallPrompt> prompt, | 247 scoped_ptr<ExtensionInstallPrompt> prompt, |
249 const base::FilePath& crx_path) { | 248 const base::FilePath& crx_path) { |
250 ExtensionService* service = extensions::ExtensionSystem::Get( | 249 ExtensionService* service = extensions::ExtensionSystem::Get( |
251 browser()->profile())->extension_service(); | 250 browser()->profile())->extension_service(); |
252 scoped_refptr<CrxInstaller> installer( | 251 scoped_refptr<CrxInstaller> installer( |
253 CrxInstaller::Create(service, prompt.Pass(), approval)); | 252 CrxInstaller::Create(service, std::move(prompt), approval)); |
254 installer->set_allow_silent_install(true); | 253 installer->set_allow_silent_install(true); |
255 installer->set_is_gallery_install(true); | 254 installer->set_is_gallery_install(true); |
256 installer->InstallCrx(crx_path); | 255 installer->InstallCrx(crx_path); |
257 content::RunMessageLoop(); | 256 content::RunMessageLoop(); |
258 } | 257 } |
259 | 258 |
260 // Installs a crx from |crx_relpath| (a path relative to the extension test | 259 // Installs a crx from |crx_relpath| (a path relative to the extension test |
261 // data dir) with expected id |id|. | 260 // data dir) with expected id |id|. |
262 void InstallWithPrompt(const char* ext_relpath, | 261 void InstallWithPrompt(const char* ext_relpath, |
263 const std::string& id, | 262 const std::string& id, |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 // these checks (see https://crbug.com/545541). | 668 // these checks (see https://crbug.com/545541). |
670 ManagementPolicyMock policy; | 669 ManagementPolicyMock policy; |
671 extensions::ExtensionSystem::Get(profile()) | 670 extensions::ExtensionSystem::Get(profile()) |
672 ->management_policy() | 671 ->management_policy() |
673 ->RegisterProvider(&policy); | 672 ->RegisterProvider(&policy); |
674 | 673 |
675 InstallWebAppAndVerifyNoErrors(); | 674 InstallWebAppAndVerifyNoErrors(); |
676 } | 675 } |
677 | 676 |
678 } // namespace extensions | 677 } // namespace extensions |
OLD | NEW |