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

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

Issue 1165913002: [Cleanup] Used scoped pointers in KeyedServiceFactory's SetTestingFactory functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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/extensions/test_extension_system.h" 5 #include "chrome/browser/extensions/test_extension_system.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/extensions/blacklist.h" 9 #include "chrome/browser/extensions/blacklist.h"
10 #include "chrome/browser/extensions/extension_management.h" 10 #include "chrome/browser/extensions/extension_management.h"
(...skipping 26 matching lines...) Expand all
37 quota_service_(new QuotaService()) {} 37 quota_service_(new QuotaService()) {}
38 38
39 TestExtensionSystem::~TestExtensionSystem() { 39 TestExtensionSystem::~TestExtensionSystem() {
40 } 40 }
41 41
42 void TestExtensionSystem::Shutdown() { 42 void TestExtensionSystem::Shutdown() {
43 if (extension_service_) 43 if (extension_service_)
44 extension_service_->Shutdown(); 44 extension_service_->Shutdown();
45 } 45 }
46 46
47 ExtensionPrefs* TestExtensionSystem::CreateExtensionPrefs( 47 scoped_ptr<ExtensionPrefs> TestExtensionSystem::CreateExtensionPrefs(
48 const base::CommandLine* command_line, 48 const base::CommandLine* command_line,
49 const base::FilePath& install_directory) { 49 const base::FilePath& install_directory) {
50 bool extensions_disabled = 50 bool extensions_disabled =
51 command_line && command_line->HasSwitch(switches::kDisableExtensions); 51 command_line && command_line->HasSwitch(switches::kDisableExtensions);
52 52
53 // Note that the GetPrefs() creates a TestingPrefService, therefore 53 // Note that the GetPrefs() creates a TestingPrefService, therefore
54 // the extension controlled pref values set in ExtensionPrefs 54 // the extension controlled pref values set in ExtensionPrefs
55 // are not reflected in the pref service. One would need to 55 // are not reflected in the pref service. One would need to
56 // inject a new ExtensionPrefStore(extension_pref_value_map, false). 56 // inject a new ExtensionPrefStore(extension_pref_value_map, false).
57 57
58 return ExtensionPrefs::Create( 58 return make_scoped_ptr(ExtensionPrefs::Create(
59 profile_->GetPrefs(), install_directory, 59 profile_->GetPrefs(), install_directory,
60 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_), 60 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_),
61 ExtensionsBrowserClient::Get()->CreateAppSorting().Pass(), 61 ExtensionsBrowserClient::Get()->CreateAppSorting().Pass(),
62 extensions_disabled, std::vector<ExtensionPrefsObserver*>()); 62 extensions_disabled, std::vector<ExtensionPrefsObserver*>()));
63 } 63 }
64 64
65 ExtensionService* TestExtensionSystem::CreateExtensionService( 65 ExtensionService* TestExtensionSystem::CreateExtensionService(
66 const base::CommandLine* command_line, 66 const base::CommandLine* command_line,
67 const base::FilePath& install_directory, 67 const base::FilePath& install_directory,
68 bool autoupdate_enabled) { 68 bool autoupdate_enabled) {
69 // The ownership of |value_store_| is immediately transferred to state_store_, 69 // The ownership of |value_store_| is immediately transferred to state_store_,
70 // but we keep a naked pointer to the TestingValueStore. 70 // but we keep a naked pointer to the TestingValueStore.
71 scoped_ptr<TestingValueStore> value_store(new TestingValueStore()); 71 scoped_ptr<TestingValueStore> value_store(new TestingValueStore());
72 value_store_ = value_store.get(); 72 value_store_ = value_store.get();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return NULL; 130 return NULL;
131 } 131 }
132 132
133 scoped_ptr<ExtensionSet> TestExtensionSystem::GetDependentExtensions( 133 scoped_ptr<ExtensionSet> TestExtensionSystem::GetDependentExtensions(
134 const Extension* extension) { 134 const Extension* extension) {
135 return extension_service()->shared_module_service()->GetDependentExtensions( 135 return extension_service()->shared_module_service()->GetDependentExtensions(
136 extension); 136 extension);
137 } 137 }
138 138
139 // static 139 // static
140 KeyedService* TestExtensionSystem::Build(content::BrowserContext* profile) { 140 scoped_ptr<KeyedService> TestExtensionSystem::Build(
141 return new TestExtensionSystem(static_cast<Profile*>(profile)); 141 content::BrowserContext* profile) {
142 return make_scoped_ptr(
143 new TestExtensionSystem(static_cast<Profile*>(profile)));
142 } 144 }
143 145
144 } // namespace extensions 146 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698