Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: chrome/browser/gtk/location_bar_view_gtk.h

Issue 1107007: Extension context menu refactor (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <map> 10 #include <map>
11 #include <string> 11 #include <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/extension_context_menu_model.h"
18 #include "chrome/browser/extensions/image_loading_tracker.h" 19 #include "chrome/browser/extensions/image_loading_tracker.h"
19 #include "chrome/browser/gtk/info_bubble_gtk.h" 20 #include "chrome/browser/gtk/info_bubble_gtk.h"
20 #include "chrome/browser/gtk/menu_gtk.h" 21 #include "chrome/browser/gtk/menu_gtk.h"
21 #include "chrome/browser/location_bar.h" 22 #include "chrome/browser/location_bar.h"
22 #include "chrome/common/content_settings_types.h" 23 #include "chrome/common/content_settings_types.h"
23 #include "chrome/common/notification_observer.h" 24 #include "chrome/common/notification_observer.h"
24 #include "chrome/common/notification_registrar.h" 25 #include "chrome/common/notification_registrar.h"
25 #include "chrome/common/owned_widget_gtk.h" 26 #include "chrome/common/owned_widget_gtk.h"
26 #include "chrome/common/page_transition_types.h" 27 #include "chrome/common/page_transition_types.h"
27 #include "third_party/skia/include/core/SkBitmap.h" 28 #include "third_party/skia/include/core/SkBitmap.h"
28 #include "webkit/glue/window_open_disposition.h" 29 #include "webkit/glue/window_open_disposition.h"
29 30
30 class AutocompleteEditViewGtk; 31 class AutocompleteEditViewGtk;
31 class BubblePositioner; 32 class BubblePositioner;
32 class Browser; 33 class Browser;
33 class CommandUpdater; 34 class CommandUpdater;
34 class ContentSettingImageModel; 35 class ContentSettingImageModel;
35 class ContentSettingBubbleGtk; 36 class ContentSettingBubbleGtk;
36 class ExtensionAction; 37 class ExtensionAction;
37 class ExtensionActionContextMenuModel;
38 class GtkThemeProvider; 38 class GtkThemeProvider;
39 class Profile; 39 class Profile;
40 class SkBitmap; 40 class SkBitmap;
41 class TabContents; 41 class TabContents;
42 class ToolbarModel; 42 class ToolbarModel;
43 43
44 class LocationBarViewGtk : public AutocompleteEditController, 44 class LocationBarViewGtk : public AutocompleteEditController,
45 public LocationBar, 45 public LocationBar,
46 public LocationBarTesting, 46 public LocationBarTesting,
47 public NotificationObserver { 47 public NotificationObserver {
48 public: 48 public:
49 LocationBarViewGtk(CommandUpdater* command_updater, 49 LocationBarViewGtk(const BubblePositioner* bubble_positioner,
50 ToolbarModel* toolbar_model,
51 const BubblePositioner* bubble_positioner,
52 Browser* browser_); 50 Browser* browser_);
53 virtual ~LocationBarViewGtk(); 51 virtual ~LocationBarViewGtk();
54 52
55 void Init(bool popup_window_mode); 53 void Init(bool popup_window_mode);
56 54
57 void SetProfile(Profile* profile); 55 void SetProfile(Profile* profile);
58 56
59 // Returns the widget the caller should host. You must call Init() first. 57 // Returns the widget the caller should host. You must call Init() first.
60 GtkWidget* widget() { return hbox_.get(); } 58 GtkWidget* widget() { return hbox_.get(); }
61 59
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 162
165 // The currently active profile. 163 // The currently active profile.
166 Profile* profile_; 164 Profile* profile_;
167 165
168 // The currently shown info bubble if any. 166 // The currently shown info bubble if any.
169 ContentSettingBubbleGtk* info_bubble_; 167 ContentSettingBubbleGtk* info_bubble_;
170 168
171 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageViewGtk); 169 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageViewGtk);
172 }; 170 };
173 171
174 class PageActionViewGtk : public ImageLoadingTracker::Observer { 172 class PageActionViewGtk : public ImageLoadingTracker::Observer,
173 public ExtensionContextMenuModel::PopupDelegate {
175 public: 174 public:
176 PageActionViewGtk( 175 PageActionViewGtk(
177 LocationBarViewGtk* owner, Profile* profile, 176 LocationBarViewGtk* owner, Profile* profile,
178 ExtensionAction* page_action); 177 ExtensionAction* page_action);
179 virtual ~PageActionViewGtk(); 178 virtual ~PageActionViewGtk();
180 179
181 GtkWidget* widget() { return event_box_.get(); } 180 GtkWidget* widget() { return event_box_.get(); }
182 181
183 ExtensionAction* page_action() { return page_action_; } 182 ExtensionAction* page_action() { return page_action_; }
184 183
185 void set_preview_enabled(bool preview_enabled) { 184 void set_preview_enabled(bool preview_enabled) {
186 preview_enabled_ = preview_enabled; 185 preview_enabled_ = preview_enabled;
187 } 186 }
188 187
189 bool IsVisible() { return GTK_WIDGET_VISIBLE(widget()); } 188 bool IsVisible() { return GTK_WIDGET_VISIBLE(widget()); }
190 189
191 // Called to notify the PageAction that it should determine whether to be 190 // Called to notify the PageAction that it should determine whether to be
192 // visible or hidden. |contents| is the TabContents that is active, |url| 191 // visible or hidden. |contents| is the TabContents that is active, |url|
193 // is the current page URL. 192 // is the current page URL.
194 void UpdateVisibility(TabContents* contents, GURL url); 193 void UpdateVisibility(TabContents* contents, GURL url);
195 194
196 // A callback from ImageLoadingTracker for when the image has loaded. 195 // A callback from ImageLoadingTracker for when the image has loaded.
197 virtual void OnImageLoaded(SkBitmap* image, size_t index); 196 virtual void OnImageLoaded(SkBitmap* image, size_t index);
198 197
199 // Simulate left mouse click on the page action button. 198 // Simulate left mouse click on the page action button.
200 void TestActivatePageAction(); 199 void TestActivatePageAction();
201 200
201 // Overridden from ExtensionContextMenuModel::PopupDelegate:
202 virtual void InspectPopup(ExtensionAction* action);
203
202 private: 204 private:
203 static gboolean OnButtonPressedThunk(GtkWidget* sender, 205 static gboolean OnButtonPressedThunk(GtkWidget* sender,
204 GdkEvent* event, 206 GdkEvent* event,
205 PageActionViewGtk* page_action_view) { 207 PageActionViewGtk* page_action_view) {
206 return page_action_view->OnButtonPressed(sender, event); 208 return page_action_view->OnButtonPressed(sender, event);
207 } 209 }
208 gboolean OnButtonPressed(GtkWidget* sender, GdkEvent* event); 210 gboolean OnButtonPressed(GtkWidget* sender, GdkEvent* event);
209 211
210 static gboolean OnExposeEventThunk(GtkWidget* widget, 212 static gboolean OnExposeEventThunk(GtkWidget* widget,
211 GdkEventExpose* event, 213 GdkEventExpose* event,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 249
248 // The URL we are currently showing the icon for. 250 // The URL we are currently showing the icon for.
249 GURL current_url_; 251 GURL current_url_;
250 252
251 // This is used for post-install visual feedback. The page_action icon 253 // This is used for post-install visual feedback. The page_action icon
252 // is briefly shown even if it hasn't been enabled by its extension. 254 // is briefly shown even if it hasn't been enabled by its extension.
253 bool preview_enabled_; 255 bool preview_enabled_;
254 256
255 // The context menu view and model for this extension action. 257 // The context menu view and model for this extension action.
256 scoped_ptr<MenuGtk> context_menu_; 258 scoped_ptr<MenuGtk> context_menu_;
257 scoped_ptr<ExtensionActionContextMenuModel> context_menu_model_; 259 scoped_ptr<ExtensionContextMenuModel> context_menu_model_;
258 260
259 DISALLOW_COPY_AND_ASSIGN(PageActionViewGtk); 261 DISALLOW_COPY_AND_ASSIGN(PageActionViewGtk);
260 }; 262 };
261 friend class PageActionViewGtk; 263 friend class PageActionViewGtk;
262 264
263 static gboolean HandleExposeThunk(GtkWidget* widget, GdkEventExpose* event, 265 static gboolean HandleExposeThunk(GtkWidget* widget, GdkEventExpose* event,
264 gpointer userdata) { 266 gpointer userdata) {
265 return reinterpret_cast<LocationBarViewGtk*>(userdata)-> 267 return reinterpret_cast<LocationBarViewGtk*>(userdata)->
266 HandleExpose(widget, event); 268 HandleExpose(widget, event);
267 } 269 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // Indicate if |tab_to_search_hint_| should be shown. 379 // Indicate if |tab_to_search_hint_| should be shown.
378 bool show_keyword_hint_; 380 bool show_keyword_hint_;
379 381
380 // Indicate if |type_to_search_hint_| should be shown. 382 // Indicate if |type_to_search_hint_| should be shown.
381 bool show_search_hint_; 383 bool show_search_hint_;
382 384
383 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); 385 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk);
384 }; 386 };
385 387
386 #endif // CHROME_BROWSER_GTK_LOCATION_BAR_VIEW_GTK_H_ 388 #endif // CHROME_BROWSER_GTK_LOCATION_BAR_VIEW_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698