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