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

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

Issue 9969148: Hide scanning notification when device with no media is detected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/imageburner/burn_controller.cc » ('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 (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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 std::string args_json; 305 std::string args_json;
306 base::JSONWriter::Write(&args, &args_json); 306 base::JSONWriter::Write(&args, &args_json);
307 307
308 profile_->GetExtensionEventRouter()->DispatchEventToExtension( 308 profile_->GetExtensionEventRouter()->DispatchEventToExtension(
309 iter->first, extension_event_names::kOnFileChanged, args_json, 309 iter->first, extension_event_names::kOnFileChanged, args_json,
310 NULL, GURL()); 310 NULL, GURL());
311 } 311 }
312 } 312 }
313 313
314 // TODO(tbarzic): This is not used anymore. Remove it.
314 void FileBrowserEventRouter::DispatchDiskEvent( 315 void FileBrowserEventRouter::DispatchDiskEvent(
315 const DiskMountManager::Disk* disk, bool added) { 316 const DiskMountManager::Disk* disk, bool added) {
316 if (!profile_) { 317 if (!profile_) {
317 NOTREACHED(); 318 NOTREACHED();
318 return; 319 return;
319 } 320 }
320 321
321 ListValue args; 322 ListValue args;
322 DictionaryValue* mount_info = new DictionaryValue(); 323 DictionaryValue* mount_info = new DictionaryValue();
323 args.Append(mount_info); 324 args.Append(mount_info);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 } 405 }
405 406
406 void FileBrowserEventRouter::OnDiskAdded( 407 void FileBrowserEventRouter::OnDiskAdded(
407 const DiskMountManager::Disk* disk) { 408 const DiskMountManager::Disk* disk) {
408 VLOG(1) << "Disk added: " << disk->device_path(); 409 VLOG(1) << "Disk added: " << disk->device_path();
409 if (disk->device_path().empty()) { 410 if (disk->device_path().empty()) {
410 VLOG(1) << "Empty system path for " << disk->device_path(); 411 VLOG(1) << "Empty system path for " << disk->device_path();
411 return; 412 return;
412 } 413 }
413 414
414 // If disk is not mounted yet, give it a try. 415 // If disk is not mounted yet and it has media, give it a try.
415 if (disk->mount_path().empty()) { 416 if (disk->mount_path().empty() && disk->has_media()) {
416 // Initiate disk mount operation. 417 // Initiate disk mount operation.
417 DiskMountManager::GetInstance()->MountPath( 418 DiskMountManager::GetInstance()->MountPath(
418 disk->device_path(), chromeos::MOUNT_TYPE_DEVICE); 419 disk->device_path(), chromeos::MOUNT_TYPE_DEVICE);
420 } else {
421 // Either the disk was mounted or it has no media. In eithed case we don't
Ben Chan 2012/04/11 02:47:52 type: eithed -> either
422 // want the Scanning notification to persist.
423 notifications_->HideNotification(FileBrowserNotifications::DEVICE,
424 disk->system_path_prefix());
419 } 425 }
420 DispatchDiskEvent(disk, true); 426 DispatchDiskEvent(disk, true);
421 } 427 }
422 428
423 void FileBrowserEventRouter::OnDiskRemoved( 429 void FileBrowserEventRouter::OnDiskRemoved(
424 const DiskMountManager::Disk* disk) { 430 const DiskMountManager::Disk* disk) {
425 VLOG(1) << "Disk removed: " << disk->device_path(); 431 VLOG(1) << "Disk removed: " << disk->device_path();
426 432
427 if (!disk->mount_path().empty()) { 433 if (!disk->mount_path().empty()) {
428 DiskMountManager::GetInstance()->UnmountPath(disk->mount_path()); 434 DiskMountManager::GetInstance()->UnmountPath(disk->mount_path());
429 } 435 }
430 DispatchDiskEvent(disk, false); 436 DispatchDiskEvent(disk, false);
431 } 437 }
432 438
433 void FileBrowserEventRouter::OnDeviceAdded( 439 void FileBrowserEventRouter::OnDeviceAdded(
434 const std::string& device_path) { 440 const std::string& device_path) {
435 VLOG(1) << "Device added : " << device_path; 441 VLOG(1) << "Device added : " << device_path;
436 442
437 notifications_->RegisterDevice(device_path); 443 notifications_->RegisterDevice(device_path);
438 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, 444 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE,
439 device_path, 445 device_path,
440 4000); 446 5000);
441 } 447 }
442 448
443 void FileBrowserEventRouter::OnDeviceRemoved( 449 void FileBrowserEventRouter::OnDeviceRemoved(
444 const std::string& device_path) { 450 const std::string& device_path) {
445 VLOG(1) << "Device removed : " << device_path; 451 VLOG(1) << "Device removed : " << device_path;
446 notifications_->HideNotification(FileBrowserNotifications::DEVICE, 452 notifications_->HideNotification(FileBrowserNotifications::DEVICE,
447 device_path); 453 device_path);
448 notifications_->HideNotification(FileBrowserNotifications::DEVICE_FAIL, 454 notifications_->HideNotification(FileBrowserNotifications::DEVICE_FAIL,
449 device_path); 455 device_path);
450 notifications_->UnregisterDevice(device_path); 456 notifications_->UnregisterDevice(device_path);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 return scoped_refptr<RefcountedProfileKeyedService>( 617 return scoped_refptr<RefcountedProfileKeyedService>(
612 new FileBrowserEventRouter(profile)); 618 new FileBrowserEventRouter(profile));
613 } 619 }
614 620
615 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { 621 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() {
616 // Explicitly and always allow this router in guest login mode. see 622 // Explicitly and always allow this router in guest login mode. see
617 // chrome/browser/profiles/profile_keyed_base_factory.h comment 623 // chrome/browser/profiles/profile_keyed_base_factory.h comment
618 // for the details. 624 // for the details.
619 return true; 625 return true;
620 } 626 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/imageburner/burn_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698