OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_DEVICE_PERMISSIONS_PROMPT_H_ | 5 #ifndef EXTENSIONS_BROWSER_DEVICE_PERMISSIONS_PROMPT_H_ |
6 #define EXTENSIONS_BROWSER_DEVICE_PERMISSIONS_PROMPT_H_ | 6 #define EXTENSIONS_BROWSER_DEVICE_PERMISSIONS_PROMPT_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 base::string16 serial_number_; | 61 base::string16 serial_number_; |
62 | 62 |
63 private: | 63 private: |
64 bool granted_ = false; | 64 bool granted_ = false; |
65 }; | 65 }; |
66 | 66 |
67 // Since the set of devices can change while the UI is visible an | 67 // Since the set of devices can change while the UI is visible an |
68 // implementation should register an observer. | 68 // implementation should register an observer. |
69 class Observer { | 69 class Observer { |
70 public: | 70 public: |
71 virtual void OnDevicesChanged() = 0; | 71 virtual void OnDeviceAdded(size_t index, |
| 72 const base::string16& device_name) = 0; |
| 73 virtual void OnDeviceRemoved(size_t index, |
| 74 const base::string16& device_name) = 0; |
72 | 75 |
73 protected: | 76 protected: |
74 virtual ~Observer(); | 77 virtual ~Observer(); |
75 }; | 78 }; |
76 | 79 |
77 Prompt(const Extension* extension, | 80 Prompt(const Extension* extension, |
78 content::BrowserContext* context, | 81 content::BrowserContext* context, |
79 bool multiple); | 82 bool multiple); |
80 | 83 |
81 // Only one observer may be registered at a time. | 84 // Only one observer may be registered at a time. |
82 virtual void SetObserver(Observer* observer); | 85 virtual void SetObserver(Observer* observer); |
83 | 86 |
84 virtual base::string16 GetHeading() const = 0; | |
85 base::string16 GetPromptMessage() const; | |
86 size_t GetDeviceCount() const { return devices_.size(); } | 87 size_t GetDeviceCount() const { return devices_.size(); } |
87 base::string16 GetDeviceName(size_t index) const; | 88 base::string16 GetDeviceName(size_t index) const; |
88 base::string16 GetDeviceSerialNumber(size_t index) const; | 89 base::string16 GetDeviceSerialNumber(size_t index) const; |
89 | 90 |
90 // Notifies the DevicePermissionsManager for the current extension that | 91 // Notifies the DevicePermissionsManager for the current extension that |
91 // access to the device at the given index is now granted. | 92 // access to the device at the given index is now granted. |
92 void GrantDevicePermission(size_t index); | 93 void GrantDevicePermission(size_t index); |
93 | 94 |
94 virtual void Dismissed() = 0; | 95 virtual void Dismissed() = 0; |
95 | 96 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 157 |
157 // Parameters available to the UI implementation. | 158 // Parameters available to the UI implementation. |
158 scoped_refptr<Prompt> prompt_; | 159 scoped_refptr<Prompt> prompt_; |
159 | 160 |
160 DISALLOW_COPY_AND_ASSIGN(DevicePermissionsPrompt); | 161 DISALLOW_COPY_AND_ASSIGN(DevicePermissionsPrompt); |
161 }; | 162 }; |
162 | 163 |
163 } // namespace extensions | 164 } // namespace extensions |
164 | 165 |
165 #endif // EXTENSIONS_BROWSER_API_DEVICE_PERMISSIONS_PROMPT_H_ | 166 #endif // EXTENSIONS_BROWSER_API_DEVICE_PERMISSIONS_PROMPT_H_ |
OLD | NEW |