- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / script_bubble_view.h
1 // Copyright (c) 2012 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_SCRIPT_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_SCRIPT_BUBBLE_VIEW_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/compiler_specific.h"
12 #include "ui/gfx/image/image.h"
13 #include "ui/views/bubble/bubble_delegate.h"
14 #include "ui/views/controls/link_listener.h"
15
16 namespace content {
17 class WebContents;
18 }
19
20 namespace extensions {
21 class ScriptBubbleController;
22 }
23
24 namespace views {
25 class ImageView;
26 }
27
28 // The view in the bubble that pops up from the ScriptBubbleIconView that lists
29 // the extensions with the activeTab permission running content scripts on the
30 // current page.
31 class ScriptBubbleView : public views::BubbleDelegateView,
32                          public views::LinkListener,
33                          public base::SupportsWeakPtr<ScriptBubbleView> {
34  public:
35   ScriptBubbleView(views::View* anchor_view,
36                    content::WebContents* web_contents);
37   virtual ~ScriptBubbleView();
38
39   // views::View methods:
40   virtual gfx::Size GetPreferredSize() OVERRIDE;
41
42   // LinkListener methods:
43   virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
44
45  private:
46   struct ScriptEntry {
47     ScriptEntry();
48
49     std::string extension_id;
50     string16 extension_name;
51     views::ImageView* extension_imageview;
52   };
53
54   // views::BubbleDelegateView methods:
55   virtual void Init() OVERRIDE;
56
57   // Call when an image has finished loading.
58   void OnImageLoaded(size_t index, const gfx::Image& image);
59
60   // A helper function to get the script controller for this tab.
61   extensions::ScriptBubbleController* GetScriptBubbleController();
62
63   // The height of the bubble in pixels.
64   int height_;
65
66   // The Web Contents we're dealing with.
67   content::WebContents* web_contents_;
68
69   // A vector containing information about the scripts running on the page.
70   std::vector<ScriptEntry> entries_;
71
72   DISALLOW_COPY_AND_ASSIGN(ScriptBubbleView);
73 };
74
75 #endif  // CHROME_BROWSER_UI_VIEWS_SCRIPT_BUBBLE_VIEW_H_