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

Side by Side Diff: extensions/renderer/dispatcher.cc

Issue 1772683002: FeatureProvider returns std::map instead of vector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 9 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
« no previous file with comments | « extensions/renderer/api_definitions_natives.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "extensions/renderer/dispatcher.h" 5 #include "extensions/renderer/dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 break; 1338 break;
1339 1339
1340 case Feature::BLESSED_EXTENSION_CONTEXT: 1340 case Feature::BLESSED_EXTENSION_CONTEXT:
1341 case Feature::UNBLESSED_EXTENSION_CONTEXT: 1341 case Feature::UNBLESSED_EXTENSION_CONTEXT:
1342 case Feature::CONTENT_SCRIPT_CONTEXT: 1342 case Feature::CONTENT_SCRIPT_CONTEXT:
1343 case Feature::WEBUI_CONTEXT: { 1343 case Feature::WEBUI_CONTEXT: {
1344 // Extension context; iterate through all the APIs and bind the available 1344 // Extension context; iterate through all the APIs and bind the available
1345 // ones. 1345 // ones.
1346 const FeatureProvider* api_feature_provider = 1346 const FeatureProvider* api_feature_provider =
1347 FeatureProvider::GetAPIFeatures(); 1347 FeatureProvider::GetAPIFeatures();
1348 const std::vector<std::string>& apis = 1348 for (const auto& map_entry : api_feature_provider->GetAllFeatures()) {
1349 api_feature_provider->GetAllFeatureNames();
1350 for (const std::string& api_name : apis) {
1351 Feature* feature = api_feature_provider->GetFeature(api_name);
1352 DCHECK(feature);
1353
1354 // Internal APIs are included via require(api_name) from internal code 1349 // Internal APIs are included via require(api_name) from internal code
1355 // rather than chrome[api_name]. 1350 // rather than chrome[api_name].
1356 if (feature->IsInternal()) 1351 if (map_entry.second->IsInternal())
1357 continue; 1352 continue;
1358 1353
1359 // If this API has a parent feature (and isn't marked 'noparent'), 1354 // If this API has a parent feature (and isn't marked 'noparent'),
1360 // then this must be a function or event, so we should not register. 1355 // then this must be a function or event, so we should not register.
1361 if (api_feature_provider->GetParent(feature) != NULL) 1356 if (api_feature_provider->GetParent(map_entry.second.get()) != nullptr)
1362 continue; 1357 continue;
1363 1358
1364 // Skip chrome.test if this isn't a test. 1359 // Skip chrome.test if this isn't a test.
1365 if (api_name == "test" && 1360 if (map_entry.first == "test" &&
1366 !base::CommandLine::ForCurrentProcess()->HasSwitch( 1361 !base::CommandLine::ForCurrentProcess()->HasSwitch(
1367 ::switches::kTestType)) { 1362 ::switches::kTestType)) {
1368 continue; 1363 continue;
1369 } 1364 }
1370 1365
1371 if (context->IsAnyFeatureAvailableToContext(*feature)) 1366 if (context->IsAnyFeatureAvailableToContext(*map_entry.second.get()))
1372 RegisterBinding(api_name, context); 1367 RegisterBinding(map_entry.first, context);
1373 } 1368 }
1374 break; 1369 break;
1375 } 1370 }
1376 case Feature::SERVICE_WORKER_CONTEXT: 1371 case Feature::SERVICE_WORKER_CONTEXT:
1377 // Handled in DidInitializeServiceWorkerContextOnWorkerThread(). 1372 // Handled in DidInitializeServiceWorkerContextOnWorkerThread().
1378 NOTREACHED(); 1373 NOTREACHED();
1379 break; 1374 break;
1380 } 1375 }
1381 } 1376 }
1382 1377
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 // The "guestViewDeny" module must always be loaded last. It registers 1607 // The "guestViewDeny" module must always be loaded last. It registers
1613 // error-providing custom elements for the GuestView types that are not 1608 // error-providing custom elements for the GuestView types that are not
1614 // available, and thus all of those types must have been checked and loaded 1609 // available, and thus all of those types must have been checked and loaded
1615 // (or not loaded) beforehand. 1610 // (or not loaded) beforehand.
1616 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { 1611 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
1617 module_system->Require("guestViewDeny"); 1612 module_system->Require("guestViewDeny");
1618 } 1613 }
1619 } 1614 }
1620 1615
1621 } // namespace extensions 1616 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/api_definitions_natives.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698