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

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

Issue 10579028: Revert 142427 - Cleaning Up Extensions When Local Content Removed (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1180/src/
Patch Set: 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 | 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 "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"
23 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
24 22
25 using extensions::Extension; 23 using extensions::Extension;
26 24
27 SyncExtensionHelper::ExtensionState::ExtensionState() 25 SyncExtensionHelper::ExtensionState::ExtensionState()
28 : enabled_state(ENABLED), incognito_enabled(false) {} 26 : enabled_state(ENABLED), incognito_enabled(false) {}
29 27
30 SyncExtensionHelper::ExtensionState::~ExtensionState() {} 28 SyncExtensionHelper::ExtensionState::~ExtensionState() {}
31 29
32 bool SyncExtensionHelper::ExtensionState::Equals( 30 bool SyncExtensionHelper::ExtensionState::Equals(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 setup_completed_ = true; 63 setup_completed_ = true;
66 } 64 }
67 65
68 std::string SyncExtensionHelper::InstallExtension( 66 std::string SyncExtensionHelper::InstallExtension(
69 Profile* profile, const std::string& name, Extension::Type type) { 67 Profile* profile, const std::string& name, Extension::Type type) {
70 scoped_refptr<Extension> extension = GetExtension(profile, name, type); 68 scoped_refptr<Extension> extension = GetExtension(profile, name, type);
71 if (!extension.get()) { 69 if (!extension.get()) {
72 NOTREACHED() << "Could not install extension " << name; 70 NOTREACHED() << "Could not install extension " << name;
73 return ""; 71 return "";
74 } 72 }
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);
85 profile->GetExtensionService()->OnExtensionInstalled( 73 profile->GetExtensionService()->OnExtensionInstalled(
86 extension, extension->UpdatesFromGallery(), StringOrdinal()); 74 extension, extension->UpdatesFromGallery(), StringOrdinal());
87 return extension->id(); 75 return extension->id();
88 } 76 }
89 77
90 void SyncExtensionHelper::UninstallExtension( 78 void SyncExtensionHelper::UninstallExtension(
91 Profile* profile, const std::string& name) { 79 Profile* profile, const std::string& name) {
92 ExtensionService::UninstallExtensionHelper(profile->GetExtensionService(), 80 ExtensionService::UninstallExtensionHelper(profile->GetExtensionService(),
93 NameToId(name)); 81 NameToId(name));
94 } 82 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 if (extension->id() != expected_id) { 346 if (extension->id() != expected_id) {
359 EXPECT_EQ(expected_id, extension->id()); 347 EXPECT_EQ(expected_id, extension->id());
360 return NULL; 348 return NULL;
361 } 349 }
362 DVLOG(2) << "created extension with name = " 350 DVLOG(2) << "created extension with name = "
363 << name << ", id = " << expected_id; 351 << name << ", id = " << expected_id;
364 (it->second)[name] = extension; 352 (it->second)[name] = extension;
365 id_to_name_[expected_id] = name; 353 id_to_name_[expected_id] = name;
366 return extension; 354 return extension;
367 } 355 }
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