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

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

Issue 11246003: Remove Profile->GetExtensionProcessManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix extension_crash_recovery_browsertest Created 8 years, 2 months 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 | Annotate | Revision Log
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/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "chrome/browser/extensions/autoupdate_interceptor.h" 7 #include "chrome/browser/extensions/autoupdate_interceptor.h"
8 #include "chrome/browser/extensions/extension_browsertest.h" 8 #include "chrome/browser/extensions/extension_browsertest.h"
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_system.h"
11 #include "chrome/browser/extensions/extension_test_message_listener.h" 12 #include "chrome/browser/extensions/extension_test_message_listener.h"
12 #include "chrome/browser/extensions/updater/extension_updater.h" 13 #include "chrome/browser/extensions/updater/extension_updater.h"
13 #include "chrome/browser/infobars/infobar_tab_helper.h" 14 #include "chrome/browser/infobars/infobar_tab_helper.h"
14 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/prefs/scoped_user_pref_update.h" 16 #include "chrome/browser/prefs/scoped_user_pref_update.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents.h" 19 #include "chrome/browser/ui/tab_contents/tab_contents.h"
19 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
(...skipping 14 matching lines...) Expand all
35 // 36 //
36 // Note that 'version' here means something different than the version field 37 // Note that 'version' here means something different than the version field
37 // in the extension's manifest. We use the version as reported by the 38 // in the extension's manifest. We use the version as reported by the
38 // background page to test how overinstalling crx files with the same 39 // background page to test how overinstalling crx files with the same
39 // manifest version works. 40 // manifest version works.
40 bool IsExtensionAtVersion(const Extension* extension, 41 bool IsExtensionAtVersion(const Extension* extension,
41 const std::string& expected_version) { 42 const std::string& expected_version) {
42 // Test that the extension's version from the manifest and reported by the 43 // Test that the extension's version from the manifest and reported by the
43 // background page is correct. This is to ensure that the processes are in 44 // background page is correct. This is to ensure that the processes are in
44 // sync with the Extension. 45 // sync with the Extension.
45 ExtensionProcessManager* manager = browser()->profile()-> 46 ExtensionProcessManager* manager =
46 GetExtensionProcessManager(); 47 extensions::ExtensionSystem::Get(browser()->profile())->
48 process_manager();
47 extensions::ExtensionHost* ext_host = 49 extensions::ExtensionHost* ext_host =
48 manager->GetBackgroundHostForExtension(extension->id()); 50 manager->GetBackgroundHostForExtension(extension->id());
49 EXPECT_TRUE(ext_host); 51 EXPECT_TRUE(ext_host);
50 if (!ext_host) 52 if (!ext_host)
51 return false; 53 return false;
52 54
53 std::string version_from_bg; 55 std::string version_from_bg;
54 bool exec = content::ExecuteJavaScriptAndExtractString( 56 bool exec = content::ExecuteJavaScriptAndExtractString(
55 ext_host->render_view_host(), L"", L"version()", &version_from_bg); 57 ext_host->render_view_host(), L"", L"version()", &version_from_bg);
56 EXPECT_TRUE(exec); 58 EXPECT_TRUE(exec);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 UninstallExtension(id); 127 UninstallExtension(id);
126 128
127 // And the install should succeed when the permissions are accepted. 129 // And the install should succeed when the permissions are accepted.
128 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( 130 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(
129 test_data_dir_.AppendASCII("good.crx"), 1, browser())); 131 test_data_dir_.AppendASCII("good.crx"), 1, browser()));
130 UninstallExtension(id); 132 UninstallExtension(id);
131 } 133 }
132 134
133 // Tests that disabling and re-enabling an extension works. 135 // Tests that disabling and re-enabling an extension works.
134 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, DisableEnable) { 136 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, DisableEnable) {
135 ExtensionProcessManager* manager = browser()->profile()-> 137 ExtensionProcessManager* manager =
136 GetExtensionProcessManager(); 138 extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
137 ExtensionService* service = browser()->profile()->GetExtensionService(); 139 ExtensionService* service = browser()->profile()->GetExtensionService();
138 const size_t size_before = service->extensions()->size(); 140 const size_t size_before = service->extensions()->size();
139 141
140 // Load an extension, expect the background page to be available. 142 // Load an extension, expect the background page to be available.
141 std::string extension_id = "bjafgdebaacbbbecmhlhpofkepfkgcpa"; 143 std::string extension_id = "bjafgdebaacbbbecmhlhpofkepfkgcpa";
142 ASSERT_TRUE(LoadExtension( 144 ASSERT_TRUE(LoadExtension(
143 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 145 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
144 .AppendASCII(extension_id) 146 .AppendASCII(extension_id)
145 .AppendASCII("1.0"))); 147 .AppendASCII("1.0")));
146 ASSERT_EQ(size_before + 1, service->extensions()->size()); 148 ASSERT_EQ(size_before + 1, service->extensions()->size());
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest")); 625 std::string(kExtensionId) + ";http://localhost/autoupdate/manifest"));
624 } 626 }
625 ASSERT_TRUE(WaitForExtensionInstall()); 627 ASSERT_TRUE(WaitForExtensionInstall());
626 ASSERT_EQ(size_before + 1, service->extensions()->size()); 628 ASSERT_EQ(size_before + 1, service->extensions()->size());
627 extension = service->GetExtensionById(kExtensionId, false); 629 extension = service->GetExtensionById(kExtensionId, false);
628 ASSERT_TRUE(extension); 630 ASSERT_TRUE(extension);
629 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location()); 631 EXPECT_EQ(Extension::EXTERNAL_POLICY_DOWNLOAD, extension->location());
630 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId)); 632 EXPECT_TRUE(service->IsExtensionEnabled(kExtensionId));
631 EXPECT_TRUE(service->disabled_extensions()->is_empty()); 633 EXPECT_TRUE(service->disabled_extensions()->is_empty());
632 } 634 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698