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

Side by Side Diff: chrome/browser/chromeos/extensions/file_handler_util.cc

Issue 10873055: Changed FileSystemPointProvider::IsAcccessAllowed() to take a single FileSystemURL instead of a tri… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | webkit/chromeos/fileapi/cros_mount_point_provider.h » ('j') | 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/chromeos/extensions/file_handler_util.h" 5 #include "chrome/browser/chromeos/extensions/file_handler_util.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/common/extensions/file_browser_handler.h" 29 #include "chrome/common/extensions/file_browser_handler.h"
30 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
31 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/child_process_security_policy.h" 32 #include "content/public/browser/child_process_security_policy.h"
33 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
34 #include "content/public/browser/site_instance.h" 34 #include "content/public/browser/site_instance.h"
35 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
36 #include "net/base/escape.h" 36 #include "net/base/escape.h"
37 #include "webkit/fileapi/file_system_context.h" 37 #include "webkit/fileapi/file_system_context.h"
38 #include "webkit/fileapi/file_system_mount_point_provider.h" 38 #include "webkit/fileapi/file_system_mount_point_provider.h"
39 #include "webkit/fileapi/file_system_url.h"
39 #include "webkit/fileapi/file_system_util.h" 40 #include "webkit/fileapi/file_system_util.h"
40 41
41 using content::BrowserContext; 42 using content::BrowserContext;
42 using content::BrowserThread; 43 using content::BrowserThread;
43 using content::ChildProcessSecurityPolicy; 44 using content::ChildProcessSecurityPolicy;
44 using content::SiteInstance; 45 using content::SiteInstance;
45 using content::WebContents; 46 using content::WebContents;
46 using extensions::Extension; 47 using extensions::Extension;
47 48
48 namespace file_handler_util { 49 namespace file_handler_util {
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 // Checks legitimacy of file url and grants file RO access permissions from 560 // Checks legitimacy of file url and grants file RO access permissions from
560 // handler (target) extension and its renderer process. 561 // handler (target) extension and its renderer process.
561 bool SetupFileAccessPermissions(const GURL& origin_file_url, 562 bool SetupFileAccessPermissions(const GURL& origin_file_url,
562 FileDefinition* file) { 563 FileDefinition* file) {
563 if (!handler_extension_.get()) 564 if (!handler_extension_.get())
564 return false; 565 return false;
565 566
566 if (handler_pid_ == 0) 567 if (handler_pid_ == 0)
567 return false; 568 return false;
568 569
569 GURL file_origin_url; 570 fileapi::FileSystemURL file_system_url = fileapi::FileSystemURL(
570 FilePath virtual_path; 571 origin_file_url);
571 fileapi::FileSystemType type; 572 if (!file_system_url.is_valid()) {
nhiroki (google) 2012/08/24 07:20:03 nit: can you remove brace?
calvinlo 2012/08/24 07:55:09 Done.
572 if (!CrackFileSystemURL(origin_file_url, &file_origin_url, &type,
573 &virtual_path)) {
574 return false; 573 return false;
575 } 574 }
576 575
577 if (type != fileapi::kFileSystemTypeExternal) 576 if (file_system_url.type() != fileapi::kFileSystemTypeExternal)
578 return false; 577 return false;
579 578
580 fileapi::ExternalFileSystemMountPointProvider* external_provider = 579 fileapi::ExternalFileSystemMountPointProvider* external_provider =
581 file_system_context_->external_provider(); 580 file_system_context_->external_provider();
582 if (!external_provider) 581 if (!external_provider)
583 return false; 582 return false;
584 583
585 if (!external_provider->IsAccessAllowed(file_origin_url, 584 if (!external_provider->IsAccessAllowed(file_system_url)) {
nhiroki (google) 2012/08/24 07:20:03 ditto.
calvinlo 2012/08/24 07:55:09 Done. Sorry, this will take me some time to get us
586 type,
587 virtual_path)) {
588 return false; 585 return false;
589 } 586 }
590 587
591 // Make sure this url really being used by the right caller extension. 588 // Make sure this url really being used by the right caller extension.
592 if (source_url_.GetOrigin() != file_origin_url) { 589 if (source_url_.GetOrigin() != file_system_url.origin()) {
593 DidFail(base::PLATFORM_FILE_ERROR_SECURITY); 590 DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
594 return false; 591 return false;
595 } 592 }
596 593
594 FilePath virtual_path = file_system_url.path();
597 FilePath root_path = 595 FilePath root_path =
598 external_provider->GetFileSystemRootPathOnFileThread( 596 external_provider->GetFileSystemRootPathOnFileThread(
599 file_origin_url, 597 file_system_url.origin(),
600 fileapi::kFileSystemTypeExternal, 598 fileapi::kFileSystemTypeExternal,
601 virtual_path, 599 virtual_path,
602 false); // create 600 false); // create
603 FilePath final_file_path = root_path.Append(virtual_path); 601 FilePath final_file_path = root_path.Append(virtual_path);
604 602
605 // Check if this file system entry exists first. 603 // Check if this file system entry exists first.
606 base::PlatformFileInfo file_info; 604 base::PlatformFileInfo file_info;
607 605
608 bool is_gdata_file = gdata::util::IsUnderGDataMountPoint(final_file_path); 606 bool is_gdata_file = gdata::util::IsUnderGDataMountPoint(final_file_path);
609 607
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 handler_pid, 886 handler_pid,
889 handler_host_permissions_[i].first, 887 handler_host_permissions_[i].first,
890 handler_host_permissions_[i].second); 888 handler_host_permissions_[i].second);
891 } 889 }
892 890
893 // We don't need this anymore. 891 // We don't need this anymore.
894 handler_host_permissions_.clear(); 892 handler_host_permissions_.clear();
895 } 893 }
896 894
897 } // namespace file_handler_util 895 } // namespace file_handler_util
OLDNEW
« no previous file with comments | « no previous file | webkit/chromeos/fileapi/cros_mount_point_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698