Commit d0a51415 authored by Karan Bhatia's avatar Karan Bhatia Committed by Commit Bot

Extensions: Prevent URLPatternSet copies.

This CL prevents redundant copies of URLPatternSet at certain locations by
taking a const reference.

BUG=None

Change-Id: Ib44686f30e10bd03a4e05b925cf4f1664b30bd34
Reviewed-on: https://chromium-review.googlesource.com/890044Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Commit-Queue: Karan Bhatia <karandeepb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532170}
parent ff4b9eef
...@@ -458,7 +458,7 @@ CrxInstallError CrxInstaller::AllowInstall(const Extension* extension) { ...@@ -458,7 +458,7 @@ CrxInstallError CrxInstaller::AllowInstall(const Extension* extension) {
pattern.SetHost(download_url_.host()); pattern.SetHost(download_url_.host());
pattern.SetMatchSubdomains(true); pattern.SetMatchSubdomains(true);
URLPatternSet patterns = extension_->web_extent(); const URLPatternSet& patterns = extension_->web_extent();
for (URLPatternSet::const_iterator i = patterns.begin(); for (URLPatternSet::const_iterator i = patterns.begin();
i != patterns.end(); ++i) { i != patterns.end(); ++i) {
if (!pattern.MatchesHost(i->host())) { if (!pattern.MatchesHost(i->host())) {
......
...@@ -92,7 +92,7 @@ void AddExceptionsGrantedByHostedApps(content::BrowserContext* context, ...@@ -92,7 +92,7 @@ void AddExceptionsGrantedByHostedApps(content::BrowserContext* context,
!(*extension)->permissions_data()->HasAPIPermission(permission)) !(*extension)->permissions_data()->HasAPIPermission(permission))
continue; continue;
extensions::URLPatternSet web_extent = (*extension)->web_extent(); const extensions::URLPatternSet& web_extent = (*extension)->web_extent();
// Add patterns from web extent. // Add patterns from web extent.
for (extensions::URLPatternSet::const_iterator pattern = web_extent.begin(); for (extensions::URLPatternSet::const_iterator pattern = web_extent.begin();
pattern != web_extent.end(); ++pattern) { pattern != web_extent.end(); ++pattern) {
......
...@@ -186,7 +186,7 @@ management::ExtensionInfo CreateExtensionInfo( ...@@ -186,7 +186,7 @@ management::ExtensionInfo CreateExtensionInfo(
if (!extension.is_hosted_app()) { if (!extension.is_hosted_app()) {
// Skip host permissions for hosted apps. // Skip host permissions for hosted apps.
const URLPatternSet host_perms = const URLPatternSet& host_perms =
extension.permissions_data()->active_permissions().explicit_hosts(); extension.permissions_data()->active_permissions().explicit_hosts();
if (!host_perms.is_empty()) { if (!host_perms.is_empty()) {
for (URLPatternSet::const_iterator iter = host_perms.begin(); for (URLPatternSet::const_iterator iter = host_perms.begin();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment