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

Side by Side Diff: chrome/browser/chromeos/file_manager/volume_manager.cc

Issue 1049833004: Add flag for MTP write support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 8 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
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chromeos/chromeos_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/file_manager/volume_manager.h" 5 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h"
9 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 17 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
17 #include "chrome/browser/chromeos/drive/file_system_interface.h" 18 #include "chrome/browser/chromeos/drive/file_system_interface.h"
18 #include "chrome/browser/chromeos/drive/file_system_util.h" 19 #include "chrome/browser/chromeos/drive/file_system_util.h"
19 #include "chrome/browser/chromeos/file_manager/path_util.h" 20 #include "chrome/browser/chromeos/file_manager/path_util.h"
20 #include "chrome/browser/chromeos/file_manager/snapshot_manager.h" 21 #include "chrome/browser/chromeos/file_manager/snapshot_manager.h"
21 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" 22 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h"
22 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" 23 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h"
23 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" 24 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h"
24 #include "chrome/browser/chromeos/profiles/profile_helper.h" 25 #include "chrome/browser/chromeos/profiles/profile_helper.h"
25 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h" 26 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h"
26 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
29 #include "chromeos/chromeos_switches.h"
28 #include "chromeos/disks/disk_mount_manager.h" 30 #include "chromeos/disks/disk_mount_manager.h"
29 #include "components/storage_monitor/storage_monitor.h" 31 #include "components/storage_monitor/storage_monitor.h"
30 #include "content/public/browser/browser_context.h" 32 #include "content/public/browser/browser_context.h"
31 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
32 #include "storage/browser/fileapi/external_mount_points.h" 34 #include "storage/browser/fileapi/external_mount_points.h"
33 35
34 namespace file_manager { 36 namespace file_manager {
35 namespace { 37 namespace {
36 38
37 const char kFileManagerMTPMountNamePrefix[] = "fileman-mtp-"; 39 const char kFileManagerMTPMountNamePrefix[] = "fileman-mtp-";
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 label = base_name + base::StringPrintf(" (%d)", i); 681 label = base_name + base::StringPrintf(" (%d)", i);
680 682
681 bool result = 683 bool result =
682 storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( 684 storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
683 fsid, 685 fsid,
684 storage::kFileSystemTypeDeviceMediaAsFileStorage, 686 storage::kFileSystemTypeDeviceMediaAsFileStorage,
685 storage::FileSystemMountOption(), 687 storage::FileSystemMountOption(),
686 path); 688 path);
687 DCHECK(result); 689 DCHECK(result);
688 690
689 // TODO(yawano) A variable to switch MTP write support. This variable should 691 bool write_supported = base::CommandLine::ForCurrentProcess()->HasSwitch(
690 // be false until MTP write operation is implemented and shipped. 692 chromeos::switches::kEnableMtpWriteSupport);
691 bool write_supported = false;
692 693
693 content::BrowserThread::PostTask( 694 content::BrowserThread::PostTask(
694 content::BrowserThread::IO, FROM_HERE, 695 content::BrowserThread::IO, FROM_HERE,
695 base::Bind(&MTPDeviceMapService::RegisterMTPFileSystem, 696 base::Bind(&MTPDeviceMapService::RegisterMTPFileSystem,
696 base::Unretained(MTPDeviceMapService::GetInstance()), 697 base::Unretained(MTPDeviceMapService::GetInstance()),
697 info.location(), fsid, !write_supported /* read_only */)); 698 info.location(), fsid, !write_supported /* read_only */));
698 699
699 linked_ptr<Volume> volume( 700 linked_ptr<Volume> volume(
700 Volume::CreateForMTP(path, label, !write_supported)); 701 Volume::CreateForMTP(path, label, !write_supported));
701 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume); 702 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) 827 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end())
827 return; 828 return;
828 if (error_code == chromeos::MOUNT_ERROR_NONE) 829 if (error_code == chromeos::MOUNT_ERROR_NONE)
829 mounted_volumes_.erase(volume->volume_id()); 830 mounted_volumes_.erase(volume->volume_id());
830 831
831 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, 832 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_,
832 OnVolumeUnmounted(error_code, *volume.get())); 833 OnVolumeUnmounted(error_code, *volume.get()));
833 } 834 }
834 835
835 } // namespace file_manager 836 } // namespace file_manager
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chromeos/chromeos_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698