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

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

Issue 11232066: Remove GetExtensionEventRouter from Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rerebase Created 8 years, 1 month 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/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/settings/settings_frontend.h" 10 #include "chrome/browser/extensions/settings/settings_frontend.h"
10 11
11 namespace extensions { 12 namespace extensions {
12 13
13 namespace settings_test_util { 14 namespace settings_test_util {
14 15
15 // Intended as a StorageCallback from GetStorage. 16 // Intended as a StorageCallback from GetStorage.
16 static void AssignStorage(ValueStore** dst, ValueStore* src) { 17 static void AssignStorage(ValueStore** dst, ValueStore* src) {
17 *dst = src; 18 *dst = src;
18 } 19 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 DCHECK(extension.get()); 99 DCHECK(extension.get());
99 DCHECK(error.empty()); 100 DCHECK(error.empty());
100 extensions_[id] = extension; 101 extensions_[id] = extension;
101 102
102 for (std::set<std::string>::const_iterator it = permissions_set.begin(); 103 for (std::set<std::string>::const_iterator it = permissions_set.begin();
103 it != permissions_set.end(); ++it) { 104 it != permissions_set.end(); ++it) {
104 DCHECK(extension->HasAPIPermission(*it)); 105 DCHECK(extension->HasAPIPermission(*it));
105 } 106 }
106 } 107 }
107 108
109 // MockExtensionSystem
110
111 MockExtensionSystem::MockExtensionSystem(Profile* profile)
112 : TestExtensionSystem(profile) {}
113 MockExtensionSystem::~MockExtensionSystem() {}
114
115 EventRouter* MockExtensionSystem::event_router() {
116 if (!event_router_.get())
117 event_router_.reset(new EventRouter(profile_, NULL));
118 return event_router_.get();
119 }
120
121 ProfileKeyedService* BuildMockExtensionSystem(Profile* profile) {
122 return new MockExtensionSystem(profile);
123 }
124
108 // MockProfile 125 // MockProfile
109 126
110 MockProfile::MockProfile(const FilePath& file_path) 127 MockProfile::MockProfile(const FilePath& file_path)
111 : TestingProfile(file_path) { 128 : TestingProfile(file_path) {
112 event_router_.reset(new EventRouter(this, NULL)); 129 ExtensionSystemFactory::GetInstance()->SetTestingFactoryAndUse(this,
130 &BuildMockExtensionSystem);
113 } 131 }
114 132
115 MockProfile::~MockProfile() {} 133 MockProfile::~MockProfile() {}
116 134
117 MockExtensionService* MockProfile::GetMockExtensionService() { 135 MockExtensionService* MockProfile::GetMockExtensionService() {
118 return &extension_service_; 136 return &extension_service_;
119 } 137 }
120 138
121 ExtensionService* MockProfile::GetExtensionService() { 139 ExtensionService* MockProfile::GetExtensionService() {
122 ExtensionServiceInterface* as_interface = 140 ExtensionServiceInterface* as_interface =
123 static_cast<ExtensionServiceInterface*>(&extension_service_); 141 static_cast<ExtensionServiceInterface*>(&extension_service_);
124 return static_cast<ExtensionService*>(as_interface); 142 return static_cast<ExtensionService*>(as_interface);
125 } 143 }
126 144
127 EventRouter* MockProfile::GetExtensionEventRouter() {
128 return event_router_.get();
129 }
130
131 // ScopedSettingsFactory 145 // ScopedSettingsFactory
132 146
133 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory() {} 147 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory() {}
134 148
135 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory( 149 ScopedSettingsStorageFactory::ScopedSettingsStorageFactory(
136 const scoped_refptr<SettingsStorageFactory>& delegate) 150 const scoped_refptr<SettingsStorageFactory>& delegate)
137 : delegate_(delegate) {} 151 : delegate_(delegate) {}
138 152
139 ScopedSettingsStorageFactory::~ScopedSettingsStorageFactory() {} 153 ScopedSettingsStorageFactory::~ScopedSettingsStorageFactory() {}
140 154
141 void ScopedSettingsStorageFactory::Reset( 155 void ScopedSettingsStorageFactory::Reset(
142 const scoped_refptr<SettingsStorageFactory>& delegate) { 156 const scoped_refptr<SettingsStorageFactory>& delegate) {
143 delegate_ = delegate; 157 delegate_ = delegate;
144 } 158 }
145 159
146 ValueStore* ScopedSettingsStorageFactory::Create( 160 ValueStore* ScopedSettingsStorageFactory::Create(
147 const FilePath& base_path, const std::string& extension_id) { 161 const FilePath& base_path, const std::string& extension_id) {
148 DCHECK(delegate_.get()); 162 DCHECK(delegate_.get());
149 return delegate_->Create(base_path, extension_id); 163 return delegate_->Create(base_path, extension_id);
150 } 164 }
151 165
152 } // namespace settings_test_util 166 } // namespace settings_test_util
153 167
154 } // namespace extensions 168 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/settings/settings_test_util.h ('k') | chrome/browser/extensions/test_extension_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698