| OLD | NEW |
| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 management_policy_->RegisterProvider( | 132 management_policy_->RegisterProvider( |
| 133 device_local_account_management_policy_provider_.get()); | 133 device_local_account_management_policy_provider_.get()); |
| 134 } | 134 } |
| 135 #endif // defined (OS_CHROMEOS) | 135 #endif // defined (OS_CHROMEOS) |
| 136 | 136 |
| 137 management_policy_->RegisterProvider(install_verifier_.get()); | 137 management_policy_->RegisterProvider(install_verifier_.get()); |
| 138 | 138 |
| 139 #endif // defined(ENABLE_EXTENSIONS) | 139 #endif // defined(ENABLE_EXTENSIONS) |
| 140 } | 140 } |
| 141 | 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 | |
| 148 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { | 142 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { |
| 149 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 143 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 150 | 144 |
| 151 navigation_observer_.reset(new NavigationObserver(profile_)); | 145 navigation_observer_.reset(new NavigationObserver(profile_)); |
| 152 | 146 |
| 153 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs); | 147 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs); |
| 154 ExtensionErrorReporter::Init(allow_noisy_errors); | 148 ExtensionErrorReporter::Init(allow_noisy_errors); |
| 155 | 149 |
| 156 user_script_master_ = new UserScriptMaster(profile_); | 150 user_script_master_ = new UserScriptMaster(profile_); |
| 157 | 151 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 172 autoupdate_enabled, | 166 autoupdate_enabled, |
| 173 extensions_enabled, | 167 extensions_enabled, |
| 174 &ready_)); | 168 &ready_)); |
| 175 | 169 |
| 176 // These services must be registered before the ExtensionService tries to | 170 // These services must be registered before the ExtensionService tries to |
| 177 // load any extensions. | 171 // load any extensions. |
| 178 { | 172 { |
| 179 install_verifier_.reset( | 173 install_verifier_.reset( |
| 180 new InstallVerifier(ExtensionPrefs::Get(profile_), profile_)); | 174 new InstallVerifier(ExtensionPrefs::Get(profile_), profile_)); |
| 181 install_verifier_->Init(); | 175 install_verifier_->Init(); |
| 182 ContentVerifierFilter filter = base::Bind(&ShouldVerifyExtensionContent); | 176 content_verifier_ = new ContentVerifier(profile_, extension_service_.get()); |
| 183 content_verifier_ = new ContentVerifier(profile_, filter); | |
| 184 content_verifier_->AddObserver(extension_service_.get()); | |
| 185 content_verifier_->Start(); | 177 content_verifier_->Start(); |
| 186 info_map()->SetContentVerifier(content_verifier_.get()); | 178 info_map()->SetContentVerifier(content_verifier_.get()); |
| 187 | 179 |
| 188 management_policy_.reset(new ManagementPolicy); | 180 management_policy_.reset(new ManagementPolicy); |
| 189 RegisterManagementPolicyProviders(); | 181 RegisterManagementPolicyProviders(); |
| 190 } | 182 } |
| 191 | 183 |
| 192 bool skip_session_extensions = false; | 184 bool skip_session_extensions = false; |
| 193 #if defined(OS_CHROMEOS) | 185 #if defined(OS_CHROMEOS) |
| 194 // Skip loading session extensions if we are not in a user session. | 186 // Skip loading session extensions if we are not in a user session. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 242 } |
| 251 } | 243 } |
| 252 } | 244 } |
| 253 | 245 |
| 254 void ExtensionSystemImpl::Shared::Shutdown() { | 246 void ExtensionSystemImpl::Shared::Shutdown() { |
| 255 if (extension_warning_service_) { | 247 if (extension_warning_service_) { |
| 256 extension_warning_service_->RemoveObserver( | 248 extension_warning_service_->RemoveObserver( |
| 257 extension_warning_badge_service_.get()); | 249 extension_warning_badge_service_.get()); |
| 258 } | 250 } |
| 259 if (content_verifier_) { | 251 if (content_verifier_) { |
| 260 if (extension_service_) | |
| 261 content_verifier_->RemoveObserver(extension_service_.get()); | |
| 262 content_verifier_->Shutdown(); | 252 content_verifier_->Shutdown(); |
| 263 } | 253 } |
| 264 | 254 |
| 265 if (extension_service_) | 255 if (extension_service_) |
| 266 extension_service_->Shutdown(); | 256 extension_service_->Shutdown(); |
| 267 } | 257 } |
| 268 | 258 |
| 269 StateStore* ExtensionSystemImpl::Shared::state_store() { | 259 StateStore* ExtensionSystemImpl::Shared::state_store() { |
| 270 return state_store_.get(); | 260 return state_store_.get(); |
| 271 } | 261 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( | 451 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( |
| 462 const std::string& extension_id, | 452 const std::string& extension_id, |
| 463 const UnloadedExtensionInfo::Reason reason) { | 453 const UnloadedExtensionInfo::Reason reason) { |
| 464 BrowserThread::PostTask( | 454 BrowserThread::PostTask( |
| 465 BrowserThread::IO, | 455 BrowserThread::IO, |
| 466 FROM_HERE, | 456 FROM_HERE, |
| 467 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); | 457 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); |
| 468 } | 458 } |
| 469 | 459 |
| 470 } // namespace extensions | 460 } // namespace extensions |
| OLD | NEW |