OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ |
6 #define CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ | 6 #define CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... | |
39 // GetOption(index) from inside a call to OnOptionAdded will see the | 39 // GetOption(index) from inside a call to OnOptionAdded will see the |
40 // added string since the options have already been updated. | 40 // added string since the options have already been updated. |
41 virtual void OnOptionAdded(size_t index) = 0; | 41 virtual void OnOptionAdded(size_t index) = 0; |
42 | 42 |
43 // Called when GetOption(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 GetOption(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(size_t index) = 0; | 47 virtual void OnOptionRemoved(size_t index) = 0; |
48 | 48 |
49 // Called when the device adapter is truned on. | |
Reilly Grant (use Gerrit)
2016/07/15 21:55:20
s/truned/turned/
juncai
2016/07/18 20:14:16
Done.
| |
50 virtual void AdapterOn() = 0; | |
51 | |
52 // Called when the device adapter is truned off. | |
Reilly Grant (use Gerrit)
2016/07/15 21:55:20
s/truned/turned/
juncai
2016/07/18 20:14:16
Done.
| |
53 virtual void AdapterOff() = 0; | |
54 | |
55 // Called when refreshing options. | |
56 virtual void Refresh() = 0; | |
Reilly Grant (use Gerrit)
2016/07/15 21:55:20
I suggest calling these "RefreshInProgress" and "R
juncai
2016/07/18 20:14:16
Done.
| |
57 | |
58 // Called when refreshing options is complete. | |
59 virtual void Idle() = 0; | |
60 | |
49 protected: | 61 protected: |
50 virtual ~Observer() {} | 62 virtual ~Observer() {} |
51 }; | 63 }; |
52 | 64 |
53 // Returns the text to be displayed in the chooser title. | 65 // Returns the text to be displayed in the chooser title. |
54 base::string16 GetTitle() const; | 66 base::string16 GetTitle() const; |
55 | 67 |
56 // Returns the label for OK button. | 68 // Returns the label for OK button. |
57 virtual base::string16 GetOkButtonLabel() const = 0; | 69 virtual base::string16 GetOkButtonLabel() const = 0; |
58 | 70 |
59 // The number of options users can pick from. For example, it can be | 71 // The number of options users can pick from. For example, it can be |
60 // the number of USB/Bluetooth device names which are listed in the | 72 // the number of USB/Bluetooth device names which are listed in the |
61 // chooser so that users can grant permission. | 73 // chooser so that users can grant permission. |
62 virtual size_t NumOptions() const = 0; | 74 virtual size_t NumOptions() const = 0; |
63 | 75 |
64 // The |index|th option string which is listed in the chooser. | 76 // The |index|th option string which is listed in the chooser. |
65 virtual base::string16 GetOption(size_t index) const = 0; | 77 virtual base::string16 GetOption(size_t index) const = 0; |
66 | 78 |
79 // Refresh the list of options. | |
80 virtual void RefreshOptions() = 0; | |
81 | |
82 // Returns whether the chooser controller UI needs a throbber to show its | |
83 // status. | |
84 virtual bool NeedsThrobber() const = 0; | |
Reilly Grant (use Gerrit)
2016/07/15 21:55:20
This seems redundant. If the set of options is ref
juncai
2016/07/18 20:14:16
Done.
| |
85 | |
86 // Returns whether the chooser controller UI needs a text to show its status. | |
87 virtual bool NeedsStatus() const = 0; | |
Reilly Grant (use Gerrit)
2016/07/15 21:55:20
Maybe just call this "GetStatus" and return an emp
juncai
2016/07/18 20:14:16
Done.
| |
88 | |
67 // These three functions are called just before this object is destroyed: | 89 // These three functions are called just before this object is destroyed: |
68 | 90 |
69 // Called when the user selects the |index|th element from the dialog. | 91 // Called when the user selects the |index|th element from the dialog. |
70 virtual void Select(size_t index) = 0; | 92 virtual void Select(size_t index) = 0; |
71 | 93 |
72 // Called when the user presses the 'Cancel' button in the dialog. | 94 // Called when the user presses the 'Cancel' button in the dialog. |
73 virtual void Cancel() = 0; | 95 virtual void Cancel() = 0; |
74 | 96 |
75 // Called when the user clicks outside the dialog or the dialog otherwise | 97 // Called when the user clicks outside the dialog or the dialog otherwise |
76 // closes without the user taking an explicit action. | 98 // closes without the user taking an explicit action. |
77 virtual void Close() = 0; | 99 virtual void Close() = 0; |
78 | 100 |
79 // Open help center URL. | 101 // Open help center URL. |
80 virtual void OpenHelpCenterUrl() const = 0; | 102 virtual void OpenHelpCenterUrl() const = 0; |
81 | 103 |
82 // Only one observer may be registered at a time. | 104 // Only one observer may be registered at a time. |
83 void set_observer(Observer* observer) { observer_ = observer; } | 105 void set_observer(Observer* observer) { observer_ = observer; } |
84 Observer* observer() const { return observer_; } | 106 Observer* observer() const { return observer_; } |
85 | 107 |
86 private: | 108 private: |
87 content::RenderFrameHost* const owning_frame_; | 109 content::RenderFrameHost* const owning_frame_; |
88 const int title_string_id_origin_; | 110 const int title_string_id_origin_; |
89 const int title_string_id_extension_; | 111 const int title_string_id_extension_; |
90 Observer* observer_ = nullptr; | 112 Observer* observer_ = nullptr; |
91 | 113 |
92 DISALLOW_COPY_AND_ASSIGN(ChooserController); | 114 DISALLOW_COPY_AND_ASSIGN(ChooserController); |
93 }; | 115 }; |
94 | 116 |
95 #endif // CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ | 117 #endif // CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ |
OLD | NEW |