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