summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/gtk/zoom_bubble_gtk.h
blob: f54a8c0fa7297dff2e9c49d87157060ef19e183e (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
// 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_ZOOM_BUBBLE_GTK_H_
#define CHROME_BROWSER_UI_GTK_ZOOM_BUBBLE_GTK_H_

#include "base/basictypes.h"
#include "base/memory/weak_ptr.h"
#include "base/timer.h"
#include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/base/gtk/gtk_signal.h"

class Profile;

typedef struct _GtkWidget GtkWidget;

class ZoomBubbleGtk : public BubbleDelegateGtk,
                      public content::NotificationObserver {
 public:
  // Shows the zoom bubble, pointing at |anchor_widget|.
  static void Show(GtkWidget* anchor, Profile* profile,
    int zoomPercent, bool auto_close);

  // Closes the zoom bubble.
  static void Close();

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

  // content::NotificationObserver:
  virtual void Observe(int type,
                       const content::NotificationSource& source,
                       const content::NotificationDetails& details) OVERRIDE;

 private:
  ZoomBubbleGtk(GtkWidget* anchor,
                Profile* profile,
                int zoom_percent,
                bool auto_close);
  virtual ~ZoomBubbleGtk();

  // Closes the zoom bubble.
  void CloseBubble();

  // Notified when |content_| is destroyed so this instance can be deleted.
  CHROMEGTK_CALLBACK_0(ZoomBubbleGtk, void, OnDestroy);

  // Whether the currently displayed bubble will automatically close.
  bool auto_close_;

  // Timer used to close the bubble when |auto_close_| is true.
  base::OneShotTimer<ZoomBubbleGtk> timer_;

  // Provides colors.
  GtkThemeService* theme_service_;

  // Label showing zoom percentage.
  GtkWidget* label_;

  // The BubbleGtk object containing the zoom bubble's content.
  BubbleGtk* bubble_;

  content::NotificationRegistrar registrar_;

  DISALLOW_COPY_AND_ASSIGN(ZoomBubbleGtk);
};

#endif  // CHROME_BROWSER_UI_GTK_ZOOM_BUBBLE_GTK_H_