Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / storage_monitor / storage_info.h
blobf36cc28c29a3df6c4c16ebac36c52e97f34989ab
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_INFO_H_
6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_INFO_H_
8 #include "base/files/file_path.h"
9 #include "base/strings/string16.h"
11 struct StorageInfo {
12 public:
13 enum Type {
14 // A removable mass storage device with a DCIM directory.
15 REMOVABLE_MASS_STORAGE_WITH_DCIM,
16 // A removable mass storage device without a DCIM directory.
17 REMOVABLE_MASS_STORAGE_NO_DCIM,
18 // A fixed mass storage device.
19 FIXED_MASS_STORAGE,
20 // A MTP or PTP device.
21 MTP_OR_PTP,
22 // A Mac ImageCapture device.
23 MAC_IMAGE_CAPTURE,
24 // An iTunes library.
25 ITUNES,
26 // A Picasa database.
27 PICASA,
28 // An iPhoto library.
29 IPHOTO,
32 StorageInfo();
33 // Note: |device_id_in| should be constructed with MakeDeviceId.
34 StorageInfo(const std::string& device_id_in,
35 const base::string16& device_name,
36 const base::FilePath::StringType& device_location,
37 const base::string16& label,
38 const base::string16& vendor,
39 const base::string16& model,
40 uint64 size_in_bytes);
41 ~StorageInfo();
43 // Returns a device id given properties of the device. A prefix dependent on
44 // |type| is added so |unique_id| need only be unique within the given type.
45 // Returns an empty string if an invalid type is passed in.
46 static std::string MakeDeviceId(Type type, const std::string& unique_id);
48 // Extracts the device |type| and |unique_id| from |device_id|. Returns false
49 // if the device_id isn't properly formatted.
50 static bool CrackDeviceId(const std::string& device_id,
51 Type* type, std::string* unique_id);
53 // Looks inside |device_id| to determine if it is a media device
54 // (type is REMOVABLE_MASS_STORAGE_WITH_DCIM or MTP_OR_PTP).
55 static bool IsMediaDevice(const std::string& device_id);
57 // Looks inside |device_id| to determine if it is a media device
58 // (type isn't FIXED_MASS_STORAGE).
59 static bool IsRemovableDevice(const std::string& device_id);
61 // Looks inside |device_id| to determine if it is a mass storage device
62 // (type isn't MTP_OR_PTP).
63 static bool IsMassStorageDevice(const std::string& device_id);
65 static bool IsITunesDevice(const std::string& device_id);
67 static bool IsPicasaDevice(const std::string& device_id);
69 static bool IsIPhotoDevice(const std::string& device_id);
71 const std::string& device_id() const { return device_id_; }
72 const base::string16& name() const { return name_; }
73 const base::FilePath::StringType& location() const { return location_; }
74 const base::string16& storage_label() const { return storage_label_; }
75 const base::string16& vendor_name() const { return vendor_name_; }
76 const base::string16& model_name() const { return model_name_; }
77 uint64 total_size_in_bytes() const { return total_size_in_bytes_; }
79 void set_device_id(const std::string& device_id) { device_id_ = device_id; }
80 void set_name(const base::string16& name) { name_ = name; }
81 void set_location(const base::FilePath::StringType& location) {
82 location_ = location;
85 private:
86 // Unique device id - persists between device attachments.
87 // This is the string that should be used as the label for a particular
88 // storage device when interacting with the API. Clients should treat
89 // this as an opaque string.
90 std::string device_id_;
92 // Human readable removable storage device name.
93 base::string16 name_;
95 // Current attached removable storage device location.
96 base::FilePath::StringType location_;
98 // Label given to this storage device by the user.
99 // May be empty if not found or the device is unlabeled.
100 base::string16 storage_label_;
102 // Vendor name for the removable device. (Human readable)
103 // May be empty if not collected.
104 base::string16 vendor_name_;
106 // Model name for the removable device. (Human readable)
107 // May be empty if not collected.
108 base::string16 model_name_;
110 // Size of the removable device in bytes.
111 // Zero if not collected or unknown.
112 uint64 total_size_in_bytes_;
115 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_INFO_H_