| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 class ContentSettingBubbleGtk; | 41 class ContentSettingBubbleGtk; |
| 42 class ExtensionAction; | 42 class ExtensionAction; |
| 43 class ThemeServiceGtk; | 43 class ThemeServiceGtk; |
| 44 class SkBitmap; | 44 class SkBitmap; |
| 45 class ToolbarModel; | 45 class ToolbarModel; |
| 46 | 46 |
| 47 namespace content { | 47 namespace content { |
| 48 class WebContents; | 48 class WebContents; |
| 49 } | 49 } |
| 50 | 50 |
| 51 namespace ui { |
| 52 class AcceleratorGtk; |
| 53 } |
| 54 |
| 51 class LocationBarViewGtk : public AutocompleteEditController, | 55 class LocationBarViewGtk : public AutocompleteEditController, |
| 52 public LocationBar, | 56 public LocationBar, |
| 53 public LocationBarTesting, | 57 public LocationBarTesting, |
| 54 public content::NotificationObserver { | 58 public content::NotificationObserver { |
| 55 public: | 59 public: |
| 56 explicit LocationBarViewGtk(Browser* browser); | 60 explicit LocationBarViewGtk(Browser* browser); |
| 57 virtual ~LocationBarViewGtk(); | 61 virtual ~LocationBarViewGtk(); |
| 58 | 62 |
| 59 void Init(bool popup_window_mode); | 63 void Init(bool popup_window_mode); |
| 60 | 64 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 204 |
| 201 // The label's default requisition (cached so we can animate accordingly). | 205 // The label's default requisition (cached so we can animate accordingly). |
| 202 GtkRequisition label_req_; | 206 GtkRequisition label_req_; |
| 203 | 207 |
| 204 base::WeakPtrFactory<ContentSettingImageViewGtk> weak_factory_; | 208 base::WeakPtrFactory<ContentSettingImageViewGtk> weak_factory_; |
| 205 | 209 |
| 206 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageViewGtk); | 210 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageViewGtk); |
| 207 }; | 211 }; |
| 208 | 212 |
| 209 class PageActionViewGtk : public ImageLoadingTracker::Observer, | 213 class PageActionViewGtk : public ImageLoadingTracker::Observer, |
| 214 public content::NotificationObserver, |
| 210 public ExtensionContextMenuModel::PopupDelegate { | 215 public ExtensionContextMenuModel::PopupDelegate { |
| 211 public: | 216 public: |
| 212 PageActionViewGtk(LocationBarViewGtk* owner, ExtensionAction* page_action); | 217 PageActionViewGtk(LocationBarViewGtk* owner, ExtensionAction* page_action); |
| 213 virtual ~PageActionViewGtk(); | 218 virtual ~PageActionViewGtk(); |
| 214 | 219 |
| 215 GtkWidget* widget() { return event_box_.get(); } | 220 GtkWidget* widget() { return event_box_.get(); } |
| 216 | 221 |
| 217 ExtensionAction* page_action() { return page_action_; } | 222 ExtensionAction* page_action() { return page_action_; } |
| 218 | 223 |
| 219 void set_preview_enabled(bool preview_enabled) { | 224 void set_preview_enabled(bool preview_enabled) { |
| 220 preview_enabled_ = preview_enabled; | 225 preview_enabled_ = preview_enabled; |
| 221 } | 226 } |
| 222 | 227 |
| 223 bool IsVisible(); | 228 bool IsVisible(); |
| 224 | 229 |
| 225 // Called to notify the PageAction that it should determine whether to be | 230 // Called to notify the PageAction that it should determine whether to be |
| 226 // visible or hidden. |contents| is the TabContents that is active, |url| | 231 // visible or hidden. |contents| is the TabContents that is active, |url| |
| 227 // is the current page URL. | 232 // is the current page URL. |
| 228 void UpdateVisibility(content::WebContents* contents, const GURL& url); | 233 void UpdateVisibility(content::WebContents* contents, const GURL& url); |
| 229 | 234 |
| 230 // A callback from ImageLoadingTracker for when the image has loaded. | 235 // A callback from ImageLoadingTracker for when the image has loaded. |
| 231 virtual void OnImageLoaded(const gfx::Image& image, | 236 virtual void OnImageLoaded(const gfx::Image& image, |
| 232 const std::string& extension_id, | 237 const std::string& extension_id, |
| 233 int index) OVERRIDE; | 238 int index) OVERRIDE; |
| 234 | 239 |
| 235 // Simulate left mouse click on the page action button. | 240 // Simulate left mouse click on the page action button. |
| 236 void TestActivatePageAction(); | 241 void TestActivatePageAction(); |
| 237 | 242 |
| 243 // Implement the content::NotificationObserver interface. |
| 244 virtual void Observe(int type, |
| 245 const content::NotificationSource& source, |
| 246 const content::NotificationDetails& details) OVERRIDE; |
| 247 |
| 238 // Overridden from ExtensionContextMenuModel::PopupDelegate: | 248 // Overridden from ExtensionContextMenuModel::PopupDelegate: |
| 239 virtual void InspectPopup(ExtensionAction* action) OVERRIDE; | 249 virtual void InspectPopup(ExtensionAction* action) OVERRIDE; |
| 240 | 250 |
| 241 private: | 251 private: |
| 242 // Show the popup for this page action. If |devtools| is true, show it | 252 // Show the popup for this page action. If |devtools| is true, show it |
| 243 // with a debugger window attached. Returns true if a popup was shown. | 253 // with a debugger window attached. Returns true if a popup was shown. |
| 244 bool ShowPopup(bool devtools); | 254 bool ShowPopup(bool devtools); |
| 245 | 255 |
| 256 // Connect the accelerator for the page action popup. |
| 257 void ConnectPageActionAccelerator(); |
| 258 |
| 259 // Disconnect the accelerator for the page action popup. |
| 260 void DisconnectPageActionAccelerator(); |
| 261 |
| 246 CHROMEGTK_CALLBACK_1(PageActionViewGtk, gboolean, OnButtonPressed, | 262 CHROMEGTK_CALLBACK_1(PageActionViewGtk, gboolean, OnButtonPressed, |
| 247 GdkEventButton*); | 263 GdkEventButton*); |
| 248 CHROMEGTK_CALLBACK_1(PageActionViewGtk, gboolean, OnExposeEvent, | 264 CHROMEGTK_CALLBACK_1(PageActionViewGtk, gboolean, OnExposeEvent, |
| 249 GdkEventExpose*); | 265 GdkEventExpose*); |
| 266 CHROMEGTK_CALLBACK_0(PageActionViewGtk, void, OnRealize); |
| 267 |
| 268 // The accelerator handler for when the shortcuts to open the popup is |
| 269 // struck. |
| 270 static gboolean OnGtkAccelerator(GtkAccelGroup* accel_group, |
| 271 GObject* acceleratable, |
| 272 guint keyval, |
| 273 GdkModifierType modifier, |
| 274 void* user_data); |
| 250 | 275 |
| 251 // The location bar view that owns us. | 276 // The location bar view that owns us. |
| 252 LocationBarViewGtk* owner_; | 277 LocationBarViewGtk* owner_; |
| 253 | 278 |
| 254 // The PageAction that this view represents. The PageAction is not owned by | 279 // The PageAction that this view represents. The PageAction is not owned by |
| 255 // us, it resides in the extension of this particular profile. | 280 // us, it resides in the extension of this particular profile. |
| 256 ExtensionAction* page_action_; | 281 ExtensionAction* page_action_; |
| 257 | 282 |
| 258 // A cache of all the different icon paths associated with this page action. | 283 // A cache of all the different icon paths associated with this page action. |
| 259 typedef std::map<std::string, GdkPixbuf*> PixbufMap; | 284 typedef std::map<std::string, GdkPixbuf*> PixbufMap; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 272 // The widgets for this page action. | 297 // The widgets for this page action. |
| 273 ui::OwnedWidgetGtk event_box_; | 298 ui::OwnedWidgetGtk event_box_; |
| 274 ui::OwnedWidgetGtk image_; | 299 ui::OwnedWidgetGtk image_; |
| 275 | 300 |
| 276 // The tab id we are currently showing the icon for. | 301 // The tab id we are currently showing the icon for. |
| 277 int current_tab_id_; | 302 int current_tab_id_; |
| 278 | 303 |
| 279 // The URL we are currently showing the icon for. | 304 // The URL we are currently showing the icon for. |
| 280 GURL current_url_; | 305 GURL current_url_; |
| 281 | 306 |
| 307 // The native browser window of the location bar that owns us. |
| 308 gfx::NativeWindow window_; |
| 309 |
| 310 // The Notification registrar. |
| 311 content::NotificationRegistrar registrar_; |
| 312 |
| 313 // The accelerator group used to handle accelerators, owned by this object. |
| 314 GtkAccelGroup* accel_group_; |
| 315 |
| 316 // The keybinding accelerator registered to show the page action popup. |
| 317 scoped_ptr<ui::AcceleratorGtk> keybinding_; |
| 318 |
| 282 // This is used for post-install visual feedback. The page_action icon | 319 // This is used for post-install visual feedback. The page_action icon |
| 283 // is briefly shown even if it hasn't been enabled by its extension. | 320 // is briefly shown even if it hasn't been enabled by its extension. |
| 284 bool preview_enabled_; | 321 bool preview_enabled_; |
| 285 | 322 |
| 286 // The context menu view and model for this extension action. | 323 // The context menu view and model for this extension action. |
| 287 scoped_ptr<MenuGtk> context_menu_; | 324 scoped_ptr<MenuGtk> context_menu_; |
| 288 scoped_refptr<ExtensionContextMenuModel> context_menu_model_; | 325 scoped_refptr<ExtensionContextMenuModel> context_menu_model_; |
| 289 | 326 |
| 290 DISALLOW_COPY_AND_ASSIGN(PageActionViewGtk); | 327 DISALLOW_COPY_AND_ASSIGN(PageActionViewGtk); |
| 291 }; | 328 }; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 // The last search keyword that was shown via the |tab_to_search_box_|. | 480 // The last search keyword that was shown via the |tab_to_search_box_|. |
| 444 string16 last_keyword_; | 481 string16 last_keyword_; |
| 445 | 482 |
| 446 // Used to change the visibility of the star decoration. | 483 // Used to change the visibility of the star decoration. |
| 447 BooleanPrefMember edit_bookmarks_enabled_; | 484 BooleanPrefMember edit_bookmarks_enabled_; |
| 448 | 485 |
| 449 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); | 486 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); |
| 450 }; | 487 }; |
| 451 | 488 |
| 452 #endif // CHROME_BROWSER_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ | 489 #endif // CHROME_BROWSER_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ |
| OLD | NEW |