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

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 10384072: Update to handle absolute-looking paths in manifests and still produce nice-looking URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 else 428 else
429 return manifest_->type(); 429 return manifest_->type();
430 } 430 }
431 431
432 // static 432 // static
433 GURL Extension::GetResourceURL(const GURL& extension_url, 433 GURL Extension::GetResourceURL(const GURL& extension_url,
434 const std::string& relative_path) { 434 const std::string& relative_path) {
435 DCHECK(extension_url.SchemeIs(chrome::kExtensionScheme)); 435 DCHECK(extension_url.SchemeIs(chrome::kExtensionScheme));
436 DCHECK_EQ("/", extension_url.path()); 436 DCHECK_EQ("/", extension_url.path());
437 437
438 GURL ret_val = GURL(extension_url.spec() + relative_path); 438 std::string path = relative_path;
439
440 // If the relative path starts with "/", it is "absolute" relative to the
441 // extension base directory, but extension_url is already specified to refer
442 // to that base directory, so strip the leading "/" if present.
443 if (relative_path.size() > 0 && relative_path[0] == '/')
444 path = relative_path.substr(1);
445
446 GURL ret_val = GURL(extension_url.spec() + path);
439 DCHECK(StartsWithASCII(ret_val.spec(), extension_url.spec(), false)); 447 DCHECK(StartsWithASCII(ret_val.spec(), extension_url.spec(), false));
440 448
441 return ret_val; 449 return ret_val;
442 } 450 }
443 451
444 bool Extension::is_platform_app() const { 452 bool Extension::is_platform_app() const {
445 return manifest_->is_platform_app(); 453 return manifest_->is_platform_app();
446 } 454 }
447 455
448 bool Extension::is_hosted_app() const { 456 bool Extension::is_hosted_app() const {
(...skipping 3106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3555 already_disabled(false), 3563 already_disabled(false),
3556 extension(extension) {} 3564 extension(extension) {}
3557 3565
3558 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3566 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3559 const Extension* extension, 3567 const Extension* extension,
3560 const ExtensionPermissionSet* permissions, 3568 const ExtensionPermissionSet* permissions,
3561 Reason reason) 3569 Reason reason)
3562 : reason(reason), 3570 : reason(reason),
3563 extension(extension), 3571 extension(extension),
3564 permissions(permissions) {} 3572 permissions(permissions) {}
OLDNEW
« no previous file with comments | « chrome/browser/intents/web_intents_registry_unittest.cc ('k') | chrome/common/extensions/extension_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698