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

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

Issue 2166513002: Create --disable-extensions-except switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Patch 2 Code Review Created 4 years, 4 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
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 policy::DeviceLocalAccount::Type device_local_account_type; 123 policy::DeviceLocalAccount::Type device_local_account_type;
124 if (user && policy::IsDeviceLocalAccountUser(user->email(), 124 if (user && policy::IsDeviceLocalAccountUser(user->email(),
125 &device_local_account_type)) { 125 &device_local_account_type)) {
126 device_local_account_management_policy_provider_.reset( 126 device_local_account_management_policy_provider_.reset(
127 new chromeos::DeviceLocalAccountManagementPolicyProvider( 127 new chromeos::DeviceLocalAccountManagementPolicyProvider(
128 device_local_account_type)); 128 device_local_account_type));
129 } 129 }
130 #endif // defined(OS_CHROMEOS) 130 #endif // defined(OS_CHROMEOS)
131 } 131 }
132 132
133 void ExtensionSystemImpl::Shared::LoadExtensionsFromCommandLineFlag(
134 const base::CommandLine* command_line,
135 const char* switch_name) {
136 if (command_line->HasSwitch(switch_name)) {
137 base::CommandLine::StringType path_list =
138 command_line->GetSwitchValueNative(switch_name);
139 base::StringTokenizerT<base::CommandLine::StringType,
140 base::CommandLine::StringType::const_iterator>
141 t(path_list, FILE_PATH_LITERAL(","));
142 while (t.GetNext()) {
143 std::string extension_id;
144 UnpackedInstaller::Create(extension_service_.get())
145 ->LoadFromCommandLine(base::FilePath(t.token()), &extension_id);
146 if (std::strcmp(switch_name, switches::kDisableExtensionsExcept) == 0) {
147 extension_service_->AddExtensionToWhitelist(extension_id);
148 }
149 }
150 }
151 }
152
133 void ExtensionSystemImpl::Shared::RegisterManagementPolicyProviders() { 153 void ExtensionSystemImpl::Shared::RegisterManagementPolicyProviders() {
134 management_policy_->RegisterProviders( 154 management_policy_->RegisterProviders(
135 ExtensionManagementFactory::GetForBrowserContext(profile_) 155 ExtensionManagementFactory::GetForBrowserContext(profile_)
136 ->GetProviders()); 156 ->GetProviders());
137 157
138 #if defined(OS_CHROMEOS) 158 #if defined(OS_CHROMEOS)
139 if (device_local_account_management_policy_provider_) { 159 if (device_local_account_management_policy_provider_) {
140 management_policy_->RegisterProvider( 160 management_policy_->RegisterProvider(
141 device_local_account_management_policy_provider_.get()); 161 device_local_account_management_policy_provider_.get());
142 } 162 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 extension_service_->Init(); 276 extension_service_->Init();
257 277
258 // Make sure ExtensionSyncService is created. 278 // Make sure ExtensionSyncService is created.
259 ExtensionSyncService::Get(profile_); 279 ExtensionSyncService::Get(profile_);
260 280
261 // Make the chrome://extension-icon/ resource available. 281 // Make the chrome://extension-icon/ resource available.
262 content::URLDataSource::Add(profile_, new ExtensionIconSource(profile_)); 282 content::URLDataSource::Add(profile_, new ExtensionIconSource(profile_));
263 283
264 quota_service_.reset(new QuotaService); 284 quota_service_.reset(new QuotaService);
265 285
286 LoadExtensionsFromCommandLineFlag(command_line,
287 switches::kDisableExtensionsExcept);
288
266 if (extensions_enabled) { 289 if (extensions_enabled) {
267 // Load any extensions specified with --load-extension. 290 // Load any extensions specified with --load-extension.
268 // TODO(yoz): Seems like this should move into ExtensionService::Init. 291 // TODO(yoz): Seems like this should move into ExtensionService::Init.
Devlin 2016/07/27 17:01:00 I agree with this fairly-ancient TODO. Can we mov
catmullings 2016/08/04 22:59:31 Done.
269 // But maybe it's no longer important. 292 // But maybe it's no longer important.
270 if (command_line->HasSwitch(switches::kLoadExtension)) { 293 LoadExtensionsFromCommandLineFlag(command_line, switches::kLoadExtension);
271 base::CommandLine::StringType path_list =
272 command_line->GetSwitchValueNative(switches::kLoadExtension);
273 base::StringTokenizerT<base::CommandLine::StringType,
274 base::CommandLine::StringType::const_iterator>
275 t(path_list, FILE_PATH_LITERAL(","));
276 while (t.GetNext()) {
277 std::string extension_id;
278 UnpackedInstaller::Create(extension_service_.get())->
279 LoadFromCommandLine(base::FilePath(t.token()), &extension_id);
280 }
281 }
282 } 294 }
283 } 295 }
284 296
285 void ExtensionSystemImpl::Shared::Shutdown() { 297 void ExtensionSystemImpl::Shared::Shutdown() {
286 if (content_verifier_.get()) 298 if (content_verifier_.get())
287 content_verifier_->Shutdown(); 299 content_verifier_->Shutdown();
288 if (extension_service_) 300 if (extension_service_)
289 extension_service_->Shutdown(); 301 extension_service_->Shutdown();
290 } 302 }
291 303
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( 478 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts(
467 const std::string& extension_id, 479 const std::string& extension_id,
468 const UnloadedExtensionInfo::Reason reason) { 480 const UnloadedExtensionInfo::Reason reason) {
469 BrowserThread::PostTask( 481 BrowserThread::PostTask(
470 BrowserThread::IO, 482 BrowserThread::IO,
471 FROM_HERE, 483 FROM_HERE,
472 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); 484 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason));
473 } 485 }
474 486
475 } // namespace extensions 487 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698