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

Side by Side Diff: chrome/browser/sync/test/integration/sync_extension_helper.cc

Issue 10541126: Cleaning Up Extensions When Local Content Removed (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master merge Created 8 years, 6 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
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 "chrome/browser/sync/test/integration/sync_extension_helper.h" 5 #include "chrome/browser/sync/test/integration/sync_extension_helper.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_system.h" 12 #include "chrome/browser/extensions/extension_system.h"
13 #include "chrome/browser/extensions/pending_extension_info.h" 13 #include "chrome/browser/extensions/pending_extension_info.h"
14 #include "chrome/browser/extensions/pending_extension_manager.h" 14 #include "chrome/browser/extensions/pending_extension_manager.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/extension_manifest_constants.h" 17 #include "chrome/common/extensions/extension_manifest_constants.h"
18 #include "chrome/common/string_ordinal.h" 18 #include "chrome/common/string_ordinal.h"
19 #include "chrome/browser/sync/test/integration/sync_test.h" 19 #include "chrome/browser/sync/test/integration/sync_test.h"
20 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 20 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
21 #include "chrome/test/base/ui_test_utils.h"
22 #include "content/public/browser/browser_thread.h"
21 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
22 24
23 using extensions::Extension; 25 using extensions::Extension;
24 26
25 SyncExtensionHelper::ExtensionState::ExtensionState() 27 SyncExtensionHelper::ExtensionState::ExtensionState()
26 : enabled_state(ENABLED), incognito_enabled(false) {} 28 : enabled_state(ENABLED), incognito_enabled(false) {}
27 29
28 SyncExtensionHelper::ExtensionState::~ExtensionState() {} 30 SyncExtensionHelper::ExtensionState::~ExtensionState() {}
29 31
30 bool SyncExtensionHelper::ExtensionState::Equals( 32 bool SyncExtensionHelper::ExtensionState::Equals(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 setup_completed_ = true; 65 setup_completed_ = true;
64 } 66 }
65 67
66 std::string SyncExtensionHelper::InstallExtension( 68 std::string SyncExtensionHelper::InstallExtension(
67 Profile* profile, const std::string& name, Extension::Type type) { 69 Profile* profile, const std::string& name, Extension::Type type) {
68 scoped_refptr<Extension> extension = GetExtension(profile, name, type); 70 scoped_refptr<Extension> extension = GetExtension(profile, name, type);
69 if (!extension.get()) { 71 if (!extension.get()) {
70 NOTREACHED() << "Could not install extension " << name; 72 NOTREACHED() << "Could not install extension " << name;
71 return ""; 73 return "";
72 } 74 }
75 // extensions::ExtensionGarbageCollector requires that there be a file present
76 // on the file system for all extensions; we mimic this here. This also better
77 // simulates the actual install process.
78 content::BrowserThread::PostTask(
79 content::BrowserThread::FILE, FROM_HERE,
80 base::Bind(
81 base::IgnoreResult(&file_util::CreateDirectory),
82 profile->GetExtensionService()->install_directory()
83 .AppendASCII(extension->id())));
84 ui_test_utils::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
73 profile->GetExtensionService()->OnExtensionInstalled( 85 profile->GetExtensionService()->OnExtensionInstalled(
74 extension, extension->UpdatesFromGallery(), StringOrdinal()); 86 extension, extension->UpdatesFromGallery(), StringOrdinal());
75 return extension->id(); 87 return extension->id();
76 } 88 }
77 89
78 void SyncExtensionHelper::UninstallExtension( 90 void SyncExtensionHelper::UninstallExtension(
79 Profile* profile, const std::string& name) { 91 Profile* profile, const std::string& name) {
80 ExtensionService::UninstallExtensionHelper(profile->GetExtensionService(), 92 ExtensionService::UninstallExtensionHelper(profile->GetExtensionService(),
81 NameToId(name)); 93 NameToId(name));
82 } 94 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 if (extension->id() != expected_id) { 358 if (extension->id() != expected_id) {
347 EXPECT_EQ(expected_id, extension->id()); 359 EXPECT_EQ(expected_id, extension->id());
348 return NULL; 360 return NULL;
349 } 361 }
350 DVLOG(2) << "created extension with name = " 362 DVLOG(2) << "created extension with name = "
351 << name << ", id = " << expected_id; 363 << name << ", id = " << expected_id;
352 (it->second)[name] = extension; 364 (it->second)[name] = extension;
353 id_to_name_[expected_id] = name; 365 id_to_name_[expected_id] = name;
354 return extension; 366 return extension;
355 } 367 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698