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

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

Issue 7706028: This is UI side unreadable device support. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: corrected strings + added mocks + style in js Created 9 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
OLDNEW
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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 335
336 // If the device is corrupted but it's still possible to format it, it will 336 // If there were no error or some special conditions occured, add mountPath
337 // be fake mounted. 337 // to the event.
338 // TODO(sidor): Write more general condition when it will possible. 338 if (error_code == chromeos::MOUNT_ERROR_NONE ||
339 bool mount_corrupted_device = 339 !mount_info.special_data.empty()) {
340 (error_code == chromeos::MOUNT_ERROR_UNKNOWN_FILESYSTEM ||
341 error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM) &&
342 mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE;
343
344 // If there were no error, add mountPath to the event.
345 if (error_code == chromeos::MOUNT_ERROR_NONE || mount_corrupted_device) {
346 // 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
347 // exposed within File API. 341 // exposed within File API.
348 if (FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile_, 342 if (FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile_,
349 FilePath(mount_info.mount_path), 343 FilePath(mount_info.mount_path),
350 &relative_mount_path)) { 344 &relative_mount_path)) {
351 mount_info_value->SetString("mountPath", 345 mount_info_value->SetString("mountPath",
352 "/" + relative_mount_path.value()); 346 "/" + relative_mount_path.value());
353 relative_mount_path_set = true; 347 relative_mount_path_set = true;
354 } 348 }
355 } 349 }
356 350
357 std::string args_json; 351 std::string args_json;
358 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); 352 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json);
359 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( 353 profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
360 extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL, 354 extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL,
361 GURL()); 355 GURL());
362 356
363 if (relative_mount_path_set && 357 if (relative_mount_path_set &&
364 mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && 358 mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE &&
365 !mount_corrupted_device && // User should not be bothered by that. 359 mount_info.special_data != "unreadable_unknown_filesystem" &&
tbarzic 2011/08/24 03:59:44 why not use mount_info.special_data.empty()
sidor 2011/08/24 04:26:06 hmm... I was thinking that in case of some other f
360 mount_info.special_data != "unreadable_unsupported_filesystem" &&
366 event == chromeos::MountLibrary::MOUNTING) { 361 event == chromeos::MountLibrary::MOUNTING) {
367 FileManagerUtil::ShowFullTabUrl(profile_, FilePath(mount_info.mount_path)); 362 FileManagerUtil::ShowFullTabUrl(profile_, FilePath(mount_info.mount_path));
368 } 363 }
369 } 364 }
370 365
371 void ExtensionFileBrowserEventRouter::OnDiskAdded( 366 void ExtensionFileBrowserEventRouter::OnDiskAdded(
372 const chromeos::MountLibrary::Disk* disk) { 367 const chromeos::MountLibrary::Disk* disk) {
373 VLOG(1) << "Disk added: " << disk->device_path(); 368 VLOG(1) << "Disk added: " << disk->device_path();
374 if (disk->device_path().empty()) { 369 if (disk->device_path().empty()) {
375 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
534 &FileWatcherDelegate::HandleFileWatchOnUIThread, 529 &FileWatcherDelegate::HandleFileWatchOnUIThread,
535 local_path, 530 local_path,
536 true)); // got_error 531 true)); // got_error
537 } 532 }
538 533
539 void 534 void
540 ExtensionFileBrowserEventRouter::FileWatcherDelegate::HandleFileWatchOnUIThread( 535 ExtensionFileBrowserEventRouter::FileWatcherDelegate::HandleFileWatchOnUIThread(
541 const FilePath& local_path, bool got_error) { 536 const FilePath& local_path, bool got_error) {
542 router_->HandleFileWatchNotification(local_path, got_error); 537 router_->HandleFileWatchNotification(local_path, got_error);
543 } 538 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698