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

Side by Side Diff: chrome/common/extensions/permissions/permissions_data.cc

Issue 22470007: Add a "key" entry to InstallWarnings, remove InstallWarning::Format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dc_ec_infrastructure
Patch Set: Created 7 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/common/extensions/permissions/permissions_data.h" 5 #include "chrome/common/extensions/permissions/permissions_data.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 Feature::Availability availability = feature->IsAvailableToManifest( 150 Feature::Availability availability = feature->IsAvailableToManifest(
151 extension->id(), 151 extension->id(),
152 extension->GetType(), 152 extension->GetType(),
153 Feature::ConvertLocation(extension->location()), 153 Feature::ConvertLocation(extension->location()),
154 extension->manifest_version()); 154 extension->manifest_version());
155 155
156 if (!availability.is_available()) { 156 if (!availability.is_available()) {
157 // Don't fail, but warn the developer that the manifest contains 157 // Don't fail, but warn the developer that the manifest contains
158 // unrecognized permissions. This may happen legitimately if the 158 // unrecognized permissions. This may happen legitimately if the
159 // extensions requests platform- or channel-specific permissions. 159 // extensions requests platform- or channel-specific permissions.
160 extension->AddInstallWarning(InstallWarning(InstallWarning::FORMAT_TEXT, 160 extension->AddInstallWarning(InstallWarning(availability.message(),
161 availability.message())); 161 feature->name()));
162 to_remove.push_back(iter->id()); 162 to_remove.push_back(iter->id());
163 continue; 163 continue;
164 } 164 }
165 165
166 if (iter->id() == APIPermission::kExperimental) { 166 if (iter->id() == APIPermission::kExperimental) {
167 if (!CanSpecifyExperimentalPermission(extension)) { 167 if (!CanSpecifyExperimentalPermission(extension)) {
168 *error = ASCIIToUTF16(errors::kExperimentalFlagRequired); 168 *error = ASCIIToUTF16(errors::kExperimentalFlagRequired);
169 return false; 169 return false;
170 } 170 }
171 } 171 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // chrome://thumbnail, so add them back in to host_permissions separately. 224 // chrome://thumbnail, so add them back in to host_permissions separately.
225 if (pattern.match_all_urls()) 225 if (pattern.match_all_urls())
226 host_permissions->AddPatterns(GetPermittedChromeSchemeHosts( 226 host_permissions->AddPatterns(GetPermittedChromeSchemeHosts(
227 extension, *api_permissions)); 227 extension, *api_permissions));
228 continue; 228 continue;
229 } 229 }
230 230
231 // It's probably an unknown API permission. Do not throw an error so 231 // It's probably an unknown API permission. Do not throw an error so
232 // extensions can retain backwards compatability (http://crbug.com/42742). 232 // extensions can retain backwards compatability (http://crbug.com/42742).
233 extension->AddInstallWarning(InstallWarning( 233 extension->AddInstallWarning(InstallWarning(
234 InstallWarning::FORMAT_TEXT, 234 base::StringPrintf(
235 base::StringPrintf(
236 "Permission '%s' is unknown or URL pattern is malformed.", 235 "Permission '%s' is unknown or URL pattern is malformed.",
237 permission_str.c_str()))); 236 permission_str.c_str()),
237 key,
238 permission_str));
238 } 239 }
239 240
240 return true; 241 return true;
241 } 242 }
242 243
243 // Returns true if this extension id is from a trusted provider. 244 // Returns true if this extension id is from a trusted provider.
244 bool IsTrustedId(const std::string& extension_id) { 245 bool IsTrustedId(const std::string& extension_id) {
245 // See http://b/4946060 for more details. 246 // See http://b/4946060 for more details.
246 return extension_id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); 247 return extension_id == std::string("nckgahadagoaajjgafhacjanaoiihapd");
247 } 248 }
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 optional_permission_set_ = new PermissionSet( 635 optional_permission_set_ = new PermissionSet(
635 initial_optional_permissions_->api_permissions, 636 initial_optional_permissions_->api_permissions,
636 initial_optional_permissions_->host_permissions, 637 initial_optional_permissions_->host_permissions,
637 URLPatternSet()); 638 URLPatternSet());
638 639
639 initial_required_permissions_.reset(); 640 initial_required_permissions_.reset();
640 initial_optional_permissions_.reset(); 641 initial_optional_permissions_.reset();
641 } 642 }
642 643
643 } // namespace extensions 644 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/manifest_handlers/externally_connectable.cc ('k') | extensions/common/install_warning.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698