| 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 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <set> |
| 12 #include <string> | 13 #include <string> |
| 13 | 14 |
| 14 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
| 18 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 20 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 20 #include "chrome/browser/command_updater.h" | 21 #include "chrome/browser/command_updater.h" |
| 22 #include "chrome/browser/extensions/action_box_controller.h" |
| 21 #include "chrome/browser/extensions/extension_context_menu_model.h" | 23 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 22 #include "chrome/browser/extensions/image_loading_tracker.h" | 24 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 23 #include "chrome/browser/prefs/pref_member.h" | 25 #include "chrome/browser/prefs/pref_member.h" |
| 24 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 26 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
| 25 #include "chrome/browser/ui/gtk/menu_gtk.h" | 27 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 26 #include "chrome/browser/ui/omnibox/location_bar.h" | 28 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 27 #include "chrome/common/content_settings_types.h" | 29 #include "chrome/common/content_settings_types.h" |
| 28 #include "content/public/browser/notification_observer.h" | 30 #include "content/public/browser/notification_observer.h" |
| 29 #include "content/public/browser/notification_registrar.h" | 31 #include "content/public/browser/notification_registrar.h" |
| 30 #include "content/public/common/page_transition_types.h" | 32 #include "content/public/common/page_transition_types.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 GtkWidget* location_icon_widget() const { return location_icon_image_; } | 73 GtkWidget* location_icon_widget() const { return location_icon_image_; } |
| 72 | 74 |
| 73 // Returns the widget the extension installed bubble should point to. | 75 // Returns the widget the extension installed bubble should point to. |
| 74 GtkWidget* location_entry_widget() const { return entry_box_; } | 76 GtkWidget* location_entry_widget() const { return entry_box_; } |
| 75 | 77 |
| 76 Browser* browser() const { return browser_; } | 78 Browser* browser() const { return browser_; } |
| 77 | 79 |
| 78 // Returns the current WebContents. | 80 // Returns the current WebContents. |
| 79 content::WebContents* GetWebContents() const; | 81 content::WebContents* GetWebContents() const; |
| 80 | 82 |
| 81 // Sets |preview_enabled| for the PageActionViewGtk associated with this | 83 // If |preview_enabled| is true, the view will display the |
| 82 // |page_action|. If |preview_enabled| is true, the view will display the | 84 // This is used by the ExtensionInstalledBubbleGtk to preview what the icon |
| 83 // page action's icon even though it has not been activated by the extension. | 85 // page action's icon even though it has not been activated by the extension. |
| 84 // This is used by the ExtensionInstalledBubbleGtk to preview what the icon | |
| 85 // will look like for the user upon installation of the extension. | 86 // will look like for the user upon installation of the extension. |
| 86 void SetPreviewEnabledPageAction(ExtensionAction *page_action, | 87 void SetPreviewEnabledPageAction(ExtensionAction *page_action, |
| 87 bool preview_enabled); | 88 bool preview_enabled); |
| 88 | 89 |
| 89 // Retrieves the GtkWidget which is associated with PageActionView | 90 // Retrieves the GtkWidget which is associated with PageActionView |
| 90 // corresponding to |page_action|. | 91 // corresponding to |page_action|. |
| 91 GtkWidget* GetPageActionWidget(ExtensionAction* page_action); | 92 GtkWidget* GetPageActionWidget(ExtensionAction* page_action); |
| 92 | 93 |
| 93 // Updates the location bar. We also reset the bar's permanent text and | 94 // Updates the location bar. We also reset the bar's permanent text and |
| 94 // security style, and, if |tab_for_state_restoring| is non-NULL, also | 95 // security style, and, if |tab_for_state_restoring| is non-NULL, also |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 class PageActionViewGtk : public ImageLoadingTracker::Observer, | 222 class PageActionViewGtk : public ImageLoadingTracker::Observer, |
| 222 public content::NotificationObserver { | 223 public content::NotificationObserver { |
| 223 public: | 224 public: |
| 224 PageActionViewGtk(LocationBarViewGtk* owner, ExtensionAction* page_action); | 225 PageActionViewGtk(LocationBarViewGtk* owner, ExtensionAction* page_action); |
| 225 virtual ~PageActionViewGtk(); | 226 virtual ~PageActionViewGtk(); |
| 226 | 227 |
| 227 GtkWidget* widget() { return event_box_.get(); } | 228 GtkWidget* widget() { return event_box_.get(); } |
| 228 | 229 |
| 229 ExtensionAction* page_action() { return page_action_; } | 230 ExtensionAction* page_action() { return page_action_; } |
| 230 | 231 |
| 231 void set_preview_enabled(bool preview_enabled) { | 232 // Called to notify the PageAction that it should update based on the state |
| 232 preview_enabled_ = preview_enabled; | 233 // of |page_action_|. |contents| is the WebContents that is active, |url| |
| 233 } | |
| 234 | |
| 235 bool IsVisible(); | |
| 236 | |
| 237 // Called to notify the PageAction that it should determine whether to be | |
| 238 // visible or hidden. |contents| is the WebContents that is active, |url| | |
| 239 // is the current page URL. | 234 // is the current page URL. |
| 240 void UpdateVisibility(content::WebContents* contents, const GURL& url); | 235 void Update(content::WebContents* contents, const GURL& url); |
| 241 | 236 |
| 242 // A callback from ImageLoadingTracker for when the image has loaded. | 237 // A callback from ImageLoadingTracker for when the image has loaded. |
| 243 virtual void OnImageLoaded(const gfx::Image& image, | 238 virtual void OnImageLoaded(const gfx::Image& image, |
| 244 const std::string& extension_id, | 239 const std::string& extension_id, |
| 245 int index) OVERRIDE; | 240 int index) OVERRIDE; |
| 246 | 241 |
| 247 // Simulate left mouse click on the page action button. | 242 // Simulate left mouse click on the page action button. |
| 248 void TestActivatePageAction(); | 243 void TestActivatePageAction(); |
| 249 | 244 |
| 250 // Implement the content::NotificationObserver interface. | 245 // Implement the content::NotificationObserver interface. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 304 |
| 310 // The Notification registrar. | 305 // The Notification registrar. |
| 311 content::NotificationRegistrar registrar_; | 306 content::NotificationRegistrar registrar_; |
| 312 | 307 |
| 313 // The accelerator group used to handle accelerators, owned by this object. | 308 // The accelerator group used to handle accelerators, owned by this object. |
| 314 GtkAccelGroup* accel_group_; | 309 GtkAccelGroup* accel_group_; |
| 315 | 310 |
| 316 // The keybinding accelerator registered to show the page action popup. | 311 // The keybinding accelerator registered to show the page action popup. |
| 317 scoped_ptr<ui::AcceleratorGtk> keybinding_; | 312 scoped_ptr<ui::AcceleratorGtk> keybinding_; |
| 318 | 313 |
| 319 // This is used for post-install visual feedback. The page_action icon | |
| 320 // is briefly shown even if it hasn't been enabled by its extension. | |
| 321 bool preview_enabled_; | |
| 322 | |
| 323 // The context menu view and model for this extension action. | 314 // The context menu view and model for this extension action. |
| 324 scoped_ptr<MenuGtk> context_menu_; | 315 scoped_ptr<MenuGtk> context_menu_; |
| 325 scoped_refptr<ExtensionContextMenuModel> context_menu_model_; | 316 scoped_refptr<ExtensionContextMenuModel> context_menu_model_; |
| 326 | 317 |
| 327 DISALLOW_COPY_AND_ASSIGN(PageActionViewGtk); | 318 DISALLOW_COPY_AND_ASSIGN(PageActionViewGtk); |
| 328 }; | 319 }; |
| 329 friend class PageActionViewGtk; | 320 friend class PageActionViewGtk; |
| 330 | 321 |
| 331 // Creates, initializes, and packs the location icon, EV certificate name, | 322 // Creates, initializes, and packs the location icon, EV certificate name, |
| 332 // and optional border. | 323 // and optional border. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 | 477 |
| 487 // Indicate if |tab_to_search_hint_| should be shown. | 478 // Indicate if |tab_to_search_hint_| should be shown. |
| 488 bool show_keyword_hint_; | 479 bool show_keyword_hint_; |
| 489 | 480 |
| 490 // The last search keyword that was shown via the |tab_to_search_box_|. | 481 // The last search keyword that was shown via the |tab_to_search_box_|. |
| 491 string16 last_keyword_; | 482 string16 last_keyword_; |
| 492 | 483 |
| 493 // Used to change the visibility of the star decoration. | 484 // Used to change the visibility of the star decoration. |
| 494 BooleanPrefMember edit_bookmarks_enabled_; | 485 BooleanPrefMember edit_bookmarks_enabled_; |
| 495 | 486 |
| 487 // The extension actions which have "preview enabled". |
| 488 std::set<ExtensionAction*> preview_enabled_actions_; |
| 489 |
| 496 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); | 490 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); |
| 497 }; | 491 }; |
| 498 | 492 |
| 499 #endif // CHROME_BROWSER_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ | 493 #endif // CHROME_BROWSER_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ |
| OLD | NEW |