Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 explicit ChooserBubbleDelegate(Browser* browser); | 28 explicit ChooserBubbleDelegate(Browser* browser); |
| 29 ~ChooserBubbleDelegate() override; | 29 ~ChooserBubbleDelegate() override; |
| 30 | 30 |
| 31 // Since the set of options can change while the UI is visible an | 31 // Since the set of options can change while the UI is visible an |
| 32 // implementation should register an observer. | 32 // implementation should register an observer. |
| 33 class Observer { | 33 class Observer { |
| 34 public: | 34 public: |
| 35 // Called after the options list is initialized for the first time. | 35 // Called after the options list is initialized for the first time. |
| 36 // OnOptionsInitialized should only be called once. | 36 // OnOptionsInitialized should only be called once. |
| 37 virtual void OnOptionsInitialized() = 0; | 37 virtual void OnOptionsInitialized() = 0; |
| 38 // Called after GetOptions()[index] has been added to the options and the | 38 // Called after GetOption(index) has been added to the options and the |
|
Peter Kasting
2016/01/04 21:02:52
Nit: Everywhere in this file: Please put a blank l
juncai
2016/01/04 22:44:47
Done.
| |
| 39 // newly added option is the last element in the options list. Calling | 39 // newly added option is the last element in the options list. Calling |
| 40 // GetOptions()[index] from inside a call to OnOptionAdded will see the | 40 // GetOption(index) from inside a call to OnOptionAdded will see the |
| 41 // added string since the options have already been updated. | 41 // added string since the options have already been updated. |
| 42 virtual void OnOptionAdded(int index) = 0; | 42 virtual void OnOptionAdded(size_t index) = 0; |
| 43 // Called when GetOptions()[index] is no longer present, and all later | 43 // Called when GetOption(index) is no longer present, and all later |
| 44 // options have been moved earlier by 1 slot. Calling GetOptions()[index] | 44 // options have been moved earlier by 1 slot. Calling GetOption(index) |
| 45 // from inside a call to OnOptionRemoved will NOT see the removed string | 45 // from inside a call to OnOptionRemoved will NOT see the removed string |
| 46 // since the options have already been updated. | 46 // since the options have already been updated. |
| 47 virtual void OnOptionRemoved(int index) = 0; | 47 virtual void OnOptionRemoved(size_t index) = 0; |
| 48 | 48 |
| 49 protected: | 49 protected: |
| 50 virtual ~Observer() {} | 50 virtual ~Observer() {} |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // BubbleDelegate: | 53 // BubbleDelegate: |
| 54 std::string GetName() const override; | 54 std::string GetName() const override; |
| 55 scoped_ptr<BubbleUi> BuildBubbleUi() override; | 55 scoped_ptr<BubbleUi> BuildBubbleUi() override; |
| 56 | 56 |
| 57 // The set of options users can pick from. For example, it can be | 57 // The number of options users can pick from. For example, it can be |
| 58 // USB/Bluetooth devices names which are listed in the chooser bubble | 58 // the number of USB/Bluetooth device names which are listed in the |
| 59 // so that users can grant permission. | 59 // chooser bubble so that users can grant permission. |
| 60 virtual const std::vector<base::string16>& GetOptions() const = 0; | 60 virtual size_t NumOptions() const = 0; |
| 61 // The |index|th option string which is listed in the chooser bubble. | |
| 62 virtual const base::string16& GetOption(size_t index) const = 0; | |
| 61 | 63 |
| 62 // These three functions are called just before this object is destroyed: | 64 // These three functions are called just before this object is destroyed: |
| 63 // Called when the user selects the |index|th element from the dialog. | 65 // Called when the user selects the |index|th element from the dialog. |
| 64 virtual void Select(int index) = 0; | 66 virtual void Select(size_t index) = 0; |
| 65 // Called when the user presses the 'Cancel' button in the dialog. | 67 // Called when the user presses the 'Cancel' button in the dialog. |
| 66 virtual void Cancel() = 0; | 68 virtual void Cancel() = 0; |
| 67 // Called when the user clicks outside the dialog or the dialog otherwise | 69 // Called when the user clicks outside the dialog or the dialog otherwise |
| 68 // closes without the user taking an explicit action. | 70 // closes without the user taking an explicit action. |
| 69 virtual void Close() = 0; | 71 virtual void Close() = 0; |
| 70 | 72 |
| 71 // Only one observer may be registered at a time. | 73 // Only one observer may be registered at a time. |
| 72 void set_observer(Observer* observer) { observer_ = observer; } | 74 void set_observer(Observer* observer) { observer_ = observer; } |
| 73 Observer* observer() const { return observer_; } | 75 Observer* observer() const { return observer_; } |
| 74 | 76 |
| 75 private: | 77 private: |
| 76 Browser* browser_; | 78 Browser* browser_; |
| 77 Observer* observer_ = nullptr; | 79 Observer* observer_ = nullptr; |
| 78 | 80 |
| 79 DISALLOW_COPY_AND_ASSIGN(ChooserBubbleDelegate); | 81 DISALLOW_COPY_AND_ASSIGN(ChooserBubbleDelegate); |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_DELEGATE_H_ | 84 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_DELEGATE_H_ |
| OLD | NEW |