| 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_CONTROLLER_H_ | 
| 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_CONTROLLER_H_ | 
| 7 | 7 | 
| 8 #include <vector> | 8 #include <vector> | 
| 9 | 9 | 
| 10 #include "base/macros.h" | 10 #include "base/macros.h" | 
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" | 
| 12 #include "components/bubble/bubble_delegate.h" | 12 #include "components/bubble/bubble_delegate.h" | 
| 13 | 13 | 
| 14 class Browser; | 14 class Browser; | 
| 15 class GURL; | 15 class GURL; | 
| 16 | 16 | 
| 17 // Subclass ChooserBubbleDelegate to implement a chooser bubble, which has | 17 // Subclass ChooserBubbleController to implement a chooser bubble, which has | 
| 18 // some introductory text and a list of options that users can pick one of. | 18 // some introductory text and a list of options that users can pick one of. | 
| 19 // Create an instance of your subclass and pass it to | 19 // Create an instance of your subclass and pass it to | 
| 20 // BubbleManager::ShowBubble() to show the bubble. Your subclass must define | 20 // BubbleManager::ShowBubble() to show the bubble. Your subclass must define | 
| 21 // the set of options users can pick from; the actions taken after users | 21 // the set of options users can pick from; the actions taken after users | 
| 22 // select an item or press the 'Cancel' button or the bubble is closed. | 22 // select an item or press the 'Cancel' button or the bubble is closed. | 
| 23 // You can also override GetName() to identify the bubble you define for | 23 // You can also override GetName() to identify the bubble you define for | 
| 24 // collecting metrics. | 24 // collecting metrics. | 
| 25 // After Select/Cancel/Close is called, this object is destroyed and call back | 25 // After Select/Cancel/Close is called, this object is destroyed and call back | 
| 26 // into it is not allowed. | 26 // into it is not allowed. | 
| 27 // TODO(juncai): Change class name ChooserBubbleDelegate to | 27 class ChooserBubbleController : public BubbleDelegate { | 
| 28 // ChooserBubbleController since it better reflects its responsibilities and |  | 
| 29 // clarifies the roles of this class. |  | 
| 30 // https://crbug.com/588933 |  | 
| 31 class ChooserBubbleDelegate : public BubbleDelegate { |  | 
| 32  public: | 28  public: | 
| 33   explicit ChooserBubbleDelegate(content::RenderFrameHost* owner); | 29   explicit ChooserBubbleController(content::RenderFrameHost* owner); | 
| 34   ~ChooserBubbleDelegate() override; | 30   ~ChooserBubbleController() override; | 
| 35 | 31 | 
| 36   // Since the set of options can change while the UI is visible an | 32   // Since the set of options can change while the UI is visible an | 
| 37   // implementation should register an observer. | 33   // implementation should register an observer. | 
| 38   class Observer { | 34   class Observer { | 
| 39    public: | 35    public: | 
| 40     // Called after the options list is initialized for the first time. | 36     // Called after the options list is initialized for the first time. | 
| 41     // OnOptionsInitialized should only be called once. | 37     // OnOptionsInitialized should only be called once. | 
| 42     virtual void OnOptionsInitialized() = 0; | 38     virtual void OnOptionsInitialized() = 0; | 
| 43 | 39 | 
| 44     // Called after GetOption(index) has been added to the options and the | 40     // Called after GetOption(index) has been added to the options and the | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 90 | 86 | 
| 91   // Only one observer may be registered at a time. | 87   // Only one observer may be registered at a time. | 
| 92   void set_observer(Observer* observer) { observer_ = observer; } | 88   void set_observer(Observer* observer) { observer_ = observer; } | 
| 93   Observer* observer() const { return observer_; } | 89   Observer* observer() const { return observer_; } | 
| 94 | 90 | 
| 95  private: | 91  private: | 
| 96   Browser* browser_; | 92   Browser* browser_; | 
| 97   const content::RenderFrameHost* const owning_frame_; | 93   const content::RenderFrameHost* const owning_frame_; | 
| 98   Observer* observer_ = nullptr; | 94   Observer* observer_ = nullptr; | 
| 99 | 95 | 
| 100   DISALLOW_COPY_AND_ASSIGN(ChooserBubbleDelegate); | 96   DISALLOW_COPY_AND_ASSIGN(ChooserBubbleController); | 
| 101 }; | 97 }; | 
| 102 | 98 | 
| 103 #endif  // CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_DELEGATE_H_ | 99 #endif  // CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_CONTROLLER_H_ | 
| OLD | NEW | 
|---|