summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/script_bubble_view.h
blob: 3df39c61e09bd34fd7dfb7bcf57533408ad5bc13 (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
// Copyright (c) 2012 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_SCRIPT_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_SCRIPT_BUBBLE_VIEW_H_

#include <map>
#include <string>

#include "base/compiler_specific.h"
#include "ui/gfx/image/image.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/link_listener.h"

namespace content {
class WebContents;
}

namespace extensions {
class ScriptBubbleController;
}

namespace views {
class ImageView;
}

// The view in the bubble that pops up from the ScriptBubbleIconView that lists
// the extensions with the activeTab permission running content scripts on the
// current page.
class ScriptBubbleView : public views::BubbleDelegateView,
                         public views::LinkListener,
                         public base::SupportsWeakPtr<ScriptBubbleView> {
 public:
  ScriptBubbleView(views::View* anchor_view,
                   content::WebContents* web_contents);
  virtual ~ScriptBubbleView();

  // views::View methods:
  virtual gfx::Size GetPreferredSize() OVERRIDE;

  // LinkListener methods:
  virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;

 private:
  struct ScriptEntry {
    ScriptEntry();

    std::string extension_id;
    string16 extension_name;
    views::ImageView* extension_imageview;
  };

  // views::BubbleDelegateView methods:
  virtual void Init() OVERRIDE;

  // Call when an image has finished loading.
  void OnImageLoaded(size_t index, const gfx::Image& image);

  // A helper function to get the script controller for this tab.
  extensions::ScriptBubbleController* GetScriptBubbleController();

  // The height of the bubble in pixels.
  int height_;

  // The Web Contents we're dealing with.
  content::WebContents* web_contents_;

  // A vector containing information about the scripts running on the page.
  std::vector<ScriptEntry> entries_;

  DISALLOW_COPY_AND_ASSIGN(ScriptBubbleView);
};

#endif  // CHROME_BROWSER_UI_VIEWS_SCRIPT_BUBBLE_VIEW_H_