| 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 |
| 11 namespace content { | 11 namespace content { |
| 12 class RenderFrameHost; | 12 class RenderFrameHost; |
| 13 } | 13 } |
| 14 | 14 |
| 15 namespace url { | |
| 16 class Origin; | |
| 17 } | |
| 18 | |
| 19 // Subclass ChooserController to implement a chooser, which has some | 15 // Subclass ChooserController to implement a chooser, which has some |
| 20 // introductory text and a list of options that users can pick one of. | 16 // introductory text and a list of options that users can pick one of. |
| 21 // Your subclass must define the set of options users can pick from; | 17 // Your subclass must define the set of options users can pick from; |
| 22 // the actions taken after users select an item or press the 'Cancel' | 18 // the actions taken after users select an item or press the 'Cancel' |
| 23 // button or the chooser is closed. | 19 // button or the chooser is closed. |
| 24 // After Select/Cancel/Close is called, this object is destroyed and | 20 // After Select/Cancel/Close is called, this object is destroyed and |
| 25 // calls back into it are not allowed. | 21 // calls back into it are not allowed. |
| 26 class ChooserController { | 22 class ChooserController { |
| 27 public: | 23 public: |
| 28 explicit ChooserController(content::RenderFrameHost* owner); | 24 explicit ChooserController(content::RenderFrameHost* owner); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 45 // Called when GetOption(index) is no longer present, and all later | 41 // Called when GetOption(index) is no longer present, and all later |
| 46 // options have been moved earlier by 1 slot. Calling GetOption(index) | 42 // options have been moved earlier by 1 slot. Calling GetOption(index) |
| 47 // from inside a call to OnOptionRemoved will NOT see the removed string | 43 // from inside a call to OnOptionRemoved will NOT see the removed string |
| 48 // since the options have already been updated. | 44 // since the options have already been updated. |
| 49 virtual void OnOptionRemoved(size_t index) = 0; | 45 virtual void OnOptionRemoved(size_t index) = 0; |
| 50 | 46 |
| 51 protected: | 47 protected: |
| 52 virtual ~Observer() {} | 48 virtual ~Observer() {} |
| 53 }; | 49 }; |
| 54 | 50 |
| 55 // Return the origin URL to be displayed on the chooser title. | 51 // Returns the text to be displayed in the chooser title. |
| 56 url::Origin GetOrigin() const; | 52 base::string16 GetTitle() const; |
| 57 | 53 |
| 58 // The number of options users can pick from. For example, it can be | 54 // The number of options users can pick from. For example, it can be |
| 59 // the number of USB/Bluetooth device names which are listed in the | 55 // the number of USB/Bluetooth device names which are listed in the |
| 60 // chooser so that users can grant permission. | 56 // chooser so that users can grant permission. |
| 61 virtual size_t NumOptions() const = 0; | 57 virtual size_t NumOptions() const = 0; |
| 62 | 58 |
| 63 // The |index|th option string which is listed in the chooser. | 59 // The |index|th option string which is listed in the chooser. |
| 64 virtual base::string16 GetOption(size_t index) const = 0; | 60 virtual base::string16 GetOption(size_t index) const = 0; |
| 65 | 61 |
| 66 // These three functions are called just before this object is destroyed: | 62 // These three functions are called just before this object is destroyed: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 83 Observer* observer() const { return observer_; } | 79 Observer* observer() const { return observer_; } |
| 84 | 80 |
| 85 private: | 81 private: |
| 86 content::RenderFrameHost* owning_frame_; | 82 content::RenderFrameHost* owning_frame_; |
| 87 Observer* observer_ = nullptr; | 83 Observer* observer_ = nullptr; |
| 88 | 84 |
| 89 DISALLOW_COPY_AND_ASSIGN(ChooserController); | 85 DISALLOW_COPY_AND_ASSIGN(ChooserController); |
| 90 }; | 86 }; |
| 91 | 87 |
| 92 #endif // CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ | 88 #endif // CHROME_BROWSER_CHOOSER_CONTROLLER_CHOOSER_CONTROLLER_H_ |
| OLD | NEW |