Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_GTK_LOCATION_BAR_VIEW_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_LOCATION_BAR_VIEW_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_LOCATION_BAR_VIEW_GTK_H_ | 6 #define CHROME_BROWSER_GTK_LOCATION_BAR_VIEW_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <map> |
|
Evan Stade
2009/10/26 23:07:22
nit: map before string
| |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
| 15 #include "base/scoped_vector.h" | 15 #include "base/scoped_vector.h" |
| 16 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 16 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" | 17 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" |
| 18 #include "chrome/browser/extensions/image_loading_tracker.h" | 18 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 19 #include "chrome/browser/location_bar.h" | 19 #include "chrome/browser/location_bar.h" |
| 20 #include "chrome/common/notification_observer.h" | 20 #include "chrome/common/notification_observer.h" |
| 21 #include "chrome/common/notification_registrar.h" | 21 #include "chrome/common/notification_registrar.h" |
| 22 #include "chrome/common/owned_widget_gtk.h" | 22 #include "chrome/common/owned_widget_gtk.h" |
| 23 #include "chrome/common/page_transition_types.h" | 23 #include "chrome/common/page_transition_types.h" |
| 24 #include "third_party/skia/include/core/SkBitmap.h" | |
| 24 #include "webkit/glue/window_open_disposition.h" | 25 #include "webkit/glue/window_open_disposition.h" |
| 25 | 26 |
| 26 class AutocompleteEditViewGtk; | 27 class AutocompleteEditViewGtk; |
| 27 class BubblePositioner; | 28 class BubblePositioner; |
| 28 class Browser; | 29 class Browser; |
| 29 class CommandUpdater; | 30 class CommandUpdater; |
| 30 class GtkThemeProvider; | 31 class GtkThemeProvider; |
| 31 class ExtensionAction; | 32 class ExtensionAction2; |
|
Evan Stade
2009/10/26 23:07:22
nit: alphabets
| |
| 32 class Profile; | 33 class Profile; |
| 33 class SkBitmap; | 34 class SkBitmap; |
| 34 class TabContents; | 35 class TabContents; |
| 35 class ToolbarModel; | 36 class ToolbarModel; |
| 36 | 37 |
| 37 class LocationBarViewGtk : public AutocompleteEditController, | 38 class LocationBarViewGtk : public AutocompleteEditController, |
| 38 public LocationBar, | 39 public LocationBar, |
| 39 public LocationBarTesting, | 40 public LocationBarTesting, |
| 40 public NotificationObserver { | 41 public NotificationObserver { |
| 41 public: | 42 public: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 | 99 |
| 99 // Translation between a security level and the background color. Both the | 100 // Translation between a security level and the background color. Both the |
| 100 // location bar and edit have to manage and match the background color. | 101 // location bar and edit have to manage and match the background color. |
| 101 static const GdkColor kBackgroundColorByLevel[3]; | 102 static const GdkColor kBackgroundColorByLevel[3]; |
| 102 | 103 |
| 103 private: | 104 private: |
| 104 class PageActionViewGtk : public ImageLoadingTracker::Observer { | 105 class PageActionViewGtk : public ImageLoadingTracker::Observer { |
| 105 public: | 106 public: |
| 106 PageActionViewGtk( | 107 PageActionViewGtk( |
| 107 LocationBarViewGtk* owner, Profile* profile, | 108 LocationBarViewGtk* owner, Profile* profile, |
| 108 const ExtensionAction* page_action); | 109 ExtensionAction2* page_action); |
| 109 virtual ~PageActionViewGtk(); | 110 virtual ~PageActionViewGtk(); |
| 110 | 111 |
| 111 GtkWidget* widget() { return event_box_.get(); } | 112 GtkWidget* widget() { return event_box_.get(); } |
| 112 | 113 |
| 113 // Called to notify the PageAction that it should determine whether to be | 114 // Called to notify the PageAction that it should determine whether to be |
| 114 // visible or hidden. |contents| is the TabContents that is active, |url| | 115 // visible or hidden. |contents| is the TabContents that is active, |url| |
| 115 // is the current page URL. | 116 // is the current page URL. |
| 116 void UpdateVisibility(TabContents* contents, GURL url); | 117 void UpdateVisibility(TabContents* contents, GURL url); |
| 117 | 118 |
| 118 // A callback from ImageLoadingTracker for when the image has loaded. | 119 // A callback from ImageLoadingTracker for when the image has loaded. |
| 119 virtual void OnImageLoaded(SkBitmap* image, size_t index); | 120 virtual void OnImageLoaded(SkBitmap* image, size_t index); |
| 120 | 121 |
| 121 private: | 122 private: |
| 122 static gboolean OnButtonPressed(GtkWidget* sender, GdkEventButton* event, | 123 static gboolean OnButtonPressed(GtkWidget* sender, GdkEventButton* event, |
| 123 PageActionViewGtk* page_action_view); | 124 PageActionViewGtk* page_action_view); |
| 124 static gboolean OnExposeEvent(GtkWidget* widget, | 125 static gboolean OnExposeEvent(GtkWidget* widget, |
| 125 GdkEventExpose* event, | 126 GdkEventExpose* event, |
| 126 PageActionViewGtk* page_action_view); | 127 PageActionViewGtk* page_action_view); |
| 127 | 128 |
| 128 // The location bar view that owns us. | 129 // The location bar view that owns us. |
| 129 LocationBarViewGtk* owner_; | 130 LocationBarViewGtk* owner_; |
| 130 | 131 |
| 131 // The current profile (not owned by us). | 132 // The current profile (not owned by us). |
| 132 Profile* profile_; | 133 Profile* profile_; |
| 133 | 134 |
| 134 // The PageAction that this view represents. The PageAction is not owned by | 135 // The PageAction that this view represents. The PageAction is not owned by |
| 135 // us, it resides in the extension of this particular profile. | 136 // us, it resides in the extension of this particular profile. |
| 136 const ExtensionAction* page_action_; | 137 ExtensionAction2* page_action_; |
| 137 | 138 |
| 138 // The icons representing different states for the page action. | 139 // A cache of all the different icon paths associated with this page action. |
| 139 std::vector<GdkPixbuf*> pixbufs_; | 140 typedef std::map<std::string, GdkPixbuf*> PixbufMap; |
| 141 PixbufMap pixbufs_; | |
| 140 | 142 |
| 141 // A cache of the last dynamically generated bitmap and the pixbuf that | 143 // A cache of the last dynamically generated bitmap and the pixbuf that |
| 142 // corresponds to it. We keep track of both so we can free old pixbufs as | 144 // corresponds to it. We keep track of both so we can free old pixbufs as |
| 143 // their icons are replaced. | 145 // their icons are replaced. |
| 144 SkBitmap* last_icon_skbitmap_; | 146 SkBitmap last_icon_skbitmap_; |
| 145 GdkPixbuf* last_icon_pixbuf_; | 147 GdkPixbuf* last_icon_pixbuf_; |
| 146 | 148 |
| 147 // The object that is waiting for the image loading to complete | 149 // The object that is waiting for the image loading to complete |
| 148 // asynchronously. It will delete itself once it is done. | 150 // asynchronously. It will delete itself once it is done. |
| 149 ImageLoadingTracker* tracker_; | 151 ImageLoadingTracker* tracker_; |
| 150 | 152 |
| 151 // The widgets for this page action. | 153 // The widgets for this page action. |
| 152 OwnedWidgetGtk event_box_; | 154 OwnedWidgetGtk event_box_; |
| 153 OwnedWidgetGtk image_; | 155 OwnedWidgetGtk image_; |
| 154 | 156 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 | 246 |
| 245 // Provides colors and rendering mode. | 247 // Provides colors and rendering mode. |
| 246 GtkThemeProvider* theme_provider_; | 248 GtkThemeProvider* theme_provider_; |
| 247 | 249 |
| 248 NotificationRegistrar registrar_; | 250 NotificationRegistrar registrar_; |
| 249 | 251 |
| 250 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); | 252 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); |
| 251 }; | 253 }; |
| 252 | 254 |
| 253 #endif // CHROME_BROWSER_GTK_LOCATION_BAR_VIEW_GTK_H_ | 255 #endif // CHROME_BROWSER_GTK_LOCATION_BAR_VIEW_GTK_H_ |
| OLD | NEW |