summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/gtk/script_bubble_gtk.h
blob: d8a73860880623466243b85f362b348d6e1c1ffc (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
// 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_GTK_SCRIPT_BUBBLE_GTK_H_
#define CHROME_BROWSER_UI_GTK_SCRIPT_BUBBLE_GTK_H_

#include <map>

#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
#include "chrome/common/content_settings_types.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/gfx/image/image.h"

class ContentSettingBubbleModel;
class Profile;

namespace content {
class WebContents;
}

// A bubble that is displayed to show users when extensions are interacting
// with the current page.
class ScriptBubbleGtk : public BubbleDelegateGtk {
 public:
  static void Show(GtkWidget* anchor, content::WebContents* web_contents);

 private:
  void Close();

  virtual ~ScriptBubbleGtk();

  ScriptBubbleGtk(GtkWidget* anchor, content::WebContents* web_contents);

  // BubbleDelegateGtk:
  virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE;

  // Builds the bubble and all the widgets that it displays.
  void BuildBubble();

  void OnIconLoaded(const std::string& extension_id, const gfx::Image& icon);

  // Widget callback methods.
  static void OnItemLinkClickedThunk(GtkWidget* sender, void* user_data);
  void OnItemLinkClicked(GtkWidget* sender);

  // We position the bubble near this widget.
  GtkWidget* anchor_;

  // The WebContents we're being displayed for.
  content::WebContents* web_contents_;

  // The active profile.
  Profile* profile_;

  // The bubble.
  BubbleGtk* bubble_;

  std::map<std::string, GtkImage*> icon_controls_;
  std::map<GtkWidget*, std::string> link_controls_;

  base::WeakPtrFactory<ScriptBubbleGtk> weak_ptr_factory_;
};

#endif  // CHROME_BROWSER_UI_GTK_SCRIPT_BUBBLE_GTK_H_