| 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 | 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/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "chrome/browser/api/prefs/pref_member.h" | 19 #include "chrome/browser/api/prefs/pref_member.h" |
| 20 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
| 20 #include "chrome/browser/extensions/extension_context_menu_model.h" | 21 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 21 #include "chrome/browser/extensions/image_loading_tracker.h" | |
| 22 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 22 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
| 23 #include "chrome/browser/ui/gtk/menu_gtk.h" | 23 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 24 #include "chrome/browser/ui/omnibox/location_bar.h" | 24 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 25 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 25 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
| 26 #include "chrome/browser/ui/view_ids.h" | 26 #include "chrome/browser/ui/view_ids.h" |
| 27 #include "chrome/common/content_settings_types.h" | 27 #include "chrome/common/content_settings_types.h" |
| 28 #include "chrome/common/extensions/extension_action.h" | 28 #include "chrome/common/extensions/extension_action.h" |
| 29 #include "content/public/browser/notification_observer.h" | 29 #include "content/public/browser/notification_observer.h" |
| 30 #include "content/public/browser/notification_registrar.h" | 30 #include "content/public/browser/notification_registrar.h" |
| 31 #include "content/public/common/page_transition_types.h" | 31 #include "content/public/common/page_transition_types.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 GtkRequisition label_req_; | 219 GtkRequisition label_req_; |
| 220 | 220 |
| 221 base::WeakPtrFactory<PageToolViewGtk> weak_factory_; | 221 base::WeakPtrFactory<PageToolViewGtk> weak_factory_; |
| 222 | 222 |
| 223 private: | 223 private: |
| 224 DISALLOW_COPY_AND_ASSIGN(PageToolViewGtk); | 224 DISALLOW_COPY_AND_ASSIGN(PageToolViewGtk); |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 private: | 227 private: |
| 228 class PageActionViewGtk : | 228 class PageActionViewGtk : |
| 229 public ImageLoadingTracker::Observer, | 229 public ExtensionActionIconFactory::Observer, |
| 230 public content::NotificationObserver, | 230 public content::NotificationObserver, |
| 231 public ExtensionContextMenuModel::PopupDelegate, | 231 public ExtensionContextMenuModel::PopupDelegate, |
| 232 public ExtensionAction::IconAnimation::Observer { | 232 public ExtensionAction::IconAnimation::Observer { |
| 233 public: | 233 public: |
| 234 PageActionViewGtk(LocationBarViewGtk* owner, ExtensionAction* page_action); | 234 PageActionViewGtk(LocationBarViewGtk* owner, ExtensionAction* page_action); |
| 235 virtual ~PageActionViewGtk(); | 235 virtual ~PageActionViewGtk(); |
| 236 | 236 |
| 237 GtkWidget* widget() { return event_box_.get(); } | 237 GtkWidget* widget() { return event_box_.get(); } |
| 238 | 238 |
| 239 ExtensionAction* page_action() { return page_action_; } | 239 ExtensionAction* page_action() { return page_action_; } |
| 240 | 240 |
| 241 void set_preview_enabled(bool preview_enabled) { | 241 void set_preview_enabled(bool preview_enabled) { |
| 242 preview_enabled_ = preview_enabled; | 242 preview_enabled_ = preview_enabled; |
| 243 } | 243 } |
| 244 | 244 |
| 245 bool IsVisible(); | 245 bool IsVisible(); |
| 246 | 246 |
| 247 // Called to notify the PageAction that it should determine whether to be | 247 // Called to notify the PageAction that it should determine whether to be |
| 248 // visible or hidden. |contents| is the WebContents that is active, |url| | 248 // visible or hidden. |contents| is the WebContents that is active, |url| |
| 249 // is the current page URL. | 249 // is the current page URL. |
| 250 void UpdateVisibility(content::WebContents* contents, const GURL& url); | 250 void UpdateVisibility(content::WebContents* contents, const GURL& url); |
| 251 | 251 |
| 252 // A callback from ImageLoadingTracker for when the image has loaded. | 252 // Overriden from ExtensionActionIconFactory::Observer. |
| 253 virtual void OnImageLoaded(const gfx::Image& image, | 253 virtual void OnIconUpdated() OVERRIDE; |
| 254 const std::string& extension_id, | |
| 255 int index) OVERRIDE; | |
| 256 | 254 |
| 257 // Simulate left mouse click on the page action button. | 255 // Simulate left mouse click on the page action button. |
| 258 void TestActivatePageAction(); | 256 void TestActivatePageAction(); |
| 259 | 257 |
| 260 // Implement the content::NotificationObserver interface. | 258 // Implement the content::NotificationObserver interface. |
| 261 virtual void Observe(int type, | 259 virtual void Observe(int type, |
| 262 const content::NotificationSource& source, | 260 const content::NotificationSource& source, |
| 263 const content::NotificationDetails& details) OVERRIDE; | 261 const content::NotificationDetails& details) OVERRIDE; |
| 264 | 262 |
| 265 // Overridden from ExtensionContextMenuModel::PopupDelegate: | 263 // Overridden from ExtensionContextMenuModel::PopupDelegate: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 289 // ExtensionAction::IconAnimationDelegate implementation. | 287 // ExtensionAction::IconAnimationDelegate implementation. |
| 290 virtual void OnIconChanged() OVERRIDE; | 288 virtual void OnIconChanged() OVERRIDE; |
| 291 | 289 |
| 292 // The location bar view that owns us. | 290 // The location bar view that owns us. |
| 293 LocationBarViewGtk* owner_; | 291 LocationBarViewGtk* owner_; |
| 294 | 292 |
| 295 // The PageAction that this view represents. The PageAction is not owned by | 293 // The PageAction that this view represents. The PageAction is not owned by |
| 296 // us, it resides in the extension of this particular profile. | 294 // us, it resides in the extension of this particular profile. |
| 297 ExtensionAction* page_action_; | 295 ExtensionAction* page_action_; |
| 298 | 296 |
| 299 // The object that is waiting for the image loading to complete | 297 // The object that page action will use to create icon for us. |
| 300 // asynchronously. | 298 // It may load icon asynchronously (in which case initial icon returned by |
| 301 ImageLoadingTracker tracker_; | 299 // the action will be blank), so we have to observe it for icon's updates. |
| 300 scoped_ptr<ExtensionActionIconFactory> icon_factory_; |
| 302 | 301 |
| 303 // The widgets for this page action. | 302 // The widgets for this page action. |
| 304 ui::OwnedWidgetGtk event_box_; | 303 ui::OwnedWidgetGtk event_box_; |
| 305 ui::OwnedWidgetGtk image_; | 304 ui::OwnedWidgetGtk image_; |
| 306 | 305 |
| 307 // The tab id we are currently showing the icon for. | 306 // The tab id we are currently showing the icon for. |
| 308 int current_tab_id_; | 307 int current_tab_id_; |
| 309 | 308 |
| 310 // The URL we are currently showing the icon for. | 309 // The URL we are currently showing the icon for. |
| 311 GURL current_url_; | 310 GURL current_url_; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 BooleanPrefMember edit_bookmarks_enabled_; | 530 BooleanPrefMember edit_bookmarks_enabled_; |
| 532 | 531 |
| 533 // Used to remember the URL and title text when drag&drop has begun. | 532 // Used to remember the URL and title text when drag&drop has begun. |
| 534 GURL drag_url_; | 533 GURL drag_url_; |
| 535 string16 drag_title_; | 534 string16 drag_title_; |
| 536 | 535 |
| 537 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); | 536 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); |
| 538 }; | 537 }; |
| 539 | 538 |
| 540 #endif // CHROME_BROWSER_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ | 539 #endif // CHROME_BROWSER_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ |
| OLD | NEW |