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

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: Added test 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 extension_service_->Init(); 256 extension_service_->Init();
257 257
258 // Make sure ExtensionSyncService is created. 258 // Make sure ExtensionSyncService is created.
259 ExtensionSyncService::Get(profile_); 259 ExtensionSyncService::Get(profile_);
260 260
261 // Make the chrome://extension-icon/ resource available. 261 // Make the chrome://extension-icon/ resource available.
262 content::URLDataSource::Add(profile_, new ExtensionIconSource(profile_)); 262 content::URLDataSource::Add(profile_, new ExtensionIconSource(profile_));
263 263
264 quota_service_.reset(new QuotaService); 264 quota_service_.reset(new QuotaService);
265 265
266 if (command_line->HasSwitch(switches::kDisableExtensionsExcept)) {
267 base::CommandLine::StringType path_list =
Devlin 2016/07/25 19:10:30 The fact that the next 10 lines are almost identic
catmullings 2016/07/27 01:29:46 Done.
268 command_line->GetSwitchValueNative(switches::kDisableExtensionsExcept);
269 base::StringTokenizerT<base::CommandLine::StringType,
270 base::CommandLine::StringType::const_iterator>
271 t(path_list, FILE_PATH_LITERAL(","));
272 while (t.GetNext()) {
273 std::string extension_id;
274 UnpackedInstaller::Create(extension_service_.get())
275 ->LoadFromCommandLine(base::FilePath(t.token()), &extension_id);
276 extension_service_->AddExtensionToWhitelist(extension_id);
277 }
278 }
266 if (extensions_enabled) { 279 if (extensions_enabled) {
267 // Load any extensions specified with --load-extension. 280 // Load any extensions specified with --load-extension.
268 // TODO(yoz): Seems like this should move into ExtensionService::Init. 281 // TODO(yoz): Seems like this should move into ExtensionService::Init.
269 // But maybe it's no longer important. 282 // But maybe it's no longer important.
270 if (command_line->HasSwitch(switches::kLoadExtension)) { 283 if (command_line->HasSwitch(switches::kLoadExtension)) {
271 base::CommandLine::StringType path_list = 284 base::CommandLine::StringType path_list =
272 command_line->GetSwitchValueNative(switches::kLoadExtension); 285 command_line->GetSwitchValueNative(switches::kLoadExtension);
273 base::StringTokenizerT<base::CommandLine::StringType, 286 base::StringTokenizerT<base::CommandLine::StringType,
274 base::CommandLine::StringType::const_iterator> 287 base::CommandLine::StringType::const_iterator>
275 t(path_list, FILE_PATH_LITERAL(",")); 288 t(path_list, FILE_PATH_LITERAL(","));
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( 479 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts(
467 const std::string& extension_id, 480 const std::string& extension_id,
468 const UnloadedExtensionInfo::Reason reason) { 481 const UnloadedExtensionInfo::Reason reason) {
469 BrowserThread::PostTask( 482 BrowserThread::PostTask(
470 BrowserThread::IO, 483 BrowserThread::IO,
471 FROM_HERE, 484 FROM_HERE,
472 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); 485 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason));
473 } 486 }
474 487
475 } // namespace extensions 488 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698