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/chromeos/extensions/file_browser_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 FileManagerUtil::GetFileBrowserExtensionUrl().GetOrigin(), | 325 FileManagerUtil::GetFileBrowserExtensionUrl().GetOrigin(), |
326 &source_url)) { | 326 &source_url)) { |
327 mount_info_value->SetString("sourceUrl", source_url.spec()); | 327 mount_info_value->SetString("sourceUrl", source_url.spec()); |
328 } | 328 } |
329 } else { | 329 } else { |
330 mount_info_value->SetString("sourceUrl", mount_info.source_path); | 330 mount_info_value->SetString("sourceUrl", mount_info.source_path); |
331 } | 331 } |
332 | 332 |
333 FilePath relative_mount_path; | 333 FilePath relative_mount_path; |
334 bool relative_mount_path_set = false; | 334 bool relative_mount_path_set = false; |
335 // If there were no error, add mountPath to the event. | 335 |
336 if (error_code == chromeos::MOUNT_ERROR_NONE) { | 336 // If there were no error or some special conditions occured, add mountPath |
| 337 // to the event. |
| 338 if (error_code == chromeos::MOUNT_ERROR_NONE || |
| 339 !mount_info.special_data.empty()) { |
337 // Convert mount point path to relative path with the external file system | 340 // Convert mount point path to relative path with the external file system |
338 // exposed within File API. | 341 // exposed within File API. |
339 if (FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile_, | 342 if (FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile_, |
340 FilePath(mount_info.mount_path), | 343 FilePath(mount_info.mount_path), |
341 &relative_mount_path)) { | 344 &relative_mount_path)) { |
342 mount_info_value->SetString("mountPath", | 345 mount_info_value->SetString("mountPath", |
343 "/" + relative_mount_path.value()); | 346 "/" + relative_mount_path.value()); |
344 relative_mount_path_set = true; | 347 relative_mount_path_set = true; |
345 } | 348 } |
346 } | 349 } |
347 | 350 |
348 std::string args_json; | 351 std::string args_json; |
349 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); | 352 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); |
350 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 353 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
351 extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL, | 354 extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL, |
352 GURL()); | 355 GURL()); |
353 | 356 |
354 if (relative_mount_path_set && | 357 if (relative_mount_path_set && |
355 mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && | 358 mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && |
| 359 mount_info.special_data != "unreadable_unknown_filesystem" && |
| 360 mount_info.special_data != "unreadable_unsupported_filesystem" && |
356 event == chromeos::MountLibrary::MOUNTING) { | 361 event == chromeos::MountLibrary::MOUNTING) { |
357 FileManagerUtil::ShowFullTabUrl(profile_, FilePath(mount_info.mount_path)); | 362 FileManagerUtil::ShowFullTabUrl(profile_, FilePath(mount_info.mount_path)); |
358 } | 363 } |
359 } | 364 } |
360 | 365 |
361 void ExtensionFileBrowserEventRouter::OnDiskAdded( | 366 void ExtensionFileBrowserEventRouter::OnDiskAdded( |
362 const chromeos::MountLibrary::Disk* disk) { | 367 const chromeos::MountLibrary::Disk* disk) { |
363 VLOG(1) << "Disk added: " << disk->device_path(); | 368 VLOG(1) << "Disk added: " << disk->device_path(); |
364 if (disk->device_path().empty()) { | 369 if (disk->device_path().empty()) { |
365 VLOG(1) << "Empty system path for " << disk->device_path(); | 370 VLOG(1) << "Empty system path for " << disk->device_path(); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 &FileWatcherDelegate::HandleFileWatchOnUIThread, | 529 &FileWatcherDelegate::HandleFileWatchOnUIThread, |
525 local_path, | 530 local_path, |
526 true)); // got_error | 531 true)); // got_error |
527 } | 532 } |
528 | 533 |
529 void | 534 void |
530 ExtensionFileBrowserEventRouter::FileWatcherDelegate::HandleFileWatchOnUIThread( | 535 ExtensionFileBrowserEventRouter::FileWatcherDelegate::HandleFileWatchOnUIThread( |
531 const FilePath& local_path, bool got_error) { | 536 const FilePath& local_path, bool got_error) { |
532 router_->HandleFileWatchNotification(local_path, got_error); | 537 router_->HandleFileWatchNotification(local_path, got_error); |
533 } | 538 } |
OLD | NEW |