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