summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/extensions/extension_message_bubble_view.h
blob: e98418976c636f041a71f5bff26c870ae37c9856 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/link_listener.h"

class Profile;

namespace views {
class Label;
class LabelButton;
class View;
}

namespace extensions {

class ExtensionMessageBubbleController;

// This is a class that implements the UI for the bubble showing which
// extensions look suspicious and have therefore been automatically disabled.
class ExtensionMessageBubbleView : public views::BubbleDelegateView,
                                   public views::ButtonListener,
                                   public views::LinkListener {
 public:
  ExtensionMessageBubbleView(
      views::View* anchor_view,
      views::BubbleBorder::Arrow arrow_location,
      scoped_ptr<ExtensionMessageBubbleController> controller);

  // Shows the bubble after a five-second delay.
  void Show();

  // WidgetObserver methods.
  void OnWidgetDestroying(views::Widget* widget) override;

  static void set_bubble_appearance_wait_time_for_testing(int time_in_seconds);

 private:
  ~ExtensionMessageBubbleView() override;

  void ShowBubble();

  // views::BubbleDelegateView overrides:
  void Init() override;

  // views::ButtonListener implementation.
  void ButtonPressed(views::Button* sender, const ui::Event& event) override;

  // views::LinkListener implementation.
  void LinkClicked(views::Link* source, int event_flags) override;

  // views::View implementation.
  void GetAccessibleState(ui::AXViewState* state) override;
  void ViewHierarchyChanged(
      const ViewHierarchyChangedDetails& details) override;

  // The controller for this bubble.
  scoped_ptr<ExtensionMessageBubbleController> controller_;

  // The view this bubble is anchored against.
  views::View* anchor_view_;

  // The headline, labels and buttons on the bubble.
  views::Label* headline_;
  views::Link* learn_more_;
  views::LabelButton* action_button_;
  views::LabelButton* dismiss_button_;

  // All actions (link, button, esc) close the bubble, but we need to
  // make sure we don't send dismiss if the link was clicked.
  bool link_clicked_;
  bool action_taken_;

  base::WeakPtrFactory<ExtensionMessageBubbleView> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleView);
};

}  // namespace extensions

#endif  // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_MESSAGE_BUBBLE_VIEW_H_