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

Side by Side Diff: chrome/browser/extensions/settings/settings_test_util.cc

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: replace missing extension_system include Created 8 years 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/settings/settings_test_util.h" 5 #include "chrome/browser/extensions/settings/settings_test_util.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "chrome/common/extensions/extension.h" 8 #include "chrome/common/extensions/extension.h"
9 #include "chrome/browser/extensions/extension_system_factory.h" 9 #include "chrome/browser/extensions/extension_system_factory.h"
10 #include "chrome/browser/extensions/settings/settings_frontend.h" 10 #include "chrome/browser/extensions/settings/settings_frontend.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 MockExtensionSystem::MockExtensionSystem(Profile* profile) 111 MockExtensionSystem::MockExtensionSystem(Profile* profile)
112 : TestExtensionSystem(profile) {} 112 : TestExtensionSystem(profile) {}
113 MockExtensionSystem::~MockExtensionSystem() {} 113 MockExtensionSystem::~MockExtensionSystem() {}
114 114
115 EventRouter* MockExtensionSystem::event_router() { 115 EventRouter* MockExtensionSystem::event_router() {
116 if (!event_router_.get()) 116 if (!event_router_.get())
117 event_router_.reset(new EventRouter(profile_, NULL)); 117 event_router_.reset(new EventRouter(profile_, NULL));
118 return event_router_.get(); 118 return event_router_.get();
119 } 119 }
120 120
121 ExtensionService* MockExtensionSystem::extension_service() {
122 ExtensionServiceInterface* as_interface =
123 static_cast<ExtensionServiceInterface*>(&extension_service_);
124 return static_cast<ExtensionService*>(as_interface);
125 }
126
121 ProfileKeyedService* BuildMockExtensionSystem(Profile* profile) { 127 ProfileKeyedService* BuildMockExtensionSystem(Profile* profile) {
122 return new MockExtensionSystem(profile); 128 return new MockExtensionSystem(profile);
123 } 129 }
124 130
125 // MockProfile 131 // MockProfile
126 132
127 MockProfile::MockProfile(const FilePath& file_path) 133 MockProfile::MockProfile(const FilePath& file_path)
128 : TestingProfile(file_path) { 134 : TestingProfile(file_path) {
129 ExtensionSystemFactory::GetInstance()->SetTestingFactoryAndUse(this, 135 ExtensionSystemFactory::GetInstance()->SetTestingFactoryAndUse(this,
130 &BuildMockExtensionSystem); 136 &BuildMockExtensionSystem);
131 } 137 }
132 138
133 MockProfile::~MockProfile() {} 139 MockProfile::~MockProfile() {}
134 140
135 MockExtensionService* MockProfile::GetMockExtensionService() {
136 return &extension_service_;
137 }
138
139 ExtensionService* MockProfile::GetExtensionService() {
140 ExtensionServiceInterface* as_interface =
141 static_cast<ExtensionServiceInterface*>(&extension_service_);
142 return static_cast<ExtensionService*>(as_interface);
143 }
144
145 // ScopedSettingsFactory 141 // ScopedSettingsFactory
146 142
147 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory() {} 143 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory() {}
148 144
149 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory( 145 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory(
150 const scoped_refptr<SettingsStorageFactory>& delegate) 146 const scoped_refptr<SettingsStorageFactory>& delegate)
151 : delegate_(delegate) {} 147 : delegate_(delegate) {}
152 148
153 ScopedSettingsStorageFactory::~ScopedSettingsStorageFactory() {} 149 ScopedSettingsStorageFactory::~ScopedSettingsStorageFactory() {}
154 150
155 void ScopedSettingsStorageFactory::Reset( 151 void ScopedSettingsStorageFactory::Reset(
156 const scoped_refptr<SettingsStorageFactory>& delegate) { 152 const scoped_refptr<SettingsStorageFactory>& delegate) {
157 delegate_ = delegate; 153 delegate_ = delegate;
158 } 154 }
159 155
160 ValueStore* ScopedSettingsStorageFactory::Create( 156 ValueStore* ScopedSettingsStorageFactory::Create(
161 const FilePath& base_path, 157 const FilePath& base_path,
162 const std::string& extension_id) { 158 const std::string& extension_id) {
163 DCHECK(delegate_.get()); 159 DCHECK(delegate_.get());
164 return delegate_->Create(base_path, extension_id); 160 return delegate_->Create(base_path, extension_id);
165 } 161 }
166 162
167 } // namespace settings_test_util 163 } // namespace settings_test_util
168 164
169 } // namespace extensions 165 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/settings/settings_test_util.h ('k') | chrome/browser/extensions/user_script_master.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698