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 "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 base::string16* error) const override { | 159 base::string16* error) const override { |
160 *error = base::UTF8ToUTF16("Dummy error message"); | 160 *error = base::UTF8ToUTF16("Dummy error message"); |
161 return false; | 161 return false; |
162 } | 162 } |
163 }; | 163 }; |
164 | 164 |
165 // Appends "enable-experimental-extension-apis" to the command line for the | 165 // Appends "enable-experimental-extension-apis" to the command line for the |
166 // lifetime of this class. | 166 // lifetime of this class. |
167 class ScopedExperimentalCommandLine { | 167 class ScopedExperimentalCommandLine { |
168 public: | 168 public: |
169 ScopedExperimentalCommandLine() : saved_(*CommandLine::ForCurrentProcess()) { | 169 ScopedExperimentalCommandLine() |
170 CommandLine::ForCurrentProcess()->AppendSwitch( | 170 : saved_(*base::CommandLine::ForCurrentProcess()) { |
| 171 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
171 switches::kEnableExperimentalExtensionApis); | 172 switches::kEnableExperimentalExtensionApis); |
172 } | 173 } |
173 | 174 |
174 ~ScopedExperimentalCommandLine() { | 175 ~ScopedExperimentalCommandLine() { |
175 *CommandLine::ForCurrentProcess() = saved_; | 176 *base::CommandLine::ForCurrentProcess() = saved_; |
176 } | 177 } |
177 | 178 |
178 private: | 179 private: |
179 CommandLine saved_; | 180 base::CommandLine saved_; |
180 }; | 181 }; |
181 | 182 |
182 } // namespace | 183 } // namespace |
183 | 184 |
184 class ExtensionCrxInstallerTest : public ExtensionBrowserTest { | 185 class ExtensionCrxInstallerTest : public ExtensionBrowserTest { |
185 protected: | 186 protected: |
186 scoped_ptr<WebstoreInstaller::Approval> GetApproval( | 187 scoped_ptr<WebstoreInstaller::Approval> GetApproval( |
187 const char* manifest_dir, | 188 const char* manifest_dir, |
188 const std::string& id, | 189 const std::string& id, |
189 bool strict_manifest_checks) { | 190 bool strict_manifest_checks) { |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 fake_user_manager->AddKioskAppUser("example@example.com"); | 549 fake_user_manager->AddKioskAppUser("example@example.com"); |
549 fake_user_manager->LoginUser("example@example.com"); | 550 fake_user_manager->LoginUser("example@example.com"); |
550 chromeos::ScopedUserManagerEnabler scoped_user_manager(fake_user_manager); | 551 chromeos::ScopedUserManagerEnabler scoped_user_manager(fake_user_manager); |
551 EXPECT_TRUE(InstallExtension(crx_path, 1)); | 552 EXPECT_TRUE(InstallExtension(crx_path, 1)); |
552 #endif | 553 #endif |
553 } | 554 } |
554 | 555 |
555 #if defined(OS_CHROMEOS) | 556 #if defined(OS_CHROMEOS) |
556 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, InstallToSharedLocation) { | 557 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, InstallToSharedLocation) { |
557 base::ShadowingAtExitManager at_exit_manager; | 558 base::ShadowingAtExitManager at_exit_manager; |
558 CommandLine::ForCurrentProcess()->AppendSwitch( | 559 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
559 chromeos::switches::kEnableExtensionAssetsSharing); | 560 chromeos::switches::kEnableExtensionAssetsSharing); |
560 base::ScopedTempDir cache_dir; | 561 base::ScopedTempDir cache_dir; |
561 ASSERT_TRUE(cache_dir.CreateUniqueTempDir()); | 562 ASSERT_TRUE(cache_dir.CreateUniqueTempDir()); |
562 ExtensionAssetsManagerChromeOS::SetSharedInstallDirForTesting( | 563 ExtensionAssetsManagerChromeOS::SetSharedInstallDirForTesting( |
563 cache_dir.path()); | 564 cache_dir.path()); |
564 | 565 |
565 base::FilePath crx_path = test_data_dir_.AppendASCII("crx_installer/v1.crx"); | 566 base::FilePath crx_path = test_data_dir_.AppendASCII("crx_installer/v1.crx"); |
566 const extensions::Extension* extension = InstallExtension( | 567 const extensions::Extension* extension = InstallExtension( |
567 crx_path, 1, extensions::Manifest::EXTERNAL_PREF); | 568 crx_path, 1, extensions::Manifest::EXTERNAL_PREF); |
568 base::FilePath extension_path = extension->path(); | 569 base::FilePath extension_path = extension->path(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 // because previously withheld permissions are now being requested. | 641 // because previously withheld permissions are now being requested. |
641 enable_scripts_switch.reset(); | 642 enable_scripts_switch.reset(); |
642 extension = InstallExtension(crx_path, -1); | 643 extension = InstallExtension(crx_path, -1); |
643 EXPECT_FALSE(registry->enabled_extensions().GetByID(extension_id)); | 644 EXPECT_FALSE(registry->enabled_extensions().GetByID(extension_id)); |
644 EXPECT_TRUE(registry->disabled_extensions().GetByID(extension_id)); | 645 EXPECT_TRUE(registry->disabled_extensions().GetByID(extension_id)); |
645 EXPECT_TRUE(ExtensionPrefs::Get(browser()->profile())->GetDisableReasons( | 646 EXPECT_TRUE(ExtensionPrefs::Get(browser()->profile())->GetDisableReasons( |
646 extension_id) & Extension::DISABLE_PERMISSIONS_INCREASE); | 647 extension_id) & Extension::DISABLE_PERMISSIONS_INCREASE); |
647 } | 648 } |
648 | 649 |
649 } // namespace extensions | 650 } // namespace extensions |
OLD | NEW |