Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: chrome/browser/ui/website_settings/chooser_bubble_delegate.h

Issue 1661063002: Add message and Help Center link to the chooser UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address estade@'s comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
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 16
16 // Subclass ChooserBubbleDelegate to implement a chooser bubble, which has 17 // Subclass ChooserBubbleDelegate to implement a chooser bubble, which has
17 // 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.
18 // Create an instance of your subclass and pass it to 19 // Create an instance of your subclass and pass it to
19 // BubbleManager::ShowBubble() to show the bubble. Your subclass must define 20 // BubbleManager::ShowBubble() to show the bubble. Your subclass must define
20 // 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
21 // 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.
22 // 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
23 // collecting metrics. 24 // collecting metrics.
24 // 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
25 // into it is not allowed. 26 // into it is not allowed.
27 // TODO(juncai): Change class name ChooserBubbleDelegate to
28 // ChooserBubbleController since it better reflects its responsibilities and
29 // clarifies the roles of this class.
30 // https://crbug.com/588933
26 class ChooserBubbleDelegate : public BubbleDelegate { 31 class ChooserBubbleDelegate : public BubbleDelegate {
27 public: 32 public:
28 explicit ChooserBubbleDelegate(content::RenderFrameHost* owner); 33 explicit ChooserBubbleDelegate(content::RenderFrameHost* owner);
29 ~ChooserBubbleDelegate() override; 34 ~ChooserBubbleDelegate() override;
30 35
31 // Since the set of options can change while the UI is visible an 36 // Since the set of options can change while the UI is visible an
32 // implementation should register an observer. 37 // implementation should register an observer.
33 class Observer { 38 class Observer {
34 public: 39 public:
35 // Called after the options list is initialized for the first time. 40 // Called after the options list is initialized for the first time.
36 // OnOptionsInitialized should only be called once. 41 // OnOptionsInitialized should only be called once.
37 virtual void OnOptionsInitialized() = 0; 42 virtual void OnOptionsInitialized() = 0;
38 43
39 // Called after GetOption(index) has been added to the options and the 44 // Called after GetOption(index) has been added to the options and the
40 // newly added option is the last element in the options list. Calling 45 // newly added option is the last element in the options list. Calling
41 // GetOption(index) from inside a call to OnOptionAdded will see the 46 // GetOption(index) from inside a call to OnOptionAdded will see the
42 // added string since the options have already been updated. 47 // added string since the options have already been updated.
43 virtual void OnOptionAdded(size_t index) = 0; 48 virtual void OnOptionAdded(size_t index) = 0;
44 49
45 // Called when GetOption(index) is no longer present, and all later 50 // Called when GetOption(index) is no longer present, and all later
46 // options have been moved earlier by 1 slot. Calling GetOption(index) 51 // options have been moved earlier by 1 slot. Calling GetOption(index)
47 // from inside a call to OnOptionRemoved will NOT see the removed string 52 // from inside a call to OnOptionRemoved will NOT see the removed string
48 // since the options have already been updated. 53 // since the options have already been updated.
49 virtual void OnOptionRemoved(size_t index) = 0; 54 virtual void OnOptionRemoved(size_t index) = 0;
50 55
51 protected: 56 protected:
52 virtual ~Observer() {} 57 virtual ~Observer() {}
53 }; 58 };
54 59
60 // Open help center URL.
61 void OpenHelpCenterUrl() const;
62
55 // BubbleDelegate: 63 // BubbleDelegate:
56 std::string GetName() const override; 64 std::string GetName() const override;
57 scoped_ptr<BubbleUi> BuildBubbleUi() override; 65 scoped_ptr<BubbleUi> BuildBubbleUi() override;
58 const content::RenderFrameHost* OwningFrame() const override; 66 const content::RenderFrameHost* OwningFrame() const override;
59 67
60 // The number of options users can pick from. For example, it can be 68 // The number of options users can pick from. For example, it can be
61 // the number of USB/Bluetooth device names which are listed in the 69 // the number of USB/Bluetooth device names which are listed in the
62 // chooser bubble so that users can grant permission. 70 // chooser bubble so that users can grant permission.
63 virtual size_t NumOptions() const = 0; 71 virtual size_t NumOptions() const = 0;
64 72
65 // The |index|th option string which is listed in the chooser bubble. 73 // The |index|th option string which is listed in the chooser bubble.
66 virtual const base::string16& GetOption(size_t index) const = 0; 74 virtual const base::string16& GetOption(size_t index) const = 0;
67 75
68 // These three functions are called just before this object is destroyed: 76 // These three functions are called just before this object is destroyed:
69 77
70 // Called when the user selects the |index|th element from the dialog. 78 // Called when the user selects the |index|th element from the dialog.
71 virtual void Select(size_t index) = 0; 79 virtual void Select(size_t index) = 0;
72 80
73 // Called when the user presses the 'Cancel' button in the dialog. 81 // Called when the user presses the 'Cancel' button in the dialog.
74 virtual void Cancel() = 0; 82 virtual void Cancel() = 0;
75 83
76 // Called when the user clicks outside the dialog or the dialog otherwise 84 // Called when the user clicks outside the dialog or the dialog otherwise
77 // closes without the user taking an explicit action. 85 // closes without the user taking an explicit action.
78 virtual void Close() = 0; 86 virtual void Close() = 0;
79 87
88 // Get help center URL.
89 virtual GURL GetHelpCenterUrl() const = 0;
90
80 // Only one observer may be registered at a time. 91 // Only one observer may be registered at a time.
81 void set_observer(Observer* observer) { observer_ = observer; } 92 void set_observer(Observer* observer) { observer_ = observer; }
82 Observer* observer() const { return observer_; } 93 Observer* observer() const { return observer_; }
83 94
84 private: 95 private:
85 Browser* browser_; 96 Browser* browser_;
86 const content::RenderFrameHost* const owning_frame_; 97 const content::RenderFrameHost* const owning_frame_;
87 Observer* observer_ = nullptr; 98 Observer* observer_ = nullptr;
88 99
89 DISALLOW_COPY_AND_ASSIGN(ChooserBubbleDelegate); 100 DISALLOW_COPY_AND_ASSIGN(ChooserBubbleDelegate);
90 }; 101 };
91 102
92 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_DELEGATE_H_ 103 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_CHOOSER_BUBBLE_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698