| 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) = 0; |
| 72 virtual void OnDeviceRemoved(size_t index) = 0; |
| 72 | 73 |
| 73 protected: | 74 protected: |
| 74 virtual ~Observer(); | 75 virtual ~Observer(); |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 Prompt(const Extension* extension, | 78 Prompt(const Extension* extension, |
| 78 content::BrowserContext* context, | 79 content::BrowserContext* context, |
| 79 bool multiple); | 80 bool multiple); |
| 80 | 81 |
| 81 // Only one observer may be registered at a time. | 82 // Only one observer may be registered at a time. |
| 82 virtual void SetObserver(Observer* observer); | 83 virtual void SetObserver(Observer* observer); |
| 83 | 84 |
| 84 virtual base::string16 GetHeading() const = 0; | |
| 85 base::string16 GetPromptMessage() const; | |
| 86 size_t GetDeviceCount() const { return devices_.size(); } | 85 size_t GetDeviceCount() const { return devices_.size(); } |
| 87 base::string16 GetDeviceName(size_t index) const; | 86 base::string16 GetDeviceName(size_t index) const; |
| 88 base::string16 GetDeviceSerialNumber(size_t index) const; | 87 base::string16 GetDeviceSerialNumber(size_t index) const; |
| 89 | 88 |
| 90 // Notifies the DevicePermissionsManager for the current extension that | 89 // Notifies the DevicePermissionsManager for the current extension that |
| 91 // access to the device at the given index is now granted. | 90 // access to the device at the given index is now granted. |
| 92 void GrantDevicePermission(size_t index); | 91 void GrantDevicePermission(size_t index); |
| 93 | 92 |
| 94 virtual void Dismissed() = 0; | 93 virtual void Dismissed() = 0; |
| 95 | 94 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 155 |
| 157 // Parameters available to the UI implementation. | 156 // Parameters available to the UI implementation. |
| 158 scoped_refptr<Prompt> prompt_; | 157 scoped_refptr<Prompt> prompt_; |
| 159 | 158 |
| 160 DISALLOW_COPY_AND_ASSIGN(DevicePermissionsPrompt); | 159 DISALLOW_COPY_AND_ASSIGN(DevicePermissionsPrompt); |
| 161 }; | 160 }; |
| 162 | 161 |
| 163 } // namespace extensions | 162 } // namespace extensions |
| 164 | 163 |
| 165 #endif // EXTENSIONS_BROWSER_API_DEVICE_PERMISSIONS_PROMPT_H_ | 164 #endif // EXTENSIONS_BROWSER_API_DEVICE_PERMISSIONS_PROMPT_H_ |
| OLD | NEW |