diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 20:06:23 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 20:06:23 +0000 |
commit | 67274c96843e6ecc7e299f6165c1ea2bb02f3361 (patch) | |
tree | c467e2bc8a9ca8ffbe6b7d1c26e2b3a11db729a7 /chrome/browser/gtk/browser_actions_toolbar_gtk.h | |
parent | b5d079536bcbf33c657fd96079bb7b2bd9644c0e (diff) | |
download | chromium_src-67274c96843e6ecc7e299f6165c1ea2bb02f3361.zip chromium_src-67274c96843e6ecc7e299f6165c1ea2bb02f3361.tar.gz chromium_src-67274c96843e6ecc7e299f6165c1ea2bb02f3361.tar.bz2 |
GTK: Browser actions toolbar.
We don't have html popups yet but clicking should work (e.g. print button works).
TODO: port browser_action in proc browser test.
TODO: badges
BUG=23882
TEST=loaded gmail browser action extension, loaded print bookmark bar extension, loaded them both, unloaded, disabled, enabled, etc.
Review URL: http://codereview.chromium.org/273025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/browser_actions_toolbar_gtk.h')
-rw-r--r-- | chrome/browser/gtk/browser_actions_toolbar_gtk.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.h b/chrome/browser/gtk/browser_actions_toolbar_gtk.h new file mode 100644 index 0000000..4210889 --- /dev/null +++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.h @@ -0,0 +1,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_ |