Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: chrome/browser/extensions/api/management/management_browsertest.cc

Issue 671763002: Extract ProcessManager from ExtensionSystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/prefs/scoped_user_pref_update.h" 8 #include "base/prefs/scoped_user_pref_update.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // Note that 'version' here means something different than the version field 76 // Note that 'version' here means something different than the version field
77 // in the extension's manifest. We use the version as reported by the 77 // in the extension's manifest. We use the version as reported by the
78 // background page to test how overinstalling crx files with the same 78 // background page to test how overinstalling crx files with the same
79 // manifest version works. 79 // manifest version works.
80 bool IsExtensionAtVersion(const Extension* extension, 80 bool IsExtensionAtVersion(const Extension* extension,
81 const std::string& expected_version) { 81 const std::string& expected_version) {
82 // Test that the extension's version from the manifest and reported by the 82 // Test that the extension's version from the manifest and reported by the
83 // background page is correct. This is to ensure that the processes are in 83 // background page is correct. This is to ensure that the processes are in
84 // sync with the Extension. 84 // sync with the Extension.
85 extensions::ProcessManager* manager = 85 extensions::ProcessManager* manager =
86 extensions::ExtensionSystem::Get(browser()->profile())-> 86 extensions::ProcessManager::Get(browser()->profile());
87 process_manager();
88 extensions::ExtensionHost* ext_host = 87 extensions::ExtensionHost* ext_host =
89 manager->GetBackgroundHostForExtension(extension->id()); 88 manager->GetBackgroundHostForExtension(extension->id());
90 EXPECT_TRUE(ext_host); 89 EXPECT_TRUE(ext_host);
91 if (!ext_host) 90 if (!ext_host)
92 return false; 91 return false;
93 92
94 std::string version_from_bg; 93 std::string version_from_bg;
95 bool exec = content::ExecuteScriptAndExtractString( 94 bool exec = content::ExecuteScriptAndExtractString(
96 ext_host->render_view_host(), "version()", &version_from_bg); 95 ext_host->render_view_host(), "version()", &version_from_bg);
97 EXPECT_TRUE(exec); 96 EXPECT_TRUE(exec);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 170
172 // And the install should succeed when the permissions are accepted. 171 // And the install should succeed when the permissions are accepted.
173 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( 172 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(
174 test_data_dir_.AppendASCII("good.crx"), 1, browser())); 173 test_data_dir_.AppendASCII("good.crx"), 1, browser()));
175 UninstallExtension(id); 174 UninstallExtension(id);
176 } 175 }
177 176
178 // Tests that disabling and re-enabling an extension works. 177 // Tests that disabling and re-enabling an extension works.
179 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, DisableEnable) { 178 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, DisableEnable) {
180 extensions::ProcessManager* manager = 179 extensions::ProcessManager* manager =
181 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); 180 extensions::ProcessManager::Get(browser()->profile());
182 ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile()); 181 ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile());
183 const size_t size_before = registry->enabled_extensions().size(); 182 const size_t size_before = registry->enabled_extensions().size();
184 183
185 // Load an extension, expect the background page to be available. 184 // Load an extension, expect the background page to be available.
186 std::string extension_id = "bjafgdebaacbbbecmhlhpofkepfkgcpa"; 185 std::string extension_id = "bjafgdebaacbbbecmhlhpofkepfkgcpa";
187 ASSERT_TRUE(LoadExtension( 186 ASSERT_TRUE(LoadExtension(
188 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 187 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
189 .AppendASCII(extension_id) 188 .AppendASCII(extension_id)
190 .AppendASCII("1.0"))); 189 .AppendASCII("1.0")));
191 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); 190 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 UpdateProviderPolicy(policies); 705 UpdateProviderPolicy(policies);
707 706
708 ASSERT_TRUE(WaitForExtensionInstall()); 707 ASSERT_TRUE(WaitForExtensionInstall());
709 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size()); 708 ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
710 extension = service->GetExtensionById(kExtensionId, false); 709 extension = service->GetExtensionById(kExtensionId, false);
711 ASSERT_TRUE(extension); 710 ASSERT_TRUE(extension);
712 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location()); 711 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, extension->location());
713 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); 712 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
714 EXPECT_TRUE(registry->disabled_extensions().is_empty()); 713 EXPECT_TRUE(registry->disabled_extensions().is_empty());
715 } 714 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698