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