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

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

Issue 10231010: gdata: Apply correct mount label when mounting archives in GData (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: gdata: Apply correct mount label when mounting archives in GData Created 8 years, 7 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
OLDNEW
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_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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 ListValue args; 361 ListValue args;
362 DictionaryValue* mount_info_value = new DictionaryValue(); 362 DictionaryValue* mount_info_value = new DictionaryValue();
363 args.Append(mount_info_value); 363 args.Append(mount_info_value);
364 mount_info_value->SetString("eventType", 364 mount_info_value->SetString("eventType",
365 event == DiskMountManager::MOUNTING ? "mount" : "unmount"); 365 event == DiskMountManager::MOUNTING ? "mount" : "unmount");
366 mount_info_value->SetString("status", MountErrorToString(error_code)); 366 mount_info_value->SetString("status", MountErrorToString(error_code));
367 mount_info_value->SetString( 367 mount_info_value->SetString(
368 "mountType", 368 "mountType",
369 DiskMountManager::MountTypeToString(mount_info.mount_type)); 369 DiskMountManager::MountTypeToString(mount_info.mount_type));
370 370
371 if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE || 371 // Determine if the source path is an archive on gdata.
372 mount_info.mount_type == chromeos::MOUNT_TYPE_GDATA) { 372 bool is_archive_on_gdata = false;
373 FilePath source_path(mount_info.source_path);
374 if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) {
375 gdata::GDataSystemService* system_service =
376 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
377 gdata::GDataFileSystem* file_system =
tbarzic 2012/04/27 05:44:21 This should probably be separate function. On the
hshi 2012/04/27 18:48:56 Removed as suggested.
378 system_service ? system_service->file_system() : NULL;
379 is_archive_on_gdata =
380 file_system && file_system->IsUnderGDataCacheDirectory(source_path);
381 }
382
383 if (!is_archive_on_gdata &&
384 (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE ||
385 mount_info.mount_type == chromeos::MOUNT_TYPE_GDATA)) {
373 GURL source_url; 386 GURL source_url;
374 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, 387 if (file_manager_util::ConvertFileToFileSystemUrl(profile_,
tbarzic 2012/04/27 05:44:21 We do this conversion for archives file_manager ca
hshi 2012/04/27 18:48:56 Done.
375 FilePath(mount_info.source_path), 388 source_path,
376 file_manager_util::GetFileBrowserExtensionUrl().GetOrigin(), 389 file_manager_util::GetFileBrowserExtensionUrl().GetOrigin(),
377 &source_url)) { 390 &source_url)) {
378 mount_info_value->SetString("sourceUrl", source_url.spec()); 391 mount_info_value->SetString("sourceUrl", source_url.spec());
379 } else { 392 } else {
380 // If mounting of gdata moutn point failed, we may not be able to convert 393 // If mounting of gdata moutn point failed, we may not be able to convert
381 // source path to source url, so let just send empty string. 394 // source path to source url, so let just send empty string.
382 DCHECK(mount_info.mount_type == chromeos::MOUNT_TYPE_GDATA && 395 DCHECK(mount_info.mount_type == chromeos::MOUNT_TYPE_GDATA &&
383 error_code != chromeos::MOUNT_ERROR_NONE); 396 error_code != chromeos::MOUNT_ERROR_NONE);
384 mount_info_value->SetString("sourceUrl", ""); 397 mount_info_value->SetString("sourceUrl", "");
385 } 398 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 const DiskMountManager::Disk* disk) { 436 const DiskMountManager::Disk* disk) {
424 VLOG(1) << "Disk added: " << disk->device_path(); 437 VLOG(1) << "Disk added: " << disk->device_path();
425 if (disk->device_path().empty()) { 438 if (disk->device_path().empty()) {
426 VLOG(1) << "Empty system path for " << disk->device_path(); 439 VLOG(1) << "Empty system path for " << disk->device_path();
427 return; 440 return;
428 } 441 }
429 442
430 // If disk is not mounted yet and it has media, give it a try. 443 // If disk is not mounted yet and it has media, give it a try.
431 if (disk->mount_path().empty() && disk->has_media()) { 444 if (disk->mount_path().empty() && disk->has_media()) {
432 // Initiate disk mount operation. MountPath auto-detects the filesystem 445 // Initiate disk mount operation. MountPath auto-detects the filesystem
433 // format if the second argument is empty. 446 // format if the second argument is empty. The third argument (mount label)
447 // is not used in a disk mount operation.
434 DiskMountManager::GetInstance()->MountPath( 448 DiskMountManager::GetInstance()->MountPath(
435 disk->device_path(), std::string(), chromeos::MOUNT_TYPE_DEVICE); 449 disk->device_path(), std::string(), std::string(),
450 chromeos::MOUNT_TYPE_DEVICE);
436 } else { 451 } else {
437 // Either the disk was mounted or it has no media. In both cases we don't 452 // Either the disk was mounted or it has no media. In both cases we don't
438 // want the Scanning notification to persist. 453 // want the Scanning notification to persist.
439 notifications_->HideNotification(FileBrowserNotifications::DEVICE, 454 notifications_->HideNotification(FileBrowserNotifications::DEVICE,
440 disk->system_path_prefix()); 455 disk->system_path_prefix());
441 } 456 }
442 DispatchDiskEvent(disk, true); 457 DispatchDiskEvent(disk, true);
443 } 458 }
444 459
445 void FileBrowserEventRouter::OnDiskRemoved( 460 void FileBrowserEventRouter::OnDiskRemoved(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 const std::string& device_path, bool success) { 507 const std::string& device_path, bool success) {
493 if (success) { 508 if (success) {
494 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, 509 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START,
495 device_path); 510 device_path);
496 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, 511 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS,
497 device_path); 512 device_path);
498 // Hide it after a couple of seconds. 513 // Hide it after a couple of seconds.
499 notifications_->HideNotificationDelayed( 514 notifications_->HideNotificationDelayed(
500 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); 515 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000);
501 // MountPath auto-detects filesystem format if second argument is empty. 516 // MountPath auto-detects filesystem format if second argument is empty.
517 // The third argument (mount path) is not used in a disk mount operation.
tbarzic 2012/04/27 05:44:21 Isn't the third arg label to be used for the mount
hshi 2012/04/27 18:48:56 Sorry for the typo, the 3rd arg should be mount la
502 DiskMountManager::GetInstance()->MountPath(device_path, std::string(), 518 DiskMountManager::GetInstance()->MountPath(device_path, std::string(),
519 std::string(),
503 chromeos::MOUNT_TYPE_DEVICE); 520 chromeos::MOUNT_TYPE_DEVICE);
504 } else { 521 } else {
505 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, 522 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START,
506 device_path); 523 device_path);
507 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, 524 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL,
508 device_path); 525 device_path);
509 } 526 }
510 } 527 }
511 528
512 // FileBrowserEventRouter::WatcherDelegate methods. 529 // FileBrowserEventRouter::WatcherDelegate methods.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 return scoped_refptr<RefcountedProfileKeyedService>( 650 return scoped_refptr<RefcountedProfileKeyedService>(
634 new FileBrowserEventRouter(profile)); 651 new FileBrowserEventRouter(profile));
635 } 652 }
636 653
637 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { 654 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() {
638 // Explicitly and always allow this router in guest login mode. see 655 // Explicitly and always allow this router in guest login mode. see
639 // chrome/browser/profiles/profile_keyed_base_factory.h comment 656 // chrome/browser/profiles/profile_keyed_base_factory.h comment
640 // for the details. 657 // for the details.
641 return true; 658 return true;
642 } 659 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698