Index: chrome/browser/ui/website_settings/chooser_bubble_controller.h |
diff --git a/chrome/browser/ui/website_settings/chooser_bubble_controller.h b/chrome/browser/ui/website_settings/chooser_bubble_controller.h |
index 3a75e86382140485463d37ee3a0369223abb231f..cb41c93dbb1b1017f8a4c00935b5c2bdfe9f381a 100644 |
--- a/chrome/browser/ui/website_settings/chooser_bubble_controller.h |
+++ b/chrome/browser/ui/website_settings/chooser_bubble_controller.h |
@@ -6,97 +6,35 @@ |
#define CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_CONTROLLER_H_ |
#include "base/macros.h" |
-#include "base/strings/string16.h" |
#include "components/bubble/bubble_delegate.h" |
+#include "components/ui/chooser_controller/chooser_controller.h" |
class Browser; |
-class GURL; |
-namespace url { |
-class Origin; |
+namespace content { |
+class RenderFrameHost; |
} |
-// Subclass ChooserBubbleController to implement a chooser bubble, which has |
-// some introductory text and a list of options that users can pick one of. |
-// Create an instance of your subclass and pass it to |
-// BubbleManager::ShowBubble() to show the bubble. Your subclass must define |
-// the set of options users can pick from; the actions taken after users |
-// select an item or press the 'Cancel' button or the bubble is closed. |
+// Subclass ChooserBubbleController to implement a chooser bubble. |
// You can also override GetName() to identify the bubble you define for |
-// collecting metrics. |
-// After Select/Cancel/Close is called, this object is destroyed and call back |
-// into it is not allowed. |
-class ChooserBubbleController : public BubbleDelegate { |
+// collecting metrics. Create an instance of your subclass and pass |
+// it to BubbleManager::ShowBubble() to show the bubble. |
+class ChooserBubbleController : public BubbleDelegate, |
+ public ChooserController { |
public: |
explicit ChooserBubbleController(content::RenderFrameHost* owner); |
~ChooserBubbleController() override; |
- // Since the set of options can change while the UI is visible an |
- // implementation should register an observer. |
- class Observer { |
- public: |
- // Called after the options list is initialized for the first time. |
- // OnOptionsInitialized should only be called once. |
- virtual void OnOptionsInitialized() = 0; |
- |
- // Called after GetOption(index) has been added to the options and the |
- // newly added option is the last element in the options list. Calling |
- // GetOption(index) from inside a call to OnOptionAdded will see the |
- // added string since the options have already been updated. |
- virtual void OnOptionAdded(size_t index) = 0; |
- |
- // Called when GetOption(index) is no longer present, and all later |
- // options have been moved earlier by 1 slot. Calling GetOption(index) |
- // from inside a call to OnOptionRemoved will NOT see the removed string |
- // since the options have already been updated. |
- virtual void OnOptionRemoved(size_t index) = 0; |
- |
- protected: |
- virtual ~Observer() {} |
- }; |
- |
- // Return the origin URL to be displayed on the bubble title. |
- url::Origin GetOrigin() const; |
- |
- // Open help center URL. |
- void OpenHelpCenterUrl() const; |
- |
// BubbleDelegate: |
std::string GetName() const override; |
std::unique_ptr<BubbleUi> BuildBubbleUi() override; |
const content::RenderFrameHost* OwningFrame() const override; |
- // The number of options users can pick from. For example, it can be |
- // the number of USB/Bluetooth device names which are listed in the |
- // chooser bubble so that users can grant permission. |
- virtual size_t NumOptions() const = 0; |
- |
- // The |index|th option string which is listed in the chooser bubble. |
- virtual const base::string16& GetOption(size_t index) const = 0; |
- |
- // These three functions are called just before this object is destroyed: |
- |
- // Called when the user selects the |index|th element from the dialog. |
- virtual void Select(size_t index) = 0; |
- |
- // Called when the user presses the 'Cancel' button in the dialog. |
- virtual void Cancel() = 0; |
- |
- // Called when the user clicks outside the dialog or the dialog otherwise |
- // closes without the user taking an explicit action. |
- virtual void Close() = 0; |
- |
- // Get help center URL. |
- virtual GURL GetHelpCenterUrl() const = 0; |
- |
- // Only one observer may be registered at a time. |
- void set_observer(Observer* observer) { observer_ = observer; } |
- Observer* observer() const { return observer_; } |
+ // ChooserController: |
+ void OpenHelpCenterUrl() const override; |
private: |
Browser* browser_; |
- const content::RenderFrameHost* const owning_frame_; |
- Observer* observer_ = nullptr; |
DISALLOW_COPY_AND_ASSIGN(ChooserBubbleController); |
}; |