OLD | NEW |
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_SUSPICIOUS_EXTENSION_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_ |
7 | 7 |
8 #include "chrome/browser/extensions/suspicious_extension_bubble.h" | 8 #include "chrome/browser/extensions/extension_message_bubble.h" |
| 9 #include "chrome/browser/extensions/extension_message_bubble_controller.h" |
9 #include "ui/views/bubble/bubble_delegate.h" | 10 #include "ui/views/bubble/bubble_delegate.h" |
10 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
11 #include "ui/views/controls/link_listener.h" | 12 #include "ui/views/controls/link_listener.h" |
12 | 13 |
13 class Browser; | 14 class Browser; |
14 | 15 |
15 namespace views { | 16 namespace views { |
16 class Label; | 17 class Label; |
17 class LabelButton; | 18 class LabelButton; |
18 class Link; | 19 class Link; |
19 class Widget; | 20 class Widget; |
20 } | 21 } |
21 | 22 |
22 namespace extensions { | 23 namespace extensions { |
23 | 24 |
24 class SuspiciousExtensionBubbleController; | |
25 | |
26 // This is a class that implements the UI for the bubble showing which | 25 // This is a class that implements the UI for the bubble showing which |
27 // extensions look suspicious and have therefore been automatically disabled. | 26 // extensions look suspicious and have therefore been automatically disabled. |
28 class SuspiciousExtensionBubbleView : public SuspiciousExtensionBubble, | 27 class ExtensionMessageBubbleView : public ExtensionMessageBubble, |
29 public views::BubbleDelegateView, | 28 public views::BubbleDelegateView, |
30 public views::ButtonListener, | 29 public views::ButtonListener, |
31 public views::LinkListener { | 30 public views::LinkListener { |
32 public: | 31 public: |
33 // Show the Disabled Extension bubble, if needed. | 32 // Show the Disabled Extension bubble, if needed. |
34 static void MaybeShow(Browser* browser, views::View* anchor_view); | 33 static void MaybeShow(Browser* browser, views::View* anchor_view); |
35 | 34 |
36 // SuspiciousExtensionBubble methods. | 35 // ExtensionMessageBubble methods. |
37 virtual void OnButtonClicked(const base::Closure& callback) OVERRIDE; | 36 virtual void OnActionButtonClicked(const base::Closure& callback) OVERRIDE; |
| 37 virtual void OnDismissButtonClicked(const base::Closure& callback) OVERRIDE; |
38 virtual void OnLinkClicked(const base::Closure& callback) OVERRIDE; | 38 virtual void OnLinkClicked(const base::Closure& callback) OVERRIDE; |
39 virtual void Show() OVERRIDE; | 39 virtual void Show() OVERRIDE; |
40 | 40 |
41 // WidgetObserver methods. | 41 // WidgetObserver methods. |
42 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; | 42 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; |
43 | 43 |
44 private: | 44 private: |
45 SuspiciousExtensionBubbleView( | 45 ExtensionMessageBubbleView( |
46 views::View* anchor_view, | 46 views::View* anchor_view, |
47 SuspiciousExtensionBubbleController* controller); | 47 ExtensionMessageBubbleController::Delegate* delegate); |
48 virtual ~SuspiciousExtensionBubbleView(); | 48 virtual ~ExtensionMessageBubbleView(); |
49 | 49 |
50 // Shows the bubble and updates the counter for how often it has been shown. | 50 // Shows the bubble and updates the counter for how often it has been shown. |
51 void ShowBubble(); | 51 void ShowBubble(); |
52 | 52 |
53 // views::BubbleDelegateView overrides: | 53 // views::BubbleDelegateView overrides: |
54 virtual void Init() OVERRIDE; | 54 virtual void Init() OVERRIDE; |
55 | 55 |
56 // views::ButtonListener implementation. | 56 // views::ButtonListener implementation. |
57 virtual void ButtonPressed(views::Button* sender, | 57 virtual void ButtonPressed(views::Button* sender, |
58 const ui::Event& event) OVERRIDE; | 58 const ui::Event& event) OVERRIDE; |
59 | 59 |
60 // views::LinkListener implementation. | 60 // views::LinkListener implementation. |
61 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 61 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
62 | 62 |
63 // views::View implementation. | 63 // views::View implementation. |
64 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 64 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
65 virtual void ViewHierarchyChanged( | 65 virtual void ViewHierarchyChanged( |
66 const ViewHierarchyChangedDetails& details) OVERRIDE; | 66 const ViewHierarchyChangedDetails& details) OVERRIDE; |
67 | 67 |
68 base::WeakPtrFactory<SuspiciousExtensionBubbleView> weak_factory_; | 68 base::WeakPtrFactory<ExtensionMessageBubbleView> weak_factory_; |
69 | 69 |
70 // The controller for the bubble. Weak, not owned by us. | 70 // The controller for the bubble. Weak, not owned by us. |
71 SuspiciousExtensionBubbleController* controller_; | 71 ExtensionMessageBubbleController::Delegate* delegate_; |
72 | 72 |
73 // The headline, labels and buttons on the bubble. | 73 // The headline, labels and buttons on the bubble. |
74 views::Label* headline_; | 74 views::Label* headline_; |
75 views::Link* learn_more_; | 75 views::Link* learn_more_; |
| 76 views::LabelButton* action_button_; |
76 views::LabelButton* dismiss_button_; | 77 views::LabelButton* dismiss_button_; |
77 | 78 |
78 // All actions (link, button, esc) close the bubble, but we need to | 79 // All actions (link, button, esc) close the bubble, but we need to |
79 // make sure we don't send dismiss if the link was clicked. | 80 // make sure we don't send dismiss if the link was clicked. |
80 bool link_clicked_; | 81 bool link_clicked_; |
| 82 bool action_taken_; |
81 | 83 |
82 // Callbacks into the controller. | 84 // Callbacks into the controller. |
83 base::Closure button_callback_; | 85 base::Closure action_callback_; |
| 86 base::Closure dismiss_callback_; |
84 base::Closure link_callback_; | 87 base::Closure link_callback_; |
85 | 88 |
86 DISALLOW_COPY_AND_ASSIGN(SuspiciousExtensionBubbleView); | 89 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleView); |
87 }; | 90 }; |
88 | 91 |
89 } // namespace extensions | 92 } // namespace extensions |
90 | 93 |
91 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_SUSPICIOUS_EXTENSION_BUBBLE_VIEW_H
_ | 94 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_ |
OLD | NEW |