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