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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_message_bubble_view.h

Issue 1087713002: [Reland] [Extensions] Make extension message bubble factory platform-abstract (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finnur's Created 5 years, 8 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_
7 7
8 #include "base/compiler_specific.h"
9 #include "base/macros.h" 8 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/extensions/extension_message_bubble.h" 10 #include "chrome/browser/extensions/extension_message_bubble.h"
12 #include "chrome/browser/ui/views/toolbar/browser_actions_container_observer.h"
13 #include "ui/views/bubble/bubble_delegate.h" 11 #include "ui/views/bubble/bubble_delegate.h"
14 #include "ui/views/controls/button/button.h" 12 #include "ui/views/controls/button/button.h"
15 #include "ui/views/controls/link_listener.h" 13 #include "ui/views/controls/link_listener.h"
16 14
17 class Profile; 15 class Profile;
18 class BrowserActionsContainer;
19 class ToolbarView;
20 16
21 namespace views { 17 namespace views {
22 class Label; 18 class Label;
23 class LabelButton; 19 class LabelButton;
24 class View; 20 class View;
25 } 21 }
26 22
27 namespace extensions { 23 namespace extensions {
28 24
29 class DevModeBubbleController;
30 class ExtensionMessageBubbleController; 25 class ExtensionMessageBubbleController;
31 26
32 // Create and show ExtensionMessageBubbles for either extensions that look
33 // suspicious and have therefore been disabled, or for extensions that are
34 // running in developer mode that we want to warn the user about.
35 // Calling MaybeShow() will show one of the bubbles, if there is cause to (we
36 // don't show both in order to avoid spamminess). The suspicious extensions
37 // bubble takes priority over the developer mode extensions bubble.
38 class ExtensionMessageBubbleFactory : public BrowserActionsContainerObserver {
39 public:
40 ExtensionMessageBubbleFactory(Profile* profile, ToolbarView* toolbar_view);
41 ~ExtensionMessageBubbleFactory() override;
42
43 void MaybeShow(views::View* anchor_view);
44
45 private:
46 // The stage of showing the developer mode extensions bubble. STAGE_START
47 // corresponds to the beginning of the process, when nothing has been done.
48 // STAGE_HIGHLIGHTED indicates that the toolbar should be highlighting
49 // dangerous extensions. STAGE_COMPLETE means that the process should be
50 // ended.
51 enum Stage { STAGE_START, STAGE_HIGHLIGHTED, STAGE_COMPLETE };
52
53 // Shows the suspicious extensions bubble, if there are suspicious extensions
54 // and we have not done so already.
55 // Returns true if we have show the view.
56 bool MaybeShowSuspiciousExtensionsBubble(views::View* anchor_view);
57
58 // Shows the settings API extensions bubble, if there are extensions
59 // overriding the startup pages and we have not done so already.
60 // Returns true if we show the view (or start the process).
61 bool MaybeShowStartupOverrideExtensionsBubble(views::View* anchor_view);
62
63 // Shows the bubble for when there are extensions overriding the proxy (if we
64 // have not done so already). Returns true if we show the view (or start the
65 // process of doing so).
66 bool MaybeShowProxyOverrideExtensionsBubble(views::View* anchor_view);
67
68 // Shows the developer mode extensions bubble, if there are extensions running
69 // in developer mode and we have not done so already.
70 // Returns true if we show the view (or start the process).
71 bool MaybeShowDevModeExtensionsBubble(views::View* anchor_view);
72
73 // Starts or stops observing the BrowserActionsContainer, if necessary.
74 void MaybeObserve();
75 void MaybeStopObserving();
76
77 // Adds |profile| to the list of profiles that have been evaluated for showing
78 // a bubble. Handy for things that only want to check once per profile.
79 void RecordProfileCheck(Profile* profile);
80 // Returns false if this profile has been evaluated before.
81 bool IsInitialProfileCheck(Profile* profile);
82
83 // BrowserActionsContainer::Observer implementation.
84 void OnBrowserActionsContainerAnimationEnded() override;
85 void OnBrowserActionsContainerDestroyed() override;
86
87 // Sets the stage for highlighting extensions and then showing the bubble
88 // controlled by |controller|, anchored to |anchor_view|.
89 void PrepareToHighlightExtensions(
90 scoped_ptr<ExtensionMessageBubbleController> controller,
91 views::View* anchor_view);
92
93 // Inform the ExtensionToolbarModel to highlight the appropriate extensions.
94 void HighlightExtensions();
95
96 // Shows the waiting bubbble, after highlighting the extensions.
97 void ShowHighlightingBubble();
98
99 // Finishes the process of showing the developer mode bubble.
100 void Finish();
101
102 // The associated profile.
103 Profile* profile_;
104
105 // The toolbar view that the ExtensionMessageBubbleViews will attach to.
106 ToolbarView* toolbar_view_;
107
108 // Whether or not we have shown the suspicious extensions bubble.
109 bool shown_suspicious_extensions_bubble_;
110
111 // Whether or not we have shown the Settings API extensions bubble notifying
112 // the user about the startup pages being overridden.
113 bool shown_startup_override_extensions_bubble_;
114
115 // Whether or not we have shown the bubble notifying the user about the proxy
116 // being overridden.
117 bool shown_proxy_override_extensions_bubble_;
118
119 // Whether or not we have shown the developer mode extensions bubble.
120 bool shown_dev_mode_extensions_bubble_;
121
122 // Whether or not we are already observing the BrowserActionsContainer (so
123 // we don't add ourselves twice).
124 bool is_observing_;
125
126 // The current stage of showing the bubble.
127 Stage stage_;
128
129 // The BrowserActionsContainer for the profile. This will be NULL if the
130 // factory is not currently in the process of showing a bubble.
131 BrowserActionsContainer* container_;
132
133 // The default view to anchor the bubble to. This will be NULL if the factory
134 // is not currently in the process of showing a bubble.
135 views::View* anchor_view_;
136
137 // The controller to show a bubble for. This will be NULL if the factory is
138 // not currently in the process of showing a bubble.
139 scoped_ptr<ExtensionMessageBubbleController> controller_;
140
141 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleFactory);
142 };
143
144 // This is a class that implements the UI for the bubble showing which 27 // This is a class that implements the UI for the bubble showing which
145 // extensions look suspicious and have therefore been automatically disabled. 28 // extensions look suspicious and have therefore been automatically disabled.
146 class ExtensionMessageBubbleView : public ExtensionMessageBubble, 29 class ExtensionMessageBubbleView : public ExtensionMessageBubble,
147 public views::BubbleDelegateView, 30 public views::BubbleDelegateView,
148 public views::ButtonListener, 31 public views::ButtonListener,
149 public views::LinkListener { 32 public views::LinkListener {
150 public: 33 public:
151 ExtensionMessageBubbleView( 34 ExtensionMessageBubbleView(
152 views::View* anchor_view, 35 views::View* anchor_view,
153 views::BubbleBorder::Arrow arrow_location, 36 views::BubbleBorder::Arrow arrow_location,
154 scoped_ptr<ExtensionMessageBubbleController> controller); 37 scoped_ptr<ExtensionMessageBubbleController> controller);
155 38
156 // ExtensionMessageBubble methods. 39 // ExtensionMessageBubble methods.
157 void OnActionButtonClicked(const base::Closure& callback) override;
158 void OnDismissButtonClicked(const base::Closure& callback) override;
159 void OnLinkClicked(const base::Closure& callback) override;
160 void Show() override; 40 void Show() override;
161 41
162 // WidgetObserver methods. 42 // WidgetObserver methods.
163 void OnWidgetDestroying(views::Widget* widget) override; 43 void OnWidgetDestroying(views::Widget* widget) override;
164 44
165 private: 45 private:
166 ~ExtensionMessageBubbleView() override; 46 ~ExtensionMessageBubbleView() override;
167 47
168 void ShowBubble(); 48 void ShowBubble();
169 49
(...skipping 21 matching lines...) Expand all
191 views::Label* headline_; 71 views::Label* headline_;
192 views::Link* learn_more_; 72 views::Link* learn_more_;
193 views::LabelButton* action_button_; 73 views::LabelButton* action_button_;
194 views::LabelButton* dismiss_button_; 74 views::LabelButton* dismiss_button_;
195 75
196 // All actions (link, button, esc) close the bubble, but we need to 76 // All actions (link, button, esc) close the bubble, but we need to
197 // make sure we don't send dismiss if the link was clicked. 77 // make sure we don't send dismiss if the link was clicked.
198 bool link_clicked_; 78 bool link_clicked_;
199 bool action_taken_; 79 bool action_taken_;
200 80
201 // Callbacks into the controller.
202 base::Closure action_callback_;
203 base::Closure dismiss_callback_;
204 base::Closure link_callback_;
205
206 base::WeakPtrFactory<ExtensionMessageBubbleView> weak_factory_; 81 base::WeakPtrFactory<ExtensionMessageBubbleView> weak_factory_;
207 82
208 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleView); 83 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleView);
209 }; 84 };
210 85
211 } // namespace extensions 86 } // namespace extensions
212 87
213 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_ 88 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698