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

Side by Side Diff: chrome/browser/chromeos/cros/mount_library.cc

Issue 8049002: Don't show hidden devices in UI (exept from imageburner). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 'mock library update' Created 9 years, 2 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
OLDNEW
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/cros/mount_library.h" 5 #include "chrome/browser/chromeos/cros/mount_library.h"
6 6
7 #include <set> 7 #include <set>
8 #include <sys/statvfs.h> 8 #include <sys/statvfs.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const std::string& file_path, 69 const std::string& file_path,
70 const std::string& device_label, 70 const std::string& device_label,
71 const std::string& drive_label, 71 const std::string& drive_label,
72 const std::string& parent_path, 72 const std::string& parent_path,
73 const std::string& system_path_prefix, 73 const std::string& system_path_prefix,
74 DeviceType device_type, 74 DeviceType device_type,
75 uint64 total_size, 75 uint64 total_size,
76 bool is_parent, 76 bool is_parent,
77 bool is_read_only, 77 bool is_read_only,
78 bool has_media, 78 bool has_media,
79 bool on_boot_device) 79 bool on_boot_device,
80 bool is_hidden)
80 : device_path_(device_path), 81 : device_path_(device_path),
81 mount_path_(mount_path), 82 mount_path_(mount_path),
82 system_path_(system_path), 83 system_path_(system_path),
83 file_path_(file_path), 84 file_path_(file_path),
84 device_label_(device_label), 85 device_label_(device_label),
85 drive_label_(drive_label), 86 drive_label_(drive_label),
86 parent_path_(parent_path), 87 parent_path_(parent_path),
87 system_path_prefix_(system_path_prefix), 88 system_path_prefix_(system_path_prefix),
88 device_type_(device_type), 89 device_type_(device_type),
89 total_size_(total_size), 90 total_size_(total_size),
90 is_parent_(is_parent), 91 is_parent_(is_parent),
91 is_read_only_(is_read_only), 92 is_read_only_(is_read_only),
92 has_media_(has_media), 93 has_media_(has_media),
93 on_boot_device_(on_boot_device) { 94 on_boot_device_(on_boot_device),
95 is_hidden_(is_hidden) {
94 } 96 }
95 97
96 MountLibrary::Disk::~Disk() {} 98 MountLibrary::Disk::~Disk() {}
97 99
98 class MountLibcrosProxyImpl : public MountLibcrosProxy { 100 class MountLibcrosProxyImpl : public MountLibcrosProxy {
99 public: 101 public:
100 virtual void CallMountPath(const char* source_path, 102 virtual void CallMountPath(const char* source_path,
101 MountType type, 103 MountType type,
102 const MountPathOptions& options, 104 const MountPathOptions& options,
103 MountCompletedMonitor callback, 105 MountCompletedMonitor callback,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 observers_.AddObserver(observer); 187 observers_.AddObserver(observer);
186 } 188 }
187 189
188 virtual void RemoveObserver(Observer* observer) OVERRIDE { 190 virtual void RemoveObserver(Observer* observer) OVERRIDE {
189 observers_.RemoveObserver(observer); 191 observers_.RemoveObserver(observer);
190 } 192 }
191 193
192 virtual void MountPath(const char* source_path, 194 virtual void MountPath(const char* source_path,
193 MountType type, 195 MountType type,
194 const MountPathOptions& options) OVERRIDE { 196 const MountPathOptions& options) OVERRIDE {
197 // Hidden and non-existent devices should not be mounted.
198 if (type == MOUNT_TYPE_DEVICE) {
199 DiskMap::const_iterator it = disks_.find(source_path);
200 if (it == disks_.end() || it->second->is_hidden()) {
201 MountCompletedHandler(this, MOUNT_ERROR_INTERNAL, source_path, type,
202 NULL);
203 return;
204 }
205 }
195 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 206 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
196 libcros_proxy_->CallMountPath(source_path, type, options, 207 libcros_proxy_->CallMountPath(source_path, type, options,
197 &MountCompletedHandler, this); 208 &MountCompletedHandler, this);
198 } 209 }
199 210
200 virtual void UnmountPath(const char* mount_path) OVERRIDE { 211 virtual void UnmountPath(const char* mount_path) OVERRIDE {
201 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 212 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
202 libcros_proxy_->CallUnmountPath(mount_path, &UnmountMountPointCallback, 213 libcros_proxy_->CallUnmountPath(mount_path, &UnmountMountPointCallback,
203 this); 214 this);
204 } 215 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 FireDeviceStatusUpdate(MOUNT_FORMATTING_STARTED, device_path); 541 FireDeviceStatusUpdate(MOUNT_FORMATTING_STARTED, device_path);
531 } else { 542 } else {
532 FireDeviceStatusUpdate(MOUNT_FORMATTING_STARTED, 543 FireDeviceStatusUpdate(MOUNT_FORMATTING_STARTED,
533 std::string("!") + device_path); 544 std::string("!") + device_path);
534 LOG(WARNING) << "Format request failed for device " 545 LOG(WARNING) << "Format request failed for device "
535 << device_path << ", with error: " 546 << device_path << ", with error: "
536 << (error_message ? error_message : "Unknown"); 547 << (error_message ? error_message : "Unknown");
537 } 548 }
538 } 549 }
539 550
540
541 void OnGetDiskProperties(const char* device_path, 551 void OnGetDiskProperties(const char* device_path,
542 const DiskInfo* disk1, 552 const DiskInfo* disk,
543 MountMethodErrorType error, 553 MountMethodErrorType error,
544 const char* error_message) { 554 const char* error_message) {
545 DCHECK(device_path); 555 DCHECK(device_path);
546 if (error == MOUNT_METHOD_ERROR_NONE && device_path) { 556 if (error == MOUNT_METHOD_ERROR_NONE && device_path) {
547 // TODO(zelidrag): Find a better way to filter these out before we 557 // TODO(zelidrag): Find a better way to filter these out before we
548 // fetch the properties: 558 // fetch the properties:
549 // Ignore disks coming from the device we booted the system from. 559 // Ignore disks coming from the device we booted the system from.
550 560
551 // This cast is temporal solution, until we merge DiskInfo and 561 // This cast is temporal solution, until we merge DiskInfo and
552 // DiskInfoAdvanced into single interface. 562 // DiskInfoAdvanced into single interface.
553 const DiskInfoAdvanced* disk =
554 reinterpret_cast<const DiskInfoAdvanced*>(disk1);
555 if (disk->on_boot_device()) 563 if (disk->on_boot_device())
556 return; 564 return;
557 565
558 LOG(WARNING) << "Found disk " << device_path; 566 LOG(WARNING) << "Found disk " << device_path;
559 // Delete previous disk info for this path: 567 // Delete previous disk info for this path:
560 bool is_new = true; 568 bool is_new = true;
561 std::string device_path_string(device_path); 569 std::string device_path_string(device_path);
562 DiskMap::iterator iter = disks_.find(device_path_string); 570 DiskMap::iterator iter = disks_.find(device_path_string);
563 if (iter != disks_.end()) { 571 if (iter != disks_.end()) {
564 delete iter->second; 572 delete iter->second;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 filepath, 609 filepath,
602 devicelabel, 610 devicelabel,
603 drivelabel, 611 drivelabel,
604 parentpath, 612 parentpath,
605 FindSystemPathPrefix(systempath), 613 FindSystemPathPrefix(systempath),
606 disk->device_type(), 614 disk->device_type(),
607 disk->size(), 615 disk->size(),
608 disk->is_drive(), 616 disk->is_drive(),
609 disk->is_read_only(), 617 disk->is_read_only(),
610 disk->has_media(), 618 disk->has_media(),
611 disk->on_boot_device()); 619 disk->on_boot_device(),
620 disk->is_hidden());
612 disks_.insert( 621 disks_.insert(
613 std::pair<std::string, Disk*>(device_path_string, new_disk)); 622 std::pair<std::string, Disk*>(device_path_string, new_disk));
614 FireDiskStatusUpdate(is_new ? MOUNT_DISK_ADDED : MOUNT_DISK_CHANGED, 623 FireDiskStatusUpdate(is_new ? MOUNT_DISK_ADDED : MOUNT_DISK_CHANGED,
615 new_disk); 624 new_disk);
616 } else { 625 } else {
617 LOG(WARNING) << "Property retrieval request failed for device " 626 LOG(WARNING) << "Property retrieval request failed for device "
618 << device_path << ", with error: " 627 << device_path << ", with error: "
619 << (error_message ? error_message : "Unknown"); 628 << (error_message ? error_message : "Unknown");
620 } 629 }
621 } 630 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 MountLibrary* impl; 838 MountLibrary* impl;
830 if (stub) 839 if (stub)
831 impl = new MountLibraryStubImpl(); 840 impl = new MountLibraryStubImpl();
832 else 841 else
833 impl = new MountLibraryImpl(); 842 impl = new MountLibraryImpl();
834 impl->Init(); 843 impl->Init();
835 return impl; 844 return impl;
836 } 845 }
837 846
838 } // namespace chromeos 847 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/mount_library.h ('k') | chrome/browser/chromeos/extensions/file_browser_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698