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

Side by Side Diff: chrome/browser/extensions/extension_disabled_ui_browsertest.cc

Issue 264763002: Support remote installation of extensions and apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 6 years, 7 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/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/threading/sequenced_worker_pool.h" 8 #include "base/threading/sequenced_worker_pool.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/extensions/extension_browsertest.h" 10 #include "chrome/browser/extensions/extension_browsertest.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_sync_service.h" 12 #include "chrome/browser/extensions/extension_sync_service.h"
13 #include "chrome/browser/extensions/updater/extension_updater.h" 13 #include "chrome/browser/extensions/updater/extension_updater.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/global_error/global_error.h" 16 #include "chrome/browser/ui/global_error/global_error.h"
17 #include "chrome/browser/ui/global_error/global_error_service.h" 17 #include "chrome/browser/ui/global_error/global_error_service.h"
18 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 18 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/test/test_utils.h" 21 #include "content/public/test/test_utils.h"
22 #include "content/test/net/url_request_prepackaged_interceptor.h" 22 #include "content/test/net/url_request_prepackaged_interceptor.h"
23 #include "extensions/browser/extension_prefs.h" 23 #include "extensions/browser/extension_prefs.h"
24 #include "extensions/browser/extension_registry.h" 24 #include "extensions/browser/extension_registry.h"
25 #include "extensions/common/extension.h" 25 #include "extensions/common/extension.h"
26 #include "net/url_request/url_fetcher.h" 26 #include "net/url_request/url_fetcher.h"
27 #include "sync/protocol/extension_specifics.pb.h"
28 #include "sync/protocol/sync.pb.h"
27 29
28 using extensions::Extension; 30 using extensions::Extension;
29 using extensions::ExtensionRegistry; 31 using extensions::ExtensionRegistry;
30 using extensions::ExtensionPrefs; 32 using extensions::ExtensionPrefs;
31 33
32 class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest { 34 class ExtensionDisabledGlobalErrorTest : public ExtensionBrowserTest {
33 protected: 35 protected:
34 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 36 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
35 ExtensionBrowserTest::SetUpCommandLine(command_line); 37 ExtensionBrowserTest::SetUpCommandLine(command_line);
36 command_line->AppendSwitchASCII(switches::kAppsGalleryUpdateURL, 38 command_line->AppendSwitchASCII(switches::kAppsGalleryUpdateURL,
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 229
228 extension = service_->GetExtensionById(extension_id, true); 230 extension = service_->GetExtensionById(extension_id, true);
229 ASSERT_TRUE(extension); 231 ASSERT_TRUE(extension);
230 EXPECT_EQ("2", extension->VersionString()); 232 EXPECT_EQ("2", extension->VersionString());
231 EXPECT_EQ(1u, registry_->disabled_extensions().size()); 233 EXPECT_EQ(1u, registry_->disabled_extensions().size());
232 EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE, 234 EXPECT_EQ(Extension::DISABLE_PERMISSIONS_INCREASE,
233 ExtensionPrefs::Get(service_->profile()) 235 ExtensionPrefs::Get(service_->profile())
234 ->GetDisableReasons(extension_id)); 236 ->GetDisableReasons(extension_id));
235 EXPECT_TRUE(GetExtensionDisabledGlobalError()); 237 EXPECT_TRUE(GetExtensionDisabledGlobalError());
236 } 238 }
239
240 // Test that an error appears if an extension gets installed server side.
241 IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, RemoteInstall) {
242 static const char* extension_id = "pgdpcfcocojkjfbgpiianjngphoopgmo";
243 ExtensionSyncService* sync_service =
244 ExtensionSyncService::Get(browser()->profile());
245
246 // Note: This interceptor gets requests on the IO thread.
247 content::URLLocalHostRequestPrepackagedInterceptor interceptor;
248 net::URLFetcher::SetEnableInterceptionForTests(true);
249 interceptor.SetResponseIgnoreQuery(
250 GURL("http://localhost/autoupdate/updates.xml"),
251 test_data_dir_.AppendASCII("permissions_increase")
252 .AppendASCII("updates.xml"));
253 interceptor.SetResponseIgnoreQuery(
254 GURL("http://localhost/autoupdate/v2.crx"),
255 scoped_temp_dir_.path().AppendASCII("permissions2.crx"));
256
257 extensions::ExtensionUpdater::CheckParams params;
258 service_->updater()->set_default_check_params(params);
259
260 sync_pb::EntitySpecifics specifics;
261 specifics.mutable_extension()->set_id(extension_id);
262 specifics.mutable_extension()->set_enabled(false);
263 specifics.mutable_extension()->set_remote_install(true);
264 specifics.mutable_extension()->set_update_url(
265 "http://localhost/autoupdate/updates.xml");
266 specifics.mutable_extension()->set_version("2");
267 syncer::SyncData sync_data =
268 syncer::SyncData::CreateRemoteData(1234567,
269 specifics,
270 base::Time::Now(),
271 syncer::AttachmentIdList(),
272 syncer::AttachmentServiceProxy());
273 // Sync is installing a new extension, so it pends.
274 EXPECT_FALSE(sync_service->ProcessExtensionSyncData(
275 extensions::ExtensionSyncData(sync_data)));
276
277 WaitForExtensionInstall();
278 content::BrowserThread::GetBlockingPool()->FlushForTesting();
279 base::RunLoop().RunUntilIdle();
280
281 const Extension* extension = service_->GetExtensionById(extension_id, true);
282 ASSERT_TRUE(extension);
283 EXPECT_EQ("2", extension->VersionString());
284 EXPECT_EQ(1u, registry_->disabled_extensions().size());
285 EXPECT_EQ(Extension::DISABLE_REMOTE_INSTALL |
286 Extension::DISABLE_PERMISSIONS_INCREASE,
287 ExtensionPrefs::Get(service_->profile())
288 ->GetDisableReasons(extension_id));
289 EXPECT_TRUE(GetExtensionDisabledGlobalError());
290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698