| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_file_browser_private_api.h" | 5 #include "chrome/browser/extensions/extension_file_browser_private_api.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 child_id_(child_id), | 188 child_id_(child_id), |
| 189 extension_(extension) { | 189 extension_(extension) { |
| 190 DCHECK(function_); | 190 DCHECK(function_); |
| 191 } | 191 } |
| 192 | 192 |
| 193 // fileapi::FileSystemCallbackDispatcher overrides. | 193 // fileapi::FileSystemCallbackDispatcher overrides. |
| 194 virtual void DidSucceed() OVERRIDE { | 194 virtual void DidSucceed() OVERRIDE { |
| 195 NOTREACHED(); | 195 NOTREACHED(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 virtual void DidGetLocalPath(const FilePath& local_path) { |
| 199 NOTREACHED(); |
| 200 } |
| 201 |
| 198 virtual void DidReadMetadata(const base::PlatformFileInfo& info, | 202 virtual void DidReadMetadata(const base::PlatformFileInfo& info, |
| 199 const FilePath& unused) OVERRIDE { | 203 const FilePath& unused) OVERRIDE { |
| 200 NOTREACHED(); | 204 NOTREACHED(); |
| 201 } | 205 } |
| 202 | 206 |
| 203 virtual void DidReadDirectory( | 207 virtual void DidReadDirectory( |
| 204 const std::vector<base::FileUtilProxy::Entry>& entries, | 208 const std::vector<base::FileUtilProxy::Entry>& entries, |
| 205 bool has_more) OVERRIDE { | 209 bool has_more) OVERRIDE { |
| 206 NOTREACHED(); | 210 NOTREACHED(); |
| 207 } | 211 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 const Extension* extension = service->GetExtensionById(extension_id, false); | 355 const Extension* extension = service->GetExtensionById(extension_id, false); |
| 352 CHECK(extension); | 356 CHECK(extension); |
| 353 DictionaryValue* task = new DictionaryValue(); | 357 DictionaryValue* task = new DictionaryValue(); |
| 354 task->SetString("taskId", MakeTaskID(extension_id.data(), | 358 task->SetString("taskId", MakeTaskID(extension_id.data(), |
| 355 iter->second->id().data())); | 359 iter->second->id().data())); |
| 356 task->SetString("title", iter->second->title()); | 360 task->SetString("title", iter->second->title()); |
| 357 // TODO(zelidrag): Figure out how to expose icon URL that task defined in | 361 // TODO(zelidrag): Figure out how to expose icon URL that task defined in |
| 358 // manifest instead of the default extension icon. | 362 // manifest instead of the default extension icon. |
| 359 GURL icon = | 363 GURL icon = |
| 360 ExtensionIconSource::GetIconURL(extension, | 364 ExtensionIconSource::GetIconURL(extension, |
| 361 Extension::EXTENSION_ICON_SMALLISH, | 365 Extension::EXTENSION_ICON_BITTY, |
| 362 ExtensionIconSet::MATCH_BIGGER, | 366 ExtensionIconSet::MATCH_BIGGER, |
| 363 false); // grayscale | 367 false); // grayscale |
| 364 task->SetString("iconUrl", icon.spec()); | 368 task->SetString("iconUrl", icon.spec()); |
| 365 result_list->Append(task); | 369 result_list->Append(task); |
| 366 } | 370 } |
| 367 | 371 |
| 368 // TODO(zelidrag, serya): Add intent content tasks to result_list once we | 372 // TODO(zelidrag, serya): Add intent content tasks to result_list once we |
| 369 // implement that API. | 373 // implement that API. |
| 370 SendResponse(true); | 374 SendResponse(true); |
| 371 return true; | 375 return true; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 389 task_id_(task_id), | 393 task_id_(task_id), |
| 390 origin_file_urls_(file_urls) { | 394 origin_file_urls_(file_urls) { |
| 391 DCHECK(function_); | 395 DCHECK(function_); |
| 392 } | 396 } |
| 393 | 397 |
| 394 // fileapi::FileSystemCallbackDispatcher overrides. | 398 // fileapi::FileSystemCallbackDispatcher overrides. |
| 395 virtual void DidSucceed() OVERRIDE { | 399 virtual void DidSucceed() OVERRIDE { |
| 396 NOTREACHED(); | 400 NOTREACHED(); |
| 397 } | 401 } |
| 398 | 402 |
| 403 virtual void DidGetLocalPath(const FilePath& local_path) { |
| 404 NOTREACHED(); |
| 405 } |
| 406 |
| 399 virtual void DidReadMetadata(const base::PlatformFileInfo& info, | 407 virtual void DidReadMetadata(const base::PlatformFileInfo& info, |
| 400 const FilePath& unused) OVERRIDE { | 408 const FilePath& unused) OVERRIDE { |
| 401 NOTREACHED(); | 409 NOTREACHED(); |
| 402 } | 410 } |
| 403 | 411 |
| 404 virtual void DidReadDirectory( | 412 virtual void DidReadDirectory( |
| 405 const std::vector<base::FileUtilProxy::Entry>& entries, | 413 const std::vector<base::FileUtilProxy::Entry>& entries, |
| 406 bool has_more) OVERRIDE { | 414 bool has_more) OVERRIDE { |
| 407 NOTREACHED(); | 415 NOTREACHED(); |
| 408 } | 416 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 virtual_path)) { | 478 virtual_path)) { |
| 471 return false; | 479 return false; |
| 472 } | 480 } |
| 473 | 481 |
| 474 // Make sure this url really being used by the right caller extension. | 482 // Make sure this url really being used by the right caller extension. |
| 475 if (source_url_.GetOrigin() != file_origin_url) { | 483 if (source_url_.GetOrigin() != file_origin_url) { |
| 476 DidFail(base::PLATFORM_FILE_ERROR_SECURITY); | 484 DidFail(base::PLATFORM_FILE_ERROR_SECURITY); |
| 477 return false; | 485 return false; |
| 478 } | 486 } |
| 479 | 487 |
| 480 FilePath root_path = path_manager->GetFileSystemRootPathOnFileThread( | 488 FilePath root_path = |
| 481 file_origin_url, | 489 path_manager->ValidateFileSystemRootAndGetPathOnFileThread( |
| 482 fileapi::kFileSystemTypeExternal, | 490 file_origin_url, |
| 483 virtual_path, | 491 fileapi::kFileSystemTypeExternal, |
| 484 false); // create | 492 virtual_path, |
| 493 false); // create |
| 485 FilePath final_file_path = root_path.Append(virtual_path); | 494 FilePath final_file_path = root_path.Append(virtual_path); |
| 486 | 495 |
| 487 // Check if this file system entry exists first. | 496 // Check if this file system entry exists first. |
| 488 base::PlatformFileInfo file_info; | 497 base::PlatformFileInfo file_info; |
| 489 FilePath platform_path; | 498 FilePath platform_path; |
| 490 fileapi::FileSystemOperationContext file_system_operation_context( | 499 fileapi::FileSystemOperationContext file_system_operation_context( |
| 491 profile_->GetFileSystemContext(), | 500 profile_->GetFileSystemContext(), |
| 492 fileapi::LocalFileSystemFileUtil::GetInstance()); | 501 fileapi::LocalFileSystemFileUtil::GetInstance()); |
| 493 if (base::PLATFORM_FILE_OK != | 502 if (base::PLATFORM_FILE_OK != |
| 494 fileapi::FileSystemFileUtil::GetInstance()->GetFileInfo( | 503 fileapi::FileSystemFileUtil::GetInstance()->GetFileInfo( |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 FilePath virtual_path; | 753 FilePath virtual_path; |
| 745 fileapi::FileSystemType type; | 754 fileapi::FileSystemType type; |
| 746 if (!CrackFileSystemURL(file_url, &file_origin_url, &type, | 755 if (!CrackFileSystemURL(file_url, &file_origin_url, &type, |
| 747 &virtual_path)) { | 756 &virtual_path)) { |
| 748 continue; | 757 continue; |
| 749 } | 758 } |
| 750 if (type != fileapi::kFileSystemTypeExternal) { | 759 if (type != fileapi::kFileSystemTypeExternal) { |
| 751 NOTREACHED(); | 760 NOTREACHED(); |
| 752 continue; | 761 continue; |
| 753 } | 762 } |
| 754 FilePath root = path_manager->GetFileSystemRootPathOnFileThread( | 763 FilePath root = path_manager->ValidateFileSystemRootAndGetPathOnFileThread( |
| 755 origin_url, | 764 origin_url, |
| 756 fileapi::kFileSystemTypeExternal, | 765 fileapi::kFileSystemTypeExternal, |
| 757 FilePath(virtual_path), | 766 FilePath(virtual_path), |
| 758 false); | 767 false); |
| 759 if (!root.empty()) { | 768 if (!root.empty()) { |
| 760 selected_files.push_back(root.Append(virtual_path)); | 769 selected_files.push_back(root.Append(virtual_path)); |
| 761 } else { | 770 } else { |
| 762 LOG(WARNING) << "GetLocalPathsOnFileThread failed " | 771 LOG(WARNING) << "GetLocalPathsOnFileThread failed " |
| 763 << file_url.spec(); | 772 << file_url.spec(); |
| 764 } | 773 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 SET_STRING(IDS_FILE_BROWSER, COMPUTING_SELECTION); | 956 SET_STRING(IDS_FILE_BROWSER, COMPUTING_SELECTION); |
| 948 SET_STRING(IDS_FILE_BROWSER, NOTHING_SELECTED); | 957 SET_STRING(IDS_FILE_BROWSER, NOTHING_SELECTED); |
| 949 SET_STRING(IDS_FILE_BROWSER, ONE_FILE_SELECTED); | 958 SET_STRING(IDS_FILE_BROWSER, ONE_FILE_SELECTED); |
| 950 SET_STRING(IDS_FILE_BROWSER, MANY_FILES_SELECTED); | 959 SET_STRING(IDS_FILE_BROWSER, MANY_FILES_SELECTED); |
| 951 | 960 |
| 952 #undef SET_STRING | 961 #undef SET_STRING |
| 953 | 962 |
| 954 SendResponse(true); | 963 SendResponse(true); |
| 955 return true; | 964 return true; |
| 956 } | 965 } |
| OLD | NEW |