summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/extension_popup_gtk.h
blob: 58578c8950f8a907276c76fc0423723b82e5dd49 (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
// Copyright (c) 2009 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_GTK_EXTENSION_POPUP_GTK_H_
#define CHROME_BROWSER_GTK_EXTENSION_POPUP_GTK_H_

#include "base/gfx/rect.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/gtk/info_bubble_gtk.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"

class Browser;
class ExtensionHost;
class GURL;

class ExtensionPopupGtk : public NotificationObserver,
                          public InfoBubbleGtkDelegate {
 public:
  ExtensionPopupGtk(Browser* browser,
                    ExtensionHost* host,
                    const gfx::Rect& relative_to);
  virtual ~ExtensionPopupGtk();

  static void Show(const GURL& url,
                   Browser* browser,
                   const gfx::Rect& relative_to);

  // NotificationObserver implementation.
  virtual void Observe(NotificationType type,
                       const NotificationSource& source,
                       const NotificationDetails& details);

  // InfoBubbleGtkDelegate implementation.
  virtual void InfoBubbleClosing(InfoBubbleGtk* bubble,
                                 bool closed_by_escape);

 private:
  // Shows the popup widget. Called after loading completes.
  void ShowPopup();

  // Destroys the popup widget. This will in turn destroy us since we delete
  // ourselves when the info bubble closes.
  void DestroyPopup();

  Browser* browser_;

  InfoBubbleGtk* bubble_;

  // We take ownership of the popup ExtensionHost.
  scoped_ptr<ExtensionHost> host_;

  // The rect that we use to position the popup. It is the bounds of the
  // browser action button.
  gfx::Rect relative_to_;

  NotificationRegistrar registrar_;

  DISALLOW_COPY_AND_ASSIGN(ExtensionPopupGtk);
};

#endif  // CHROME_BROWSER_GTK_EXTENSION_POPUP_GTK_H_