OLD | NEW |
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_manager/file_browser_private_a
pi.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_a
pi.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/statvfs.h> | 8 #include <sys/statvfs.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <utime.h> | 10 #include <utime.h> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #include "chromeos/disks/disk_mount_manager.h" | 63 #include "chromeos/disks/disk_mount_manager.h" |
64 #include "content/public/browser/child_process_security_policy.h" | 64 #include "content/public/browser/child_process_security_policy.h" |
65 #include "content/public/browser/render_process_host.h" | 65 #include "content/public/browser/render_process_host.h" |
66 #include "content/public/browser/render_view_host.h" | 66 #include "content/public/browser/render_view_host.h" |
67 #include "content/public/browser/storage_partition.h" | 67 #include "content/public/browser/storage_partition.h" |
68 #include "googleurl/src/gurl.h" | 68 #include "googleurl/src/gurl.h" |
69 #include "grit/app_locale_settings.h" | 69 #include "grit/app_locale_settings.h" |
70 #include "grit/generated_resources.h" | 70 #include "grit/generated_resources.h" |
71 #include "grit/platform_locale_settings.h" | 71 #include "grit/platform_locale_settings.h" |
72 #include "net/base/escape.h" | 72 #include "net/base/escape.h" |
73 #include "net/base/mime_util.h" | |
74 #include "net/base/network_change_notifier.h" | 73 #include "net/base/network_change_notifier.h" |
75 #include "ui/base/l10n/l10n_util.h" | 74 #include "ui/base/l10n/l10n_util.h" |
76 #include "ui/shell_dialogs/selected_file_info.h" | 75 #include "ui/shell_dialogs/selected_file_info.h" |
77 #include "ui/webui/web_ui_util.h" | 76 #include "ui/webui/web_ui_util.h" |
78 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" | 77 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" |
79 #include "webkit/fileapi/file_system_context.h" | 78 #include "webkit/fileapi/file_system_context.h" |
80 #include "webkit/fileapi/file_system_file_util.h" | 79 #include "webkit/fileapi/file_system_file_util.h" |
81 #include "webkit/fileapi/file_system_operation_context.h" | 80 #include "webkit/fileapi/file_system_operation_context.h" |
82 #include "webkit/fileapi/file_system_types.h" | 81 #include "webkit/fileapi/file_system_types.h" |
83 #include "webkit/fileapi/file_system_url.h" | 82 #include "webkit/fileapi/file_system_url.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 file_specific_info.is_hosted_document()); | 389 file_specific_info.is_hosted_document()); |
391 | 390 |
392 property_dict->SetString("contentMimeType", | 391 property_dict->SetString("contentMimeType", |
393 file_specific_info.content_mime_type()); | 392 file_specific_info.content_mime_type()); |
394 } | 393 } |
395 | 394 |
396 void GetMimeTypesForFileURLs(const std::vector<base::FilePath>& file_paths, | 395 void GetMimeTypesForFileURLs(const std::vector<base::FilePath>& file_paths, |
397 PathAndMimeTypeSet* files) { | 396 PathAndMimeTypeSet* files) { |
398 for (std::vector<base::FilePath>::const_iterator iter = file_paths.begin(); | 397 for (std::vector<base::FilePath>::const_iterator iter = file_paths.begin(); |
399 iter != file_paths.end(); ++iter) { | 398 iter != file_paths.end(); ++iter) { |
400 const base::FilePath::StringType file_extension = | 399 files->insert( |
401 StringToLowerASCII(iter->Extension()); | 400 std::make_pair(*iter, file_manager_util::GetMimeTypeForPath(*iter))); |
402 | |
403 // TODO(thorogood): Rearchitect this call so it can run on the File thread; | |
404 // GetMimeTypeFromFile requires this on Linux. Right now, we use | |
405 // Chrome-level knowledge only. | |
406 std::string mime_type; | |
407 if (file_extension.empty() || | |
408 !net::GetWellKnownMimeTypeFromExtension(file_extension.substr(1), | |
409 &mime_type)) { | |
410 // If the file doesn't have an extension or its mime-type cannot be | |
411 // determined, then indicate that it has the empty mime-type. This will | |
412 // only be matched if the Web Intents accepts "*" or "*/*". | |
413 files->insert(std::make_pair(*iter, "")); | |
414 } else { | |
415 files->insert(std::make_pair(*iter, mime_type)); | |
416 } | |
417 } | 401 } |
418 } | 402 } |
419 | 403 |
420 // Retrieves the maximum file name length of the file system of |path|. | 404 // Retrieves the maximum file name length of the file system of |path|. |
421 // Returns 0 if it could not be queried. | 405 // Returns 0 if it could not be queried. |
422 size_t GetFileNameMaxLengthOnBlockingPool(const std::string& path) { | 406 size_t GetFileNameMaxLengthOnBlockingPool(const std::string& path) { |
423 struct statvfs stat = {}; | 407 struct statvfs stat = {}; |
424 if (statvfs(path.c_str(), &stat) != 0) { | 408 if (statvfs(path.c_str(), &stat) != 0) { |
425 // The filesystem seems not supporting statvfs(). Assume it to be a commonly | 409 // The filesystem seems not supporting statvfs(). Assume it to be a commonly |
426 // used bound 255, and log the failure. | 410 // used bound 255, and log the failure. |
(...skipping 2726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3153 OpenNewWindowFunction::OpenNewWindowFunction() {} | 3137 OpenNewWindowFunction::OpenNewWindowFunction() {} |
3154 | 3138 |
3155 OpenNewWindowFunction::~OpenNewWindowFunction() {} | 3139 OpenNewWindowFunction::~OpenNewWindowFunction() {} |
3156 | 3140 |
3157 bool OpenNewWindowFunction::RunImpl() { | 3141 bool OpenNewWindowFunction::RunImpl() { |
3158 std::string url; | 3142 std::string url; |
3159 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); | 3143 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); |
3160 file_manager_util::OpenNewWindow(profile_, GURL(url)); | 3144 file_manager_util::OpenNewWindow(profile_, GURL(url)); |
3161 return true; | 3145 return true; |
3162 } | 3146 } |
OLD | NEW |