| 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 | 12 |
| 12 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 13 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
| 15 #include "base/scoped_vector.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 16 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" | 17 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" |
| 18 #include "chrome/browser/image_loading_tracker.h" |
| 16 #include "chrome/browser/location_bar.h" | 19 #include "chrome/browser/location_bar.h" |
| 17 #include "chrome/common/notification_observer.h" | 20 #include "chrome/common/notification_observer.h" |
| 18 #include "chrome/common/notification_registrar.h" | 21 #include "chrome/common/notification_registrar.h" |
| 19 #include "chrome/common/owned_widget_gtk.h" | 22 #include "chrome/common/owned_widget_gtk.h" |
| 20 #include "chrome/common/page_transition_types.h" | 23 #include "chrome/common/page_transition_types.h" |
| 21 #include "webkit/glue/window_open_disposition.h" | 24 #include "webkit/glue/window_open_disposition.h" |
| 22 | 25 |
| 23 class AutocompleteEditViewGtk; | 26 class AutocompleteEditViewGtk; |
| 24 class AutocompletePopupPositioner; | 27 class AutocompletePopupPositioner; |
| 28 class Browser; |
| 25 class CommandUpdater; | 29 class CommandUpdater; |
| 26 class GtkThemeProvider; | 30 class GtkThemeProvider; |
| 31 class PageAction; |
| 27 class Profile; | 32 class Profile; |
| 28 class SkBitmap; | 33 class SkBitmap; |
| 29 class TabContents; | 34 class TabContents; |
| 30 class ToolbarModel; | 35 class ToolbarModel; |
| 31 | 36 |
| 32 class LocationBarViewGtk : public AutocompleteEditController, | 37 class LocationBarViewGtk : public AutocompleteEditController, |
| 33 public LocationBar, | 38 public LocationBar, |
| 34 public LocationBarTesting, | 39 public LocationBarTesting, |
| 35 public NotificationObserver { | 40 public NotificationObserver { |
| 36 public: | 41 public: |
| 37 LocationBarViewGtk(CommandUpdater* command_updater, | 42 LocationBarViewGtk(CommandUpdater* command_updater, |
| 38 ToolbarModel* toolbar_model, | 43 ToolbarModel* toolbar_model, |
| 39 AutocompletePopupPositioner* popup_positioner); | 44 AutocompletePopupPositioner* popup_positioner, |
| 45 Browser* browser_); |
| 40 virtual ~LocationBarViewGtk(); | 46 virtual ~LocationBarViewGtk(); |
| 41 | 47 |
| 42 void Init(bool popup_window_mode); | 48 void Init(bool popup_window_mode); |
| 43 | 49 |
| 44 void SetProfile(Profile* profile); | 50 void SetProfile(Profile* profile); |
| 45 | 51 |
| 46 // Returns the widget the caller should host. You must call Init() first. | 52 // Returns the widget the caller should host. You must call Init() first. |
| 47 GtkWidget* widget() { return hbox_.get(); } | 53 GtkWidget* widget() { return hbox_.get(); } |
| 48 | 54 |
| 49 // Updates the location bar. We also reset the bar's permanent text and | 55 // Updates the location bar. We also reset the bar's permanent text and |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // Implement the NotificationObserver interface. | 91 // Implement the NotificationObserver interface. |
| 86 virtual void Observe(NotificationType type, | 92 virtual void Observe(NotificationType type, |
| 87 const NotificationSource& source, | 93 const NotificationSource& source, |
| 88 const NotificationDetails& details); | 94 const NotificationDetails& details); |
| 89 | 95 |
| 90 // Translation between a security level and the background color. Both the | 96 // Translation between a security level and the background color. Both the |
| 91 // location bar and edit have to manage and match the background color. | 97 // location bar and edit have to manage and match the background color. |
| 92 static const GdkColor kBackgroundColorByLevel[3]; | 98 static const GdkColor kBackgroundColorByLevel[3]; |
| 93 | 99 |
| 94 private: | 100 private: |
| 101 class PageActionViewGtk : public ImageLoadingTracker::Observer { |
| 102 public: |
| 103 PageActionViewGtk( |
| 104 LocationBarViewGtk* owner, Profile* profile, |
| 105 const PageAction* page_action); |
| 106 virtual ~PageActionViewGtk(); |
| 107 |
| 108 GtkWidget* widget() { return event_box_.get(); } |
| 109 |
| 110 // Called to notify the PageAction that it should determine whether to be |
| 111 // visible or hidden. |contents| is the TabContents that is active, |url| |
| 112 // is the current page URL. |
| 113 void UpdateVisibility(TabContents* contents, GURL url); |
| 114 |
| 115 // A callback from ImageLoadingTracker for when the image has loaded. |
| 116 virtual void OnImageLoaded(SkBitmap* image, size_t index); |
| 117 |
| 118 private: |
| 119 static gboolean OnButtonPressed(GtkWidget* sender, GdkEventButton* event, |
| 120 PageActionViewGtk* page_action_view); |
| 121 |
| 122 // The location bar view that owns us. |
| 123 LocationBarViewGtk* owner_; |
| 124 |
| 125 // The current profile (not owned by us). |
| 126 Profile* profile_; |
| 127 |
| 128 // The PageAction that this view represents. The PageAction is not owned by |
| 129 // us, it resides in the extension of this particular profile. |
| 130 const PageAction* page_action_; |
| 131 |
| 132 // The icons representing different states for the page action. |
| 133 std::vector<GdkPixbuf*> pixbufs_; |
| 134 |
| 135 // The object that is waiting for the image loading to complete |
| 136 // asynchronously. It will delete itself once it is done. |
| 137 ImageLoadingTracker* tracker_; |
| 138 |
| 139 // The widgets for this page action. |
| 140 OwnedWidgetGtk event_box_; |
| 141 OwnedWidgetGtk image_; |
| 142 |
| 143 // The tab id we are currently showing the icon for. |
| 144 int current_tab_id_; |
| 145 |
| 146 // The URL we are currently showing the icon for. |
| 147 GURL current_url_; |
| 148 |
| 149 DISALLOW_COPY_AND_ASSIGN(PageActionViewGtk); |
| 150 }; |
| 151 |
| 95 static gboolean HandleExposeThunk(GtkWidget* widget, GdkEventExpose* event, | 152 static gboolean HandleExposeThunk(GtkWidget* widget, GdkEventExpose* event, |
| 96 gpointer userdata) { | 153 gpointer userdata) { |
| 97 return reinterpret_cast<LocationBarViewGtk*>(userdata)-> | 154 return reinterpret_cast<LocationBarViewGtk*>(userdata)-> |
| 98 HandleExpose(widget, event); | 155 HandleExpose(widget, event); |
| 99 } | 156 } |
| 100 | 157 |
| 101 gboolean HandleExpose(GtkWidget* widget, GdkEventExpose* event); | 158 gboolean HandleExpose(GtkWidget* widget, GdkEventExpose* event); |
| 102 | 159 |
| 103 static gboolean OnSecurityIconPressed(GtkWidget* sender, | 160 static gboolean OnSecurityIconPressed(GtkWidget* sender, |
| 104 GdkEventButton* event, | 161 GdkEventButton* event, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 122 // The outermost widget we want to be hosted. | 179 // The outermost widget we want to be hosted. |
| 123 OwnedWidgetGtk hbox_; | 180 OwnedWidgetGtk hbox_; |
| 124 | 181 |
| 125 // SSL icons. | 182 // SSL icons. |
| 126 GtkWidget* security_icon_event_box_; | 183 GtkWidget* security_icon_event_box_; |
| 127 GtkWidget* security_lock_icon_image_; | 184 GtkWidget* security_lock_icon_image_; |
| 128 GtkWidget* security_warning_icon_image_; | 185 GtkWidget* security_warning_icon_image_; |
| 129 // Toolbar info text (EV cert info). | 186 // Toolbar info text (EV cert info). |
| 130 GtkWidget* info_label_; | 187 GtkWidget* info_label_; |
| 131 | 188 |
| 189 // Extension page action icons. |
| 190 GtkWidget* page_action_hbox_; |
| 191 ScopedVector<PageActionViewGtk> page_action_views_; |
| 192 |
| 132 // Area on the left shown when in tab to search mode. | 193 // Area on the left shown when in tab to search mode. |
| 133 GtkWidget* tab_to_search_box_; | 194 GtkWidget* tab_to_search_box_; |
| 134 GtkWidget* tab_to_search_label_; | 195 GtkWidget* tab_to_search_label_; |
| 135 | 196 |
| 136 // Hint to user that they can tab-to-search by hitting tab. | 197 // Hint to user that they can tab-to-search by hitting tab. |
| 137 GtkWidget* tab_to_search_hint_; | 198 GtkWidget* tab_to_search_hint_; |
| 138 GtkWidget* tab_to_search_hint_leading_label_; | 199 GtkWidget* tab_to_search_hint_leading_label_; |
| 139 GtkWidget* tab_to_search_hint_icon_; | 200 GtkWidget* tab_to_search_hint_icon_; |
| 140 GtkWidget* tab_to_search_hint_trailing_label_; | 201 GtkWidget* tab_to_search_hint_trailing_label_; |
| 141 | 202 |
| 142 scoped_ptr<AutocompleteEditViewGtk> location_entry_; | 203 scoped_ptr<AutocompleteEditViewGtk> location_entry_; |
| 143 | 204 |
| 144 Profile* profile_; | 205 Profile* profile_; |
| 145 CommandUpdater* command_updater_; | 206 CommandUpdater* command_updater_; |
| 146 ToolbarModel* toolbar_model_; | 207 ToolbarModel* toolbar_model_; |
| 208 Browser* browser_; |
| 147 | 209 |
| 148 // We need to hold on to this just to it pass to the edit. | 210 // We need to hold on to this just to it pass to the edit. |
| 149 AutocompletePopupPositioner* popup_positioner_; | 211 AutocompletePopupPositioner* popup_positioner_; |
| 150 | 212 |
| 151 // When we get an OnAutocompleteAccept notification from the autocomplete | 213 // When we get an OnAutocompleteAccept notification from the autocomplete |
| 152 // edit, we save the input string so we can give it back to the browser on | 214 // edit, we save the input string so we can give it back to the browser on |
| 153 // the LocationBar interface via GetInputString(). | 215 // the LocationBar interface via GetInputString(). |
| 154 std::wstring location_input_; | 216 std::wstring location_input_; |
| 155 | 217 |
| 156 // The user's desired disposition for how their input should be opened. | 218 // The user's desired disposition for how their input should be opened. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 168 | 230 |
| 169 // Provides colors and rendering mode. | 231 // Provides colors and rendering mode. |
| 170 GtkThemeProvider* theme_provider_; | 232 GtkThemeProvider* theme_provider_; |
| 171 | 233 |
| 172 NotificationRegistrar registrar_; | 234 NotificationRegistrar registrar_; |
| 173 | 235 |
| 174 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); | 236 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); |
| 175 }; | 237 }; |
| 176 | 238 |
| 177 #endif // CHROME_BROWSER_GTK_LOCATION_BAR_VIEW_GTK_H_ | 239 #endif // CHROME_BROWSER_GTK_LOCATION_BAR_VIEW_GTK_H_ |
| OLD | NEW |