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

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

Issue 266963003: Beginning of support for extension content verification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged latest trunk Created 6 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_impl.h" 5 #include "chrome/browser/extensions/extension_system_impl.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/extensions/standard_management_policy_provider.h" 25 #include "chrome/browser/extensions/standard_management_policy_provider.h"
26 #include "chrome/browser/extensions/state_store.h" 26 #include "chrome/browser/extensions/state_store.h"
27 #include "chrome/browser/extensions/unpacked_installer.h" 27 #include "chrome/browser/extensions/unpacked_installer.h"
28 #include "chrome/browser/extensions/user_script_master.h" 28 #include "chrome/browser/extensions/user_script_master.h"
29 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/browser/profiles/profile_manager.h" 30 #include "chrome/browser/profiles/profile_manager.h"
31 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 31 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
32 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/chrome_version_info.h" 33 #include "chrome/common/chrome_version_info.h"
34 #include "chrome/common/extensions/features/feature_channel.h" 34 #include "chrome/common/extensions/features/feature_channel.h"
35 #include "chrome/common/extensions/manifest_url_handler.h"
35 #include "content/public/browser/browser_thread.h" 36 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/url_data_source.h" 37 #include "content/public/browser/url_data_source.h"
38 #include "extensions/browser/content_verifier.h"
37 #include "extensions/browser/event_router.h" 39 #include "extensions/browser/event_router.h"
38 #include "extensions/browser/extension_pref_store.h" 40 #include "extensions/browser/extension_pref_store.h"
39 #include "extensions/browser/extension_pref_value_map.h" 41 #include "extensions/browser/extension_pref_value_map.h"
40 #include "extensions/browser/extension_pref_value_map_factory.h" 42 #include "extensions/browser/extension_pref_value_map_factory.h"
41 #include "extensions/browser/extension_prefs.h" 43 #include "extensions/browser/extension_prefs.h"
42 #include "extensions/browser/extension_registry.h" 44 #include "extensions/browser/extension_registry.h"
43 #include "extensions/browser/info_map.h" 45 #include "extensions/browser/info_map.h"
44 #include "extensions/browser/lazy_background_task_queue.h" 46 #include "extensions/browser/lazy_background_task_queue.h"
45 #include "extensions/browser/management_policy.h" 47 #include "extensions/browser/management_policy.h"
46 #include "extensions/browser/process_manager.h" 48 #include "extensions/browser/process_manager.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 management_policy_->RegisterProvider( 132 management_policy_->RegisterProvider(
131 device_local_account_management_policy_provider_.get()); 133 device_local_account_management_policy_provider_.get());
132 } 134 }
133 #endif // defined (OS_CHROMEOS) 135 #endif // defined (OS_CHROMEOS)
134 136
135 management_policy_->RegisterProvider(install_verifier_.get()); 137 management_policy_->RegisterProvider(install_verifier_.get());
136 138
137 #endif // defined(ENABLE_EXTENSIONS) 139 #endif // defined(ENABLE_EXTENSIONS)
138 } 140 }
139 141
142 static bool ShouldVerifyExtensionContent(const Extension* extension) {
143 return ((extension->is_extension() || extension->is_legacy_packaged_app()) &&
144 ManifestURL::UpdatesFromGallery(extension) &&
145 Manifest::IsAutoUpdateableLocation(extension->location()));
146 }
147
140 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { 148 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) {
141 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 149 const CommandLine* command_line = CommandLine::ForCurrentProcess();
142 150
143 navigation_observer_.reset(new NavigationObserver(profile_)); 151 navigation_observer_.reset(new NavigationObserver(profile_));
144 152
145 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs); 153 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs);
146 ExtensionErrorReporter::Init(allow_noisy_errors); 154 ExtensionErrorReporter::Init(allow_noisy_errors);
147 155
148 user_script_master_ = new UserScriptMaster(profile_); 156 user_script_master_ = new UserScriptMaster(profile_);
149 157
(...skipping 14 matching lines...) Expand all
164 autoupdate_enabled, 172 autoupdate_enabled,
165 extensions_enabled, 173 extensions_enabled,
166 &ready_)); 174 &ready_));
167 175
168 // These services must be registered before the ExtensionService tries to 176 // These services must be registered before the ExtensionService tries to
169 // load any extensions. 177 // load any extensions.
170 { 178 {
171 install_verifier_.reset( 179 install_verifier_.reset(
172 new InstallVerifier(ExtensionPrefs::Get(profile_), profile_)); 180 new InstallVerifier(ExtensionPrefs::Get(profile_), profile_));
173 install_verifier_->Init(); 181 install_verifier_->Init();
182 ContentVerifierFilter filter = base::Bind(&ShouldVerifyExtensionContent);
183 content_verifier_ = new ContentVerifier(profile_, filter);
184 content_verifier_->AddObserver(extension_service_.get());
185 content_verifier_->Start();
186 info_map()->SetContentVerifier(content_verifier_.get());
174 187
175 management_policy_.reset(new ManagementPolicy); 188 management_policy_.reset(new ManagementPolicy);
176 RegisterManagementPolicyProviders(); 189 RegisterManagementPolicyProviders();
177 } 190 }
178 191
179 bool skip_session_extensions = false; 192 bool skip_session_extensions = false;
180 #if defined(OS_CHROMEOS) 193 #if defined(OS_CHROMEOS)
181 // Skip loading session extensions if we are not in a user session. 194 // Skip loading session extensions if we are not in a user session.
182 skip_session_extensions = !chromeos::LoginState::Get()->IsUserLoggedIn(); 195 skip_session_extensions = !chromeos::LoginState::Get()->IsUserLoggedIn();
183 if (chrome::IsRunningInForcedAppMode()) { 196 if (chrome::IsRunningInForcedAppMode()) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 249 }
237 } 250 }
238 } 251 }
239 } 252 }
240 253
241 void ExtensionSystemImpl::Shared::Shutdown() { 254 void ExtensionSystemImpl::Shared::Shutdown() {
242 if (extension_warning_service_) { 255 if (extension_warning_service_) {
243 extension_warning_service_->RemoveObserver( 256 extension_warning_service_->RemoveObserver(
244 extension_warning_badge_service_.get()); 257 extension_warning_badge_service_.get());
245 } 258 }
259 if (content_verifier_) {
260 if (extension_service_)
261 content_verifier_->RemoveObserver(extension_service_.get());
262 content_verifier_->Shutdown();
263 }
264
246 if (extension_service_) 265 if (extension_service_)
247 extension_service_->Shutdown(); 266 extension_service_->Shutdown();
248 } 267 }
249 268
250 StateStore* ExtensionSystemImpl::Shared::state_store() { 269 StateStore* ExtensionSystemImpl::Shared::state_store() {
251 return state_store_.get(); 270 return state_store_.get();
252 } 271 }
253 272
254 StateStore* ExtensionSystemImpl::Shared::rules_store() { 273 StateStore* ExtensionSystemImpl::Shared::rules_store() {
255 return rules_store_.get(); 274 return rules_store_.get();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 318 }
300 319
301 InstallVerifier* ExtensionSystemImpl::Shared::install_verifier() { 320 InstallVerifier* ExtensionSystemImpl::Shared::install_verifier() {
302 return install_verifier_.get(); 321 return install_verifier_.get();
303 } 322 }
304 323
305 QuotaService* ExtensionSystemImpl::Shared::quota_service() { 324 QuotaService* ExtensionSystemImpl::Shared::quota_service() {
306 return quota_service_.get(); 325 return quota_service_.get();
307 } 326 }
308 327
328 ContentVerifier* ExtensionSystemImpl::Shared::content_verifier() {
329 return content_verifier_.get();
330 }
331
309 // 332 //
310 // ExtensionSystemImpl 333 // ExtensionSystemImpl
311 // 334 //
312 335
313 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) 336 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile)
314 : profile_(profile) { 337 : profile_(profile) {
315 shared_ = ExtensionSystemSharedFactory::GetForBrowserContext(profile); 338 shared_ = ExtensionSystemSharedFactory::GetForBrowserContext(profile);
316 339
317 if (profile->IsOffTheRecord()) { 340 if (profile->IsOffTheRecord()) {
318 process_manager_.reset(ProcessManager::Create(profile)); 341 process_manager_.reset(ProcessManager::Create(profile));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 419 }
397 420
398 InstallVerifier* ExtensionSystemImpl::install_verifier() { 421 InstallVerifier* ExtensionSystemImpl::install_verifier() {
399 return shared_->install_verifier(); 422 return shared_->install_verifier();
400 } 423 }
401 424
402 QuotaService* ExtensionSystemImpl::quota_service() { 425 QuotaService* ExtensionSystemImpl::quota_service() {
403 return shared_->quota_service(); 426 return shared_->quota_service();
404 } 427 }
405 428
429 ContentVerifier* ExtensionSystemImpl::content_verifier() {
430 return shared_->content_verifier();
431 }
432
406 void ExtensionSystemImpl::RegisterExtensionWithRequestContexts( 433 void ExtensionSystemImpl::RegisterExtensionWithRequestContexts(
407 const Extension* extension) { 434 const Extension* extension) {
408 base::Time install_time; 435 base::Time install_time;
409 if (extension->location() != Manifest::COMPONENT) { 436 if (extension->location() != Manifest::COMPONENT) {
410 install_time = ExtensionPrefs::Get(profile_)-> 437 install_time = ExtensionPrefs::Get(profile_)->
411 GetInstallTime(extension->id()); 438 GetInstallTime(extension->id());
412 } 439 }
413 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_); 440 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_);
414 441
415 bool notifications_disabled = false; 442 bool notifications_disabled = false;
(...skipping 18 matching lines...) Expand all
434 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( 461 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts(
435 const std::string& extension_id, 462 const std::string& extension_id,
436 const UnloadedExtensionInfo::Reason reason) { 463 const UnloadedExtensionInfo::Reason reason) {
437 BrowserThread::PostTask( 464 BrowserThread::PostTask(
438 BrowserThread::IO, 465 BrowserThread::IO,
439 FROM_HERE, 466 FROM_HERE,
440 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); 467 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason));
441 } 468 }
442 469
443 } // namespace extensions 470 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_system_impl.h ('k') | chrome/browser/extensions/test_extension_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698