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

Side by Side Diff: chrome/test/testing_browser_process.h

Issue 6312121: Add initial device policy infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix race condition and tests. Created 9 years, 10 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
« no previous file with comments | « chrome/common/pref_names.cc ('k') | chrome/test/testing_device_token_fetcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // An implementation of BrowserProcess for unit tests that fails for most 5 // An implementation of BrowserProcess for unit tests that fails for most
6 // services. By preventing creation of services, we reduce dependencies and 6 // services. By preventing creation of services, we reduce dependencies and
7 // keep the profile clean. Clients of this class must handle the NULL return 7 // keep the profile clean. Clients of this class must handle the NULL return
8 // value, however. 8 // value, however.
9 9
10 #ifndef CHROME_TEST_TESTING_BROWSER_PROCESS_H_ 10 #ifndef CHROME_TEST_TESTING_BROWSER_PROCESS_H_
11 #define CHROME_TEST_TESTING_BROWSER_PROCESS_H_ 11 #define CHROME_TEST_TESTING_BROWSER_PROCESS_H_
12 #pragma once 12 #pragma once
13 13
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 15
16 #include <string> 16 #include <string>
17 17
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/synchronization/waitable_event.h" 19 #include "base/synchronization/waitable_event.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/google/google_url_tracker.h" 21 #include "chrome/browser/google/google_url_tracker.h"
22 #include "chrome/browser/policy/browser_policy_context.h"
22 #include "chrome/browser/policy/configuration_policy_pref_store.h" 23 #include "chrome/browser/policy/configuration_policy_pref_store.h"
23 #include "chrome/browser/policy/configuration_policy_provider.h" 24 #include "chrome/browser/policy/configuration_policy_provider.h"
24 #include "chrome/browser/policy/configuration_policy_provider_keeper.h"
25 #include "chrome/browser/policy/dummy_configuration_policy_provider.h" 25 #include "chrome/browser/policy/dummy_configuration_policy_provider.h"
26 #include "chrome/browser/prefs/pref_service.h" 26 #include "chrome/browser/prefs/pref_service.h"
27 #include "chrome/common/notification_service.h" 27 #include "chrome/common/notification_service.h"
28 #include "ui/base/clipboard/clipboard.h" 28 #include "ui/base/clipboard/clipboard.h"
29 29
30 class IOThread; 30 class IOThread;
31 31
32 class TestingBrowserProcess : public BrowserProcess { 32 class TestingBrowserProcess : public BrowserProcess {
33 public: 33 public:
34 TestingBrowserProcess() 34 TestingBrowserProcess()
35 : shutdown_event_(new base::WaitableEvent(true, false)), 35 : shutdown_event_(new base::WaitableEvent(true, false)),
36 module_ref_count_(0), 36 module_ref_count_(0),
37 app_locale_("en"), 37 app_locale_("en"),
38 pref_service_(NULL), 38 pref_service_(NULL) {
39 created_configuration_policy_provider_keeper_(false) {
40 } 39 }
41 40
42 virtual ~TestingBrowserProcess() { 41 virtual ~TestingBrowserProcess() {
43 } 42 }
44 43
45 virtual void EndSession() { 44 virtual void EndSession() {
46 } 45 }
47 46
48 virtual ResourceDispatcherHost* resource_dispatcher_host() { 47 virtual ResourceDispatcherHost* resource_dispatcher_host() {
49 return NULL; 48 return NULL;
(...skipping 26 matching lines...) Expand all
76 } 75 }
77 76
78 virtual ProfileManager* profile_manager() { 77 virtual ProfileManager* profile_manager() {
79 return NULL; 78 return NULL;
80 } 79 }
81 80
82 virtual PrefService* local_state() { 81 virtual PrefService* local_state() {
83 return pref_service_; 82 return pref_service_;
84 } 83 }
85 84
86 virtual policy::ConfigurationPolicyProviderKeeper* 85 virtual policy::BrowserPolicyContext* browser_policy_context() {
87 configuration_policy_provider_keeper() { 86 if (!browser_policy_context_.get()) {
88 if (!created_configuration_policy_provider_keeper_) {
89 DCHECK(configuration_policy_provider_keeper_.get() == NULL);
90 created_configuration_policy_provider_keeper_ = true;
91 const policy::ConfigurationPolicyProvider::PolicyDefinitionList* 87 const policy::ConfigurationPolicyProvider::PolicyDefinitionList*
92 policy_list = policy::ConfigurationPolicyPrefStore:: 88 policy_list = policy::ConfigurationPolicyPrefStore::
93 GetChromePolicyDefinitionList(); 89 GetChromePolicyDefinitionList();
94 configuration_policy_provider_keeper_.reset( 90 browser_policy_context_.reset(
95 new policy::ConfigurationPolicyProviderKeeper( 91 new policy::BrowserPolicyContext(
96 new policy::DummyConfigurationPolicyProvider(policy_list),
97 new policy::DummyConfigurationPolicyProvider(policy_list), 92 new policy::DummyConfigurationPolicyProvider(policy_list),
98 new policy::DummyConfigurationPolicyProvider(policy_list))); 93 new policy::DummyConfigurationPolicyProvider(policy_list)));
99 } 94 }
100 return configuration_policy_provider_keeper_.get(); 95 return browser_policy_context_.get();
101 } 96 }
102 97
103 virtual IconManager* icon_manager() { 98 virtual IconManager* icon_manager() {
104 return NULL; 99 return NULL;
105 } 100 }
106 101
107 virtual ThumbnailGenerator* GetThumbnailGenerator() { 102 virtual ThumbnailGenerator* GetThumbnailGenerator() {
108 return NULL; 103 return NULL;
109 } 104 }
110 105
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 207 }
213 208
214 private: 209 private:
215 NotificationService notification_service_; 210 NotificationService notification_service_;
216 scoped_ptr<base::WaitableEvent> shutdown_event_; 211 scoped_ptr<base::WaitableEvent> shutdown_event_;
217 unsigned int module_ref_count_; 212 unsigned int module_ref_count_;
218 scoped_ptr<ui::Clipboard> clipboard_; 213 scoped_ptr<ui::Clipboard> clipboard_;
219 std::string app_locale_; 214 std::string app_locale_;
220 215
221 PrefService* pref_service_; 216 PrefService* pref_service_;
222 bool created_configuration_policy_provider_keeper_; 217 scoped_ptr<policy::BrowserPolicyContext> browser_policy_context_;
223 scoped_ptr<policy::ConfigurationPolicyProviderKeeper>
224 configuration_policy_provider_keeper_;
225 scoped_ptr<GoogleURLTracker> google_url_tracker_; 218 scoped_ptr<GoogleURLTracker> google_url_tracker_;
226 219
227 DISALLOW_COPY_AND_ASSIGN(TestingBrowserProcess); 220 DISALLOW_COPY_AND_ASSIGN(TestingBrowserProcess);
228 }; 221 };
229 222
230 #endif // CHROME_TEST_TESTING_BROWSER_PROCESS_H_ 223 #endif // CHROME_TEST_TESTING_BROWSER_PROCESS_H_
OLDNEW
« no previous file with comments | « chrome/common/pref_names.cc ('k') | chrome/test/testing_device_token_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698