OLD | NEW |
---|---|
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/extension_system.h" | 5 #include "chrome/browser/extensions/extension_system.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/string_tokenizer.h" | 10 #include "base/string_tokenizer.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 ExtensionSystem* ExtensionSystem::Get(Profile* profile) { | 64 ExtensionSystem* ExtensionSystem::Get(Profile* profile) { |
65 return ExtensionSystemFactory::GetForProfile(profile); | 65 return ExtensionSystemFactory::GetForProfile(profile); |
66 } | 66 } |
67 | 67 |
68 // | 68 // |
69 // ExtensionSystemImpl::Shared | 69 // ExtensionSystemImpl::Shared |
70 // | 70 // |
71 | 71 |
72 ExtensionSystemImpl::Shared::Shared(Profile* profile) | 72 ExtensionSystemImpl::Shared::Shared(Profile* profile) |
73 : profile_(profile) { | 73 : profile_(profile) { |
74 event_router_.reset(new EventRouter(profile_)); | |
Aaron Boodman
2012/11/07 23:51:28
Why not make it part of the initializer list?
Yoyo Zhou
2012/11/08 00:18:16
See below.
| |
74 } | 75 } |
75 | 76 |
76 ExtensionSystemImpl::Shared::~Shared() { | 77 ExtensionSystemImpl::Shared::~Shared() { |
77 } | 78 } |
78 | 79 |
79 void ExtensionSystemImpl::Shared::InitPrefs() { | 80 void ExtensionSystemImpl::Shared::InitPrefs() { |
80 bool extensions_disabled = | 81 bool extensions_disabled = |
81 profile_->GetPrefs()->GetBoolean(prefs::kDisableExtensions) || | 82 profile_->GetPrefs()->GetBoolean(prefs::kDisableExtensions) || |
82 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensions); | 83 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableExtensions); |
83 extension_prefs_.reset(new ExtensionPrefs( | 84 extension_prefs_.reset(new ExtensionPrefs( |
84 profile_->GetPrefs(), | 85 profile_->GetPrefs(), |
85 profile_->GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), | 86 profile_->GetPath().AppendASCII(ExtensionService::kInstallDirectoryName), |
86 ExtensionPrefValueMapFactory::GetForProfile(profile_))); | 87 ExtensionPrefValueMapFactory::GetForProfile(profile_))); |
87 extension_prefs_->Init(extensions_disabled); | 88 extension_prefs_->Init(extensions_disabled); |
89 // Tell the EventRouter that ExtensionPrefs are ready. | |
90 event_router_->InitWithPrefs(extension_prefs_.get()); | |
Aaron Boodman
2012/11/07 23:51:28
Shared::InitPrefs() is called in the constructor.
Yoyo Zhou
2012/11/08 00:18:16
Yes, I was misinterpreting what was going on. I'll
| |
88 | 91 |
89 state_store_.reset(new StateStore( | 92 state_store_.reset(new StateStore( |
90 profile_, | 93 profile_, |
91 profile_->GetPath().AppendASCII(ExtensionService::kStateStoreName))); | 94 profile_->GetPath().AppendASCII(ExtensionService::kStateStoreName))); |
92 | 95 |
93 shell_window_geometry_cache_.reset(new ShellWindowGeometryCache( | 96 shell_window_geometry_cache_.reset(new ShellWindowGeometryCache( |
94 profile_, state_store_.get())); | 97 profile_, state_store_.get())); |
95 } | 98 } |
96 | 99 |
97 void ExtensionSystemImpl::Shared::RegisterManagementPolicyProviders() { | 100 void ExtensionSystemImpl::Shared::RegisterManagementPolicyProviders() { |
98 DCHECK(extension_prefs_.get()); | 101 DCHECK(extension_prefs_.get()); |
99 management_policy_->RegisterProvider(extension_prefs_.get()); | 102 management_policy_->RegisterProvider(extension_prefs_.get()); |
100 } | 103 } |
101 | 104 |
102 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { | 105 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { |
103 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 106 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
104 | 107 |
105 lazy_background_task_queue_.reset(new LazyBackgroundTaskQueue(profile_)); | 108 lazy_background_task_queue_.reset(new LazyBackgroundTaskQueue(profile_)); |
106 message_service_.reset(new MessageService(lazy_background_task_queue_.get())); | 109 message_service_.reset(new MessageService(lazy_background_task_queue_.get())); |
107 extension_event_router_.reset(new EventRouter(profile_, | |
108 extension_prefs_.get())); | |
109 navigation_observer_.reset(new NavigationObserver(profile_)); | 110 navigation_observer_.reset(new NavigationObserver(profile_)); |
110 | 111 |
111 ExtensionErrorReporter::Init(true); // allow noisy errors. | 112 ExtensionErrorReporter::Init(true); // allow noisy errors. |
112 | 113 |
113 user_script_master_ = new UserScriptMaster(profile_); | 114 user_script_master_ = new UserScriptMaster(profile_); |
114 | 115 |
115 bool autoupdate_enabled = true; | 116 bool autoupdate_enabled = true; |
116 #if defined(OS_CHROMEOS) | 117 #if defined(OS_CHROMEOS) |
117 if (!extensions_enabled) | 118 if (!extensions_enabled) |
118 autoupdate_enabled = false; | 119 autoupdate_enabled = false; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 LazyBackgroundTaskQueue* | 231 LazyBackgroundTaskQueue* |
231 ExtensionSystemImpl::Shared::lazy_background_task_queue() { | 232 ExtensionSystemImpl::Shared::lazy_background_task_queue() { |
232 return lazy_background_task_queue_.get(); | 233 return lazy_background_task_queue_.get(); |
233 } | 234 } |
234 | 235 |
235 MessageService* ExtensionSystemImpl::Shared::message_service() { | 236 MessageService* ExtensionSystemImpl::Shared::message_service() { |
236 return message_service_.get(); | 237 return message_service_.get(); |
237 } | 238 } |
238 | 239 |
239 EventRouter* ExtensionSystemImpl::Shared::event_router() { | 240 EventRouter* ExtensionSystemImpl::Shared::event_router() { |
240 return extension_event_router_.get(); | 241 return event_router_.get(); |
241 } | 242 } |
242 | 243 |
243 // | 244 // |
244 // ExtensionSystemImpl | 245 // ExtensionSystemImpl |
245 // | 246 // |
246 | 247 |
247 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) | 248 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) |
248 : profile_(profile), | 249 : profile_(profile), |
249 extension_devtools_manager_(NULL) { | 250 extension_devtools_manager_(NULL) { |
250 shared_ = ExtensionSystemSharedFactory::GetForProfile(profile); | 251 shared_ = ExtensionSystemSharedFactory::GetForProfile(profile); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( | 394 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( |
394 const std::string& extension_id, | 395 const std::string& extension_id, |
395 const extension_misc::UnloadedExtensionReason reason) { | 396 const extension_misc::UnloadedExtensionReason reason) { |
396 BrowserThread::PostTask( | 397 BrowserThread::PostTask( |
397 BrowserThread::IO, FROM_HERE, | 398 BrowserThread::IO, FROM_HERE, |
398 base::Bind(&ExtensionInfoMap::RemoveExtension, info_map(), | 399 base::Bind(&ExtensionInfoMap::RemoveExtension, info_map(), |
399 extension_id, reason)); | 400 extension_id, reason)); |
400 } | 401 } |
401 | 402 |
402 } // namespace extensions | 403 } // namespace extensions |
OLD | NEW |