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

Side by Side Diff: chrome/browser/extensions/extension_protocols.cc

Issue 106533003: Allowing following of symlinks for script resources from extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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 | « no previous file | 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 (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/browser/extensions/extension_protocols.h" 5 #include "chrome/browser/extensions/extension_protocols.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 277 }
278 278
279 class URLRequestExtensionJob : public net::URLRequestFileJob { 279 class URLRequestExtensionJob : public net::URLRequestFileJob {
280 public: 280 public:
281 URLRequestExtensionJob(net::URLRequest* request, 281 URLRequestExtensionJob(net::URLRequest* request,
282 net::NetworkDelegate* network_delegate, 282 net::NetworkDelegate* network_delegate,
283 const std::string& extension_id, 283 const std::string& extension_id,
284 const base::FilePath& directory_path, 284 const base::FilePath& directory_path,
285 const base::FilePath& relative_path, 285 const base::FilePath& relative_path,
286 const std::string& content_security_policy, 286 const std::string& content_security_policy,
287 bool send_cors_header) 287 bool send_cors_header,
288 bool follow_symlinks_anywhere)
288 : net::URLRequestFileJob( 289 : net::URLRequestFileJob(
289 request, network_delegate, base::FilePath(), 290 request, network_delegate, base::FilePath(),
290 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( 291 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
291 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), 292 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)),
292 directory_path_(directory_path), 293 directory_path_(directory_path),
293 // TODO(tc): Move all of these files into resources.pak so we don't break 294 // TODO(tc): Move all of these files into resources.pak so we don't break
294 // when updating on Linux. 295 // when updating on Linux.
295 resource_(extension_id, directory_path, relative_path), 296 resource_(extension_id, directory_path, relative_path),
296 content_security_policy_(content_security_policy), 297 content_security_policy_(content_security_policy),
297 send_cors_header_(send_cors_header), 298 send_cors_header_(send_cors_header),
298 weak_factory_(this) { 299 weak_factory_(this) {
300 if (follow_symlinks_anywhere) {
301 resource_.set_follow_symlinks_anywhere();
302 }
299 } 303 }
300 304
301 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE { 305 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE {
302 *info = response_info_; 306 *info = response_info_;
303 } 307 }
304 308
305 virtual void Start() OVERRIDE { 309 virtual void Start() OVERRIDE {
306 base::FilePath* read_file_path = new base::FilePath; 310 base::FilePath* read_file_path = new base::FilePath;
307 base::Time* last_modified_time = new base::Time(); 311 base::Time* last_modified_time = new base::Time();
308 bool posted = BrowserThread::PostBlockingPoolTaskAndReply( 312 bool posted = BrowserThread::PostBlockingPoolTaskAndReply(
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 if (URLIsForExtensionIcon(request->url(), disabled_extension)) 523 if (URLIsForExtensionIcon(request->url(), disabled_extension))
520 directory_path = disabled_extension->path(); 524 directory_path = disabled_extension->path();
521 if (directory_path.value().empty()) { 525 if (directory_path.value().empty()) {
522 LOG(WARNING) << "Failed to GetPathForExtension: " << extension_id; 526 LOG(WARNING) << "Failed to GetPathForExtension: " << extension_id;
523 return NULL; 527 return NULL;
524 } 528 }
525 } 529 }
526 530
527 std::string content_security_policy; 531 std::string content_security_policy;
528 bool send_cors_header = false; 532 bool send_cors_header = false;
533 bool follow_symlinks_anywhere = false;
529 if (extension) { 534 if (extension) {
530 std::string resource_path = request->url().path(); 535 std::string resource_path = request->url().path();
531 content_security_policy = 536 content_security_policy =
532 extensions::CSPInfo::GetResourceContentSecurityPolicy(extension, 537 extensions::CSPInfo::GetResourceContentSecurityPolicy(extension,
533 resource_path); 538 resource_path);
534 if ((extension->manifest_version() >= 2 || 539 if ((extension->manifest_version() >= 2 ||
535 extensions::WebAccessibleResourcesInfo::HasWebAccessibleResources( 540 extensions::WebAccessibleResourcesInfo::HasWebAccessibleResources(
536 extension)) && 541 extension)) &&
537 extensions::WebAccessibleResourcesInfo::IsResourceWebAccessible( 542 extensions::WebAccessibleResourcesInfo::IsResourceWebAccessible(
538 extension, resource_path)) 543 extension, resource_path))
539 send_cors_header = true; 544 send_cors_header = true;
545
546 follow_symlinks_anywhere = extension->creation_flags();
benwells 2013/12/09 23:22:15 What is this line for - is it meant to limit this
blois 2013/12/09 23:31:06 Eek. Correct. It should be doing the same as this
540 } 547 }
541 548
542 std::string path = request->url().path(); 549 std::string path = request->url().path();
543 if (path.size() > 1 && 550 if (path.size() > 1 &&
544 path.substr(1) == extensions::kGeneratedBackgroundPageFilename) { 551 path.substr(1) == extensions::kGeneratedBackgroundPageFilename) {
545 return new GeneratedBackgroundPageJob( 552 return new GeneratedBackgroundPageJob(
546 request, network_delegate, extension, content_security_policy); 553 request, network_delegate, extension, content_security_policy);
547 } 554 }
548 555
549 base::FilePath resources_path; 556 base::FilePath resources_path;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 return NULL; 618 return NULL;
612 } 619 }
613 } 620 }
614 621
615 return new URLRequestExtensionJob(request, 622 return new URLRequestExtensionJob(request,
616 network_delegate, 623 network_delegate,
617 extension_id, 624 extension_id,
618 directory_path, 625 directory_path,
619 relative_path, 626 relative_path,
620 content_security_policy, 627 content_security_policy,
621 send_cors_header); 628 send_cors_header,
629 follow_symlinks_anywhere);
622 } 630 }
623 631
624 } // namespace 632 } // namespace
625 633
626 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler( 634 net::URLRequestJobFactory::ProtocolHandler* CreateExtensionProtocolHandler(
627 bool is_incognito, 635 bool is_incognito,
628 extensions::InfoMap* extension_info_map) { 636 extensions::InfoMap* extension_info_map) {
629 return new ExtensionProtocolHandler(is_incognito, extension_info_map); 637 return new ExtensionProtocolHandler(is_incognito, extension_info_map);
630 } 638 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698