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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/chromeos/cros/cros_library.h" | |
13 #include "chrome/browser/chromeos/extensions/file_browser_notifications.h" | 12 #include "chrome/browser/chromeos/extensions/file_browser_notifications.h" |
14 #include "chrome/browser/chromeos/login/user_manager.h" | 13 #include "chrome/browser/chromeos/login/user_manager.h" |
15 #include "chrome/browser/extensions/extension_event_names.h" | 14 #include "chrome/browser/extensions/extension_event_names.h" |
16 #include "chrome/browser/extensions/extension_event_router.h" | 15 #include "chrome/browser/extensions/extension_event_router.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/file_manager_util.h" | 17 #include "chrome/browser/extensions/file_manager_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
20 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
21 #include "webkit/fileapi/file_system_types.h" | 20 #include "webkit/fileapi/file_system_types.h" |
22 #include "webkit/fileapi/file_system_util.h" | 21 #include "webkit/fileapi/file_system_util.h" |
(...skipping 15 matching lines...) Expand all Loading... |
38 return "hdd"; | 37 return "hdd"; |
39 case chromeos::OPTICAL: | 38 case chromeos::OPTICAL: |
40 return "optical"; | 39 return "optical"; |
41 default: | 40 default: |
42 break; | 41 break; |
43 } | 42 } |
44 return "undefined"; | 43 return "undefined"; |
45 } | 44 } |
46 | 45 |
47 DictionaryValue* DiskToDictionaryValue( | 46 DictionaryValue* DiskToDictionaryValue( |
48 const chromeos::MountLibrary::Disk* disk) { | 47 const chromeos::disks::DiskMountManager::Disk* disk) { |
49 DictionaryValue* result = new DictionaryValue(); | 48 DictionaryValue* result = new DictionaryValue(); |
50 result->SetString("mountPath", disk->mount_path()); | 49 result->SetString("mountPath", disk->mount_path()); |
51 result->SetString("devicePath", disk->device_path()); | 50 result->SetString("devicePath", disk->device_path()); |
52 result->SetString("label", disk->device_label()); | 51 result->SetString("label", disk->device_label()); |
53 result->SetString("deviceType", DeviceTypeToString(disk->device_type())); | 52 result->SetString("deviceType", DeviceTypeToString(disk->device_type())); |
54 result->SetInteger("totalSizeKB", disk->total_size() / 1024); | 53 result->SetInteger("totalSizeKB", disk->total_size_in_bytes() / 1024); |
55 result->SetBoolean("readOnly", disk->is_read_only()); | 54 result->SetBoolean("readOnly", disk->is_read_only()); |
56 return result; | 55 return result; |
57 } | 56 } |
58 } | 57 } |
59 | 58 |
60 const char* MountErrorToString(chromeos::MountError error) { | 59 const char* MountErrorToString(chromeos::MountError error) { |
61 switch (error) { | 60 switch (error) { |
62 case chromeos::MOUNT_ERROR_NONE: | 61 case chromeos::MOUNT_ERROR_NONE: |
63 return "success"; | 62 return "success"; |
64 case chromeos::MOUNT_ERROR_UNKNOWN: | 63 case chromeos::MOUNT_ERROR_UNKNOWN: |
(...skipping 23 matching lines...) Expand all Loading... |
88 | 87 |
89 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { | 88 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { |
90 DCHECK(file_watchers_.empty()); | 89 DCHECK(file_watchers_.empty()); |
91 STLDeleteValues(&file_watchers_); | 90 STLDeleteValues(&file_watchers_); |
92 | 91 |
93 if (!profile_) { | 92 if (!profile_) { |
94 NOTREACHED(); | 93 NOTREACHED(); |
95 return; | 94 return; |
96 } | 95 } |
97 profile_ = NULL; | 96 profile_ = NULL; |
98 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) | 97 chromeos::disks::DiskMountManager::GetInstance()->RemoveObserver(this); |
99 return; | |
100 chromeos::MountLibrary* lib = | |
101 chromeos::CrosLibrary::Get()->GetMountLibrary(); | |
102 lib->RemoveObserver(this); | |
103 } | 98 } |
104 | 99 |
105 void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents() { | 100 void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents() { |
106 if (!profile_) { | 101 if (!profile_) { |
107 NOTREACHED(); | 102 NOTREACHED(); |
108 return; | 103 return; |
109 } | 104 } |
110 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) | |
111 return; | |
112 if (chromeos::UserManager::Get()->user_is_logged_in()) { | 105 if (chromeos::UserManager::Get()->user_is_logged_in()) { |
113 chromeos::MountLibrary* lib = | 106 chromeos::disks::DiskMountManager* disk_mount_manager = |
114 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 107 chromeos::disks::DiskMountManager::GetInstance(); |
115 lib->RemoveObserver(this); | 108 disk_mount_manager->RemoveObserver(this); |
116 lib->AddObserver(this); | 109 disk_mount_manager->AddObserver(this); |
117 lib->RequestMountInfoRefresh(); | 110 disk_mount_manager->RequestMountInfoRefresh(); |
118 } | 111 } |
119 } | 112 } |
120 | 113 |
121 // File watch setup routines. | 114 // File watch setup routines. |
122 bool ExtensionFileBrowserEventRouter::AddFileWatch( | 115 bool ExtensionFileBrowserEventRouter::AddFileWatch( |
123 const FilePath& local_path, | 116 const FilePath& local_path, |
124 const FilePath& virtual_path, | 117 const FilePath& virtual_path, |
125 const std::string& extension_id) { | 118 const std::string& extension_id) { |
126 base::AutoLock lock(lock_); | 119 base::AutoLock lock(lock_); |
127 WatcherMap::iterator iter = file_watchers_.find(local_path); | 120 WatcherMap::iterator iter = file_watchers_.find(local_path); |
(...skipping 20 matching lines...) Expand all Loading... |
148 return; | 141 return; |
149 // Remove the renderer process for this watch. | 142 // Remove the renderer process for this watch. |
150 iter->second->RemoveExtension(extension_id); | 143 iter->second->RemoveExtension(extension_id); |
151 if (iter->second->GetRefCount() == 0) { | 144 if (iter->second->GetRefCount() == 0) { |
152 delete iter->second; | 145 delete iter->second; |
153 file_watchers_.erase(iter); | 146 file_watchers_.erase(iter); |
154 } | 147 } |
155 } | 148 } |
156 | 149 |
157 void ExtensionFileBrowserEventRouter::DiskChanged( | 150 void ExtensionFileBrowserEventRouter::DiskChanged( |
158 chromeos::MountLibraryEventType event, | 151 chromeos::disks::DiskMountManagerEventType event, |
159 const chromeos::MountLibrary::Disk* disk) { | 152 const chromeos::disks::DiskMountManager::Disk* disk) { |
160 // Disregard hidden devices. | 153 // Disregard hidden devices. |
161 if (disk->is_hidden()) | 154 if (disk->is_hidden()) |
162 return; | 155 return; |
163 if (event == chromeos::MOUNT_DISK_ADDED) { | 156 if (event == chromeos::disks::MOUNT_DISK_ADDED) { |
164 OnDiskAdded(disk); | 157 OnDiskAdded(disk); |
165 } else if (event == chromeos::MOUNT_DISK_REMOVED) { | 158 } else if (event == chromeos::disks::MOUNT_DISK_REMOVED) { |
166 OnDiskRemoved(disk); | 159 OnDiskRemoved(disk); |
167 } | 160 } |
168 } | 161 } |
169 | 162 |
170 void ExtensionFileBrowserEventRouter::DeviceChanged( | 163 void ExtensionFileBrowserEventRouter::DeviceChanged( |
171 chromeos::MountLibraryEventType event, | 164 chromeos::disks::DiskMountManagerEventType event, |
172 const std::string& device_path) { | 165 const std::string& device_path) { |
173 if (event == chromeos::MOUNT_DEVICE_ADDED) { | 166 if (event == chromeos::disks::MOUNT_DEVICE_ADDED) { |
174 OnDeviceAdded(device_path); | 167 OnDeviceAdded(device_path); |
175 } else if (event == chromeos::MOUNT_DEVICE_REMOVED) { | 168 } else if (event == chromeos::disks::MOUNT_DEVICE_REMOVED) { |
176 OnDeviceRemoved(device_path); | 169 OnDeviceRemoved(device_path); |
177 } else if (event == chromeos::MOUNT_DEVICE_SCANNED) { | 170 } else if (event == chromeos::disks::MOUNT_DEVICE_SCANNED) { |
178 OnDeviceScanned(device_path); | 171 OnDeviceScanned(device_path); |
179 } else if (event == chromeos::MOUNT_FORMATTING_STARTED) { | 172 } else if (event == chromeos::disks::MOUNT_FORMATTING_STARTED) { |
180 // TODO(tbarzic): get rid of '!'. | 173 // TODO(tbarzic): get rid of '!'. |
181 if (device_path[0] == '!') { | 174 if (device_path[0] == '!') { |
182 OnFormattingStarted(device_path.substr(1), false); | 175 OnFormattingStarted(device_path.substr(1), false); |
183 } else { | 176 } else { |
184 OnFormattingStarted(device_path, true); | 177 OnFormattingStarted(device_path, true); |
185 } | 178 } |
186 } else if (event == chromeos::MOUNT_FORMATTING_FINISHED) { | 179 } else if (event == chromeos::disks::MOUNT_FORMATTING_FINISHED) { |
187 if (device_path[0] == '!') { | 180 if (device_path[0] == '!') { |
188 OnFormattingFinished(device_path.substr(1), false); | 181 OnFormattingFinished(device_path.substr(1), false); |
189 } else { | 182 } else { |
190 OnFormattingFinished(device_path, true); | 183 OnFormattingFinished(device_path, true); |
191 } | 184 } |
192 } | 185 } |
193 } | 186 } |
194 | 187 |
195 void ExtensionFileBrowserEventRouter::MountCompleted( | 188 void ExtensionFileBrowserEventRouter::MountCompleted( |
196 chromeos::MountLibrary::MountEvent event_type, | 189 chromeos::disks::DiskMountManager::MountEvent event_type, |
197 chromeos::MountError error_code, | 190 chromeos::MountError error_code, |
198 const chromeos::MountLibrary::MountPointInfo& mount_info) { | 191 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) { |
199 DispatchMountCompletedEvent(event_type, error_code, mount_info); | 192 DispatchMountCompletedEvent(event_type, error_code, mount_info); |
200 | 193 |
201 if (mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && | 194 if (mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && |
202 event_type == chromeos::MountLibrary::MOUNTING) { | 195 event_type == chromeos::disks::DiskMountManager::MOUNTING) { |
203 chromeos::MountLibrary* mount_lib = | 196 chromeos::disks::DiskMountManager* disk_mount_manager = |
204 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 197 chromeos::disks::DiskMountManager::GetInstance(); |
205 chromeos::MountLibrary::DiskMap::const_iterator disk_it = | 198 chromeos::disks::DiskMountManager::DiskMap::const_iterator disk_it = |
206 mount_lib->disks().find(mount_info.source_path); | 199 disk_mount_manager->disks().find(mount_info.source_path); |
207 if (disk_it == mount_lib->disks().end()) { | 200 if (disk_it == disk_mount_manager->disks().end()) { |
208 return; | 201 return; |
209 } | 202 } |
210 chromeos::MountLibrary::Disk* disk = disk_it->second; | 203 chromeos::disks::DiskMountManager::Disk* disk = disk_it->second; |
211 | 204 |
212 notifications_->ManageNotificationsOnMountCompleted( | 205 notifications_->ManageNotificationsOnMountCompleted( |
213 disk->system_path_prefix(), disk->drive_label(), disk->is_parent(), | 206 disk->system_path_prefix(), disk->drive_label(), disk->is_parent(), |
214 error_code == chromeos::MOUNT_ERROR_NONE, | 207 error_code == chromeos::MOUNT_ERROR_NONE, |
215 error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM); | 208 error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM); |
216 } | 209 } |
217 } | 210 } |
218 | 211 |
219 void ExtensionFileBrowserEventRouter::HandleFileWatchNotification( | 212 void ExtensionFileBrowserEventRouter::HandleFileWatchNotification( |
220 const FilePath& local_path, bool got_error) { | 213 const FilePath& local_path, bool got_error) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 std::string args_json; | 246 std::string args_json; |
254 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); | 247 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); |
255 | 248 |
256 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 249 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
257 iter->first, extension_event_names::kOnFileChanged, args_json, | 250 iter->first, extension_event_names::kOnFileChanged, args_json, |
258 NULL, GURL()); | 251 NULL, GURL()); |
259 } | 252 } |
260 } | 253 } |
261 | 254 |
262 void ExtensionFileBrowserEventRouter::DispatchDiskEvent( | 255 void ExtensionFileBrowserEventRouter::DispatchDiskEvent( |
263 const chromeos::MountLibrary::Disk* disk, bool added) { | 256 const chromeos::disks::DiskMountManager::Disk* disk, bool added) { |
264 if (!profile_) { | 257 if (!profile_) { |
265 NOTREACHED(); | 258 NOTREACHED(); |
266 return; | 259 return; |
267 } | 260 } |
268 | 261 |
269 ListValue args; | 262 ListValue args; |
270 DictionaryValue* mount_info = new DictionaryValue(); | 263 DictionaryValue* mount_info = new DictionaryValue(); |
271 args.Append(mount_info); | 264 args.Append(mount_info); |
272 mount_info->SetString("eventType", | 265 mount_info->SetString("eventType", |
273 added ? kDiskAddedEventType : kDiskRemovedEventType); | 266 added ? kDiskAddedEventType : kDiskRemovedEventType); |
274 DictionaryValue* disk_info = DiskToDictionaryValue(disk); | 267 DictionaryValue* disk_info = DiskToDictionaryValue(disk); |
275 mount_info->Set("volumeInfo", disk_info); | 268 mount_info->Set("volumeInfo", disk_info); |
276 | 269 |
277 std::string args_json; | 270 std::string args_json; |
278 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); | 271 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); |
279 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 272 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
280 extension_event_names::kOnFileBrowserDiskChanged, args_json, NULL, | 273 extension_event_names::kOnFileBrowserDiskChanged, args_json, NULL, |
281 GURL()); | 274 GURL()); |
282 } | 275 } |
283 | 276 |
284 void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent( | 277 void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent( |
285 chromeos::MountLibrary::MountEvent event, | 278 chromeos::disks::DiskMountManager::MountEvent event, |
286 chromeos::MountError error_code, | 279 chromeos::MountError error_code, |
287 const chromeos::MountLibrary::MountPointInfo& mount_info) { | 280 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) { |
288 if (!profile_ || mount_info.mount_type == chromeos::MOUNT_TYPE_INVALID) { | 281 if (!profile_ || mount_info.mount_type == chromeos::MOUNT_TYPE_INVALID) { |
289 NOTREACHED(); | 282 NOTREACHED(); |
290 return; | 283 return; |
291 } | 284 } |
292 | 285 |
293 ListValue args; | 286 ListValue args; |
294 DictionaryValue* mount_info_value = new DictionaryValue(); | 287 DictionaryValue* mount_info_value = new DictionaryValue(); |
295 args.Append(mount_info_value); | 288 args.Append(mount_info_value); |
296 if (event == chromeos::MountLibrary::MOUNTING) { | 289 if (event == chromeos::disks::DiskMountManager::MOUNTING) { |
297 mount_info_value->SetString("eventType", "mount"); | 290 mount_info_value->SetString("eventType", "mount"); |
298 } else { | 291 } else { |
299 mount_info_value->SetString("eventType", "unmount"); | 292 mount_info_value->SetString("eventType", "unmount"); |
300 } | 293 } |
301 mount_info_value->SetString("status", MountErrorToString(error_code)); | 294 mount_info_value->SetString("status", MountErrorToString(error_code)); |
302 mount_info_value->SetString("mountType", | 295 mount_info_value->SetString( |
303 chromeos::MountLibrary::MountTypeToString(mount_info.mount_type)); | 296 "mountType", |
| 297 chromeos::disks::DiskMountManager::MountTypeToString( |
| 298 mount_info.mount_type)); |
304 | 299 |
305 if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { | 300 if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { |
306 GURL source_url; | 301 GURL source_url; |
307 if (FileManagerUtil::ConvertFileToFileSystemUrl(profile_, | 302 if (FileManagerUtil::ConvertFileToFileSystemUrl(profile_, |
308 FilePath(mount_info.source_path), | 303 FilePath(mount_info.source_path), |
309 FileManagerUtil::GetFileBrowserExtensionUrl().GetOrigin(), | 304 FileManagerUtil::GetFileBrowserExtensionUrl().GetOrigin(), |
310 &source_url)) { | 305 &source_url)) { |
311 mount_info_value->SetString("sourceUrl", source_url.spec()); | 306 mount_info_value->SetString("sourceUrl", source_url.spec()); |
312 } | 307 } |
313 } else { | 308 } else { |
(...skipping 20 matching lines...) Expand all Loading... |
334 | 329 |
335 std::string args_json; | 330 std::string args_json; |
336 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); | 331 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); |
337 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 332 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
338 extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL, | 333 extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL, |
339 GURL()); | 334 GURL()); |
340 | 335 |
341 if (relative_mount_path_set && | 336 if (relative_mount_path_set && |
342 mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && | 337 mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && |
343 !mount_info.mount_condition && | 338 !mount_info.mount_condition && |
344 event == chromeos::MountLibrary::MOUNTING) { | 339 event == chromeos::disks::DiskMountManager::MOUNTING) { |
345 FileManagerUtil::ViewFolder(FilePath(mount_info.mount_path)); | 340 FileManagerUtil::ViewFolder(FilePath(mount_info.mount_path)); |
346 } | 341 } |
347 } | 342 } |
348 | 343 |
349 void ExtensionFileBrowserEventRouter::OnDiskAdded( | 344 void ExtensionFileBrowserEventRouter::OnDiskAdded( |
350 const chromeos::MountLibrary::Disk* disk) { | 345 const chromeos::disks::DiskMountManager::Disk* disk) { |
351 VLOG(1) << "Disk added: " << disk->device_path(); | 346 VLOG(1) << "Disk added: " << disk->device_path(); |
352 if (disk->device_path().empty()) { | 347 if (disk->device_path().empty()) { |
353 VLOG(1) << "Empty system path for " << disk->device_path(); | 348 VLOG(1) << "Empty system path for " << disk->device_path(); |
354 return; | 349 return; |
355 } | 350 } |
356 | 351 |
357 // If disk is not mounted yet, give it a try. | 352 // If disk is not mounted yet, give it a try. |
358 if (disk->mount_path().empty()) { | 353 if (disk->mount_path().empty()) { |
359 // Initiate disk mount operation. | 354 // Initiate disk mount operation. |
360 chromeos::MountLibrary* lib = | 355 chromeos::disks::DiskMountManager::GetInstance()->MountPath( |
361 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 356 disk->device_path(), chromeos::MOUNT_TYPE_DEVICE); |
362 lib->MountPath(disk->device_path().c_str(), | |
363 chromeos::MOUNT_TYPE_DEVICE, | |
364 chromeos::MountPathOptions()); // Unused. | |
365 } | 357 } |
366 DispatchDiskEvent(disk, true); | 358 DispatchDiskEvent(disk, true); |
367 } | 359 } |
368 | 360 |
369 void ExtensionFileBrowserEventRouter::OnDiskRemoved( | 361 void ExtensionFileBrowserEventRouter::OnDiskRemoved( |
370 const chromeos::MountLibrary::Disk* disk) { | 362 const chromeos::disks::DiskMountManager::Disk* disk) { |
371 VLOG(1) << "Disk removed: " << disk->device_path(); | 363 VLOG(1) << "Disk removed: " << disk->device_path(); |
372 | 364 |
373 if (!disk->mount_path().empty()) { | 365 if (!disk->mount_path().empty()) { |
374 chromeos::MountLibrary* lib = | 366 chromeos::disks::DiskMountManager::GetInstance()->UnmountPath( |
375 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 367 disk->mount_path()); |
376 lib->UnmountPath(disk->mount_path().c_str()); | |
377 } | 368 } |
378 DispatchDiskEvent(disk, false); | 369 DispatchDiskEvent(disk, false); |
379 } | 370 } |
380 | 371 |
381 void ExtensionFileBrowserEventRouter::OnDeviceAdded( | 372 void ExtensionFileBrowserEventRouter::OnDeviceAdded( |
382 const std::string& device_path) { | 373 const std::string& device_path) { |
383 VLOG(1) << "Device added : " << device_path; | 374 VLOG(1) << "Device added : " << device_path; |
384 | 375 |
385 notifications_->RegisterDevice(device_path); | 376 notifications_->RegisterDevice(device_path); |
386 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, | 377 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 const std::string& device_path, bool success) { | 409 const std::string& device_path, bool success) { |
419 if (success) { | 410 if (success) { |
420 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 411 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
421 device_path); | 412 device_path); |
422 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, | 413 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, |
423 device_path); | 414 device_path); |
424 // Hide it after a couple of seconds. | 415 // Hide it after a couple of seconds. |
425 notifications_->HideNotificationDelayed( | 416 notifications_->HideNotificationDelayed( |
426 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); | 417 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); |
427 | 418 |
428 chromeos::MountLibrary* lib = | 419 chromeos::disks::DiskMountManager::GetInstance()->MountPath( |
429 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 420 device_path, chromeos::MOUNT_TYPE_DEVICE); |
430 lib->MountPath(device_path.c_str(), | |
431 chromeos::MOUNT_TYPE_DEVICE, | |
432 chromeos::MountPathOptions()); // Unused. | |
433 } else { | 421 } else { |
434 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 422 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
435 device_path); | 423 device_path); |
436 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, | 424 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, |
437 device_path); | 425 device_path); |
438 } | 426 } |
439 } | 427 } |
440 | 428 |
441 // ExtensionFileBrowserEventRouter::WatcherDelegate methods. | 429 // ExtensionFileBrowserEventRouter::WatcherDelegate methods. |
442 ExtensionFileBrowserEventRouter::FileWatcherDelegate::FileWatcherDelegate( | 430 ExtensionFileBrowserEventRouter::FileWatcherDelegate::FileWatcherDelegate( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 508 |
521 const FilePath& | 509 const FilePath& |
522 ExtensionFileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { | 510 ExtensionFileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { |
523 return virtual_path; | 511 return virtual_path; |
524 } | 512 } |
525 | 513 |
526 bool ExtensionFileBrowserEventRouter::FileWatcherExtensions::Watch | 514 bool ExtensionFileBrowserEventRouter::FileWatcherExtensions::Watch |
527 (const FilePath& path, FileWatcherDelegate* delegate) { | 515 (const FilePath& path, FileWatcherDelegate* delegate) { |
528 return file_watcher->Watch(path, delegate); | 516 return file_watcher->Watch(path, delegate); |
529 } | 517 } |
OLD | NEW |