blob: 421088972501b7c13e5ddf707f1c098ef7a866df (
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
|
// 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_BROWSER_ACTIONS_TOOLBAR_GTK_H_
#define CHROME_BROWSER_GTK_BROWSER_ACTIONS_TOOLBAR_GTK_H_
#include <map>
#include <string>
#include "base/linked_ptr.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/owned_widget_gtk.h"
class Browser;
class BrowserActionButton;
class Extension;
class Profile;
typedef struct _GtkWidget GtkWidget;
class BrowserActionsToolbarGtk : public NotificationObserver {
public:
explicit BrowserActionsToolbarGtk(Browser* browser);
~BrowserActionsToolbarGtk();
GtkWidget* widget() { return hbox_.get(); }
int button_count() { return extension_button_map_.size(); }
// NotificationObserver implementation.
void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
private:
// Query the extensions service for all extensions with browser actions,
// and create the UI for them.
void CreateAllButtons();
// Create the UI for a single browser action. This will stick the button
// at the end of the toolbar.
// TODO(estade): is this OK, or does it need to place it in a specific
// location on the toolbar?
void CreateButtonForExtension(Extension* extension);
// Delete resources associated with UI for a browser action.
void RemoveButtonForExtension(Extension* extension);
// Change the visibility of widget() based on whether we have any buttons
// to show.
void UpdateVisibility();
Browser* browser_;
Profile* profile_;
OwnedWidgetGtk hbox_;
NotificationRegistrar registrar_;
// Map from extension ID to BrowserActionButton, which is a wrapper for
// a chrome button and related functionality. There should be one entry
// for every extension that has a browser action.
std::map<std::string, linked_ptr<BrowserActionButton> > extension_button_map_;
DISALLOW_COPY_AND_ASSIGN(BrowserActionsToolbarGtk);
};
#endif // CHROME_BROWSER_GTK_BROWSER_ACTIONS_TOOLBAR_GTK_H_
|