| 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/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "chrome/browser/api/prefs/pref_member.h" | 18 #include "chrome/browser/api/prefs/pref_member.h" |
| 19 #include "chrome/browser/command_observer.h" | |
| 20 #include "chrome/browser/extensions/extension_context_menu_model.h" | 19 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 21 #include "chrome/browser/extensions/image_loading_tracker.h" | 20 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 22 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 21 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
| 23 #include "chrome/browser/ui/gtk/menu_gtk.h" | 22 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 24 #include "chrome/browser/ui/omnibox/location_bar.h" | 23 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 25 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 24 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
| 26 #include "chrome/browser/ui/view_ids.h" | 25 #include "chrome/browser/ui/view_ids.h" |
| 27 #include "chrome/common/content_settings_types.h" | 26 #include "chrome/common/content_settings_types.h" |
| 28 #include "chrome/common/extensions/extension_action.h" | 27 #include "chrome/common/extensions/extension_action.h" |
| 29 #include "content/public/browser/notification_observer.h" | 28 #include "content/public/browser/notification_observer.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 54 class Image; | 53 class Image; |
| 55 } | 54 } |
| 56 | 55 |
| 57 namespace ui { | 56 namespace ui { |
| 58 class AcceleratorGtk; | 57 class AcceleratorGtk; |
| 59 } | 58 } |
| 60 | 59 |
| 61 class LocationBarViewGtk : public OmniboxEditController, | 60 class LocationBarViewGtk : public OmniboxEditController, |
| 62 public LocationBar, | 61 public LocationBar, |
| 63 public LocationBarTesting, | 62 public LocationBarTesting, |
| 64 public content::NotificationObserver, | 63 public content::NotificationObserver { |
| 65 public CommandObserver { | |
| 66 public: | 64 public: |
| 67 explicit LocationBarViewGtk(Browser* browser); | 65 explicit LocationBarViewGtk(Browser* browser); |
| 68 virtual ~LocationBarViewGtk(); | 66 virtual ~LocationBarViewGtk(); |
| 69 | 67 |
| 70 void Init(bool popup_window_mode); | 68 void Init(bool popup_window_mode); |
| 71 | 69 |
| 72 // Returns the widget the caller should host. You must call Init() first. | 70 // Returns the widget the caller should host. You must call Init() first. |
| 73 GtkWidget* widget() { return hbox_.get(); } | 71 GtkWidget* widget() { return hbox_.get(); } |
| 74 | 72 |
| 75 // Returns the widget the page info bubble should point to. | 73 // Returns the widget the page info bubble should point to. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 virtual int PageActionVisibleCount() OVERRIDE; | 154 virtual int PageActionVisibleCount() OVERRIDE; |
| 157 virtual ExtensionAction* GetPageAction(size_t index) OVERRIDE; | 155 virtual ExtensionAction* GetPageAction(size_t index) OVERRIDE; |
| 158 virtual ExtensionAction* GetVisiblePageAction(size_t index) OVERRIDE; | 156 virtual ExtensionAction* GetVisiblePageAction(size_t index) OVERRIDE; |
| 159 virtual void TestPageActionPressed(size_t index) OVERRIDE; | 157 virtual void TestPageActionPressed(size_t index) OVERRIDE; |
| 160 | 158 |
| 161 // content::NotificationObserver: | 159 // content::NotificationObserver: |
| 162 virtual void Observe(int type, | 160 virtual void Observe(int type, |
| 163 const content::NotificationSource& source, | 161 const content::NotificationSource& source, |
| 164 const content::NotificationDetails& details) OVERRIDE; | 162 const content::NotificationDetails& details) OVERRIDE; |
| 165 | 163 |
| 166 // CommandObserver: | |
| 167 virtual void EnabledStateChangedForCommand(int id, bool enabled) OVERRIDE; | |
| 168 | |
| 169 // Edit background color. | 164 // Edit background color. |
| 170 static const GdkColor kBackgroundColor; | 165 static const GdkColor kBackgroundColor; |
| 171 | 166 |
| 172 // Superclass for content settings icons shown at the left side of the | 167 // Superclass for content settings icons shown at the left side of the |
| 173 // location bar. | 168 // location bar. |
| 174 class PageToolViewGtk : public ui::AnimationDelegate { | 169 class PageToolViewGtk : public ui::AnimationDelegate { |
| 175 public: | 170 public: |
| 176 explicit PageToolViewGtk(const LocationBarViewGtk* parent); | 171 explicit PageToolViewGtk(const LocationBarViewGtk* parent); |
| 177 virtual ~PageToolViewGtk(); | 172 virtual ~PageToolViewGtk(); |
| 178 | 173 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 CHROMEGTK_CALLBACK_1(LocationBarViewGtk, void, OnIconDragEnd, | 361 CHROMEGTK_CALLBACK_1(LocationBarViewGtk, void, OnIconDragEnd, |
| 367 GdkDragContext*); | 362 GdkDragContext*); |
| 368 CHROMEGTK_CALLBACK_1(LocationBarViewGtk, void, OnHboxSizeAllocate, | 363 CHROMEGTK_CALLBACK_1(LocationBarViewGtk, void, OnHboxSizeAllocate, |
| 369 GtkAllocation*); | 364 GtkAllocation*); |
| 370 CHROMEGTK_CALLBACK_1(LocationBarViewGtk, void, OnEntryBoxSizeAllocate, | 365 CHROMEGTK_CALLBACK_1(LocationBarViewGtk, void, OnEntryBoxSizeAllocate, |
| 371 GtkAllocation*); | 366 GtkAllocation*); |
| 372 CHROMEGTK_CALLBACK_1(LocationBarViewGtk, gboolean, OnZoomButtonPress, | 367 CHROMEGTK_CALLBACK_1(LocationBarViewGtk, gboolean, OnZoomButtonPress, |
| 373 GdkEventButton*); | 368 GdkEventButton*); |
| 374 CHROMEGTK_CALLBACK_1(LocationBarViewGtk, gboolean, OnStarButtonPress, | 369 CHROMEGTK_CALLBACK_1(LocationBarViewGtk, gboolean, OnStarButtonPress, |
| 375 GdkEventButton*); | 370 GdkEventButton*); |
| 376 CHROMEGTK_CALLBACK_1(LocationBarViewGtk, gboolean, | |
| 377 OnChromeToMobileButtonPress, GdkEventButton*); | |
| 378 | 371 |
| 379 // Updates the site type area: changes the icon and shows/hides the EV | 372 // Updates the site type area: changes the icon and shows/hides the EV |
| 380 // certificate information. | 373 // certificate information. |
| 381 void UpdateSiteTypeArea(); | 374 void UpdateSiteTypeArea(); |
| 382 | 375 |
| 383 // Updates the maximum size of the EV certificate label. | 376 // Updates the maximum size of the EV certificate label. |
| 384 void UpdateEVCertificateLabelSize(); | 377 void UpdateEVCertificateLabelSize(); |
| 385 | 378 |
| 386 // Sets the text that should be displayed in the info label and its associated | 379 // Sets the text that should be displayed in the info label and its associated |
| 387 // tooltip text. Call with an empty string if the info label should be | 380 // tooltip text. Call with an empty string if the info label should be |
| 388 // hidden. | 381 // hidden. |
| 389 void SetInfoText(); | 382 void SetInfoText(); |
| 390 | 383 |
| 391 // Set the keyword text for the Search BLAH: keyword box. | 384 // Set the keyword text for the Search BLAH: keyword box. |
| 392 void SetKeywordLabel(const string16& keyword); | 385 void SetKeywordLabel(const string16& keyword); |
| 393 | 386 |
| 394 // Set the keyword text for the "Press tab to search BLAH" hint box. | 387 // Set the keyword text for the "Press tab to search BLAH" hint box. |
| 395 void SetKeywordHintLabel(const string16& keyword); | 388 void SetKeywordHintLabel(const string16& keyword); |
| 396 | 389 |
| 397 void ShowFirstRunBubbleInternal(); | 390 void ShowFirstRunBubbleInternal(); |
| 398 | 391 |
| 399 // Show or hide |tab_to_search_box_| and |tab_to_search_hint_| according to | 392 // Show or hide |tab_to_search_box_| and |tab_to_search_hint_| according to |
| 400 // the value of |show_selected_keyword_|, |show_keyword_hint_|, and the | 393 // the value of |show_selected_keyword_|, |show_keyword_hint_|, and the |
| 401 // available horizontal space in the location bar. | 394 // available horizontal space in the location bar. |
| 402 void AdjustChildrenVisibility(); | 395 void AdjustChildrenVisibility(); |
| 403 | 396 |
| 404 // Build the zoom, star, and Chrome To Mobile icons. | 397 // Build the zoom, and star icons. |
| 405 GtkWidget* CreateIconButton( | 398 GtkWidget* CreateIconButton( |
| 406 GtkWidget** image, | 399 GtkWidget** image, |
| 407 int image_id, | 400 int image_id, |
| 408 ViewID debug_id, | 401 ViewID debug_id, |
| 409 int tooltip_id, | 402 int tooltip_id, |
| 410 gboolean (click_callback)(GtkWidget*, GdkEventButton*, gpointer)); | 403 gboolean (click_callback)(GtkWidget*, GdkEventButton*, gpointer)); |
| 411 void CreateZoomButton(); | 404 void CreateZoomButton(); |
| 412 void CreateStarButton(); | 405 void CreateStarButton(); |
| 413 void CreateChromeToMobileButton(); | |
| 414 | 406 |
| 415 // Update the zoom icon after zoom changes. | 407 // Update the zoom icon after zoom changes. |
| 416 void UpdateZoomIcon(); | 408 void UpdateZoomIcon(); |
| 417 | 409 |
| 418 // Update the star icon after it is toggled or the theme changes. | 410 // Update the star icon after it is toggled or the theme changes. |
| 419 void UpdateStarIcon(); | 411 void UpdateStarIcon(); |
| 420 | 412 |
| 421 // Update the chrome to mobile icon after the theme changes, etc. | |
| 422 void UpdateChromeToMobileIcon(); | |
| 423 | |
| 424 // Returns true if we should only show the URL and none of the extras like | 413 // Returns true if we should only show the URL and none of the extras like |
| 425 // the star button or page actions. | 414 // the star button or page actions. |
| 426 bool ShouldOnlyShowLocation(); | 415 bool ShouldOnlyShowLocation(); |
| 427 | 416 |
| 428 // The outermost widget we want to be hosted. | 417 // The outermost widget we want to be hosted. |
| 429 ui::OwnedWidgetGtk hbox_; | 418 ui::OwnedWidgetGtk hbox_; |
| 430 | 419 |
| 431 // Zoom button. | 420 // Zoom button. |
| 432 ui::OwnedWidgetGtk zoom_; | 421 ui::OwnedWidgetGtk zoom_; |
| 433 GtkWidget* zoom_image_; | 422 GtkWidget* zoom_image_; |
| 434 | 423 |
| 435 // Star button. | 424 // Star button. |
| 436 ui::OwnedWidgetGtk star_; | 425 ui::OwnedWidgetGtk star_; |
| 437 GtkWidget* star_image_; | 426 GtkWidget* star_image_; |
| 438 bool starred_; | 427 bool starred_; |
| 439 | 428 |
| 440 // The Chrome To Mobile button and image. | |
| 441 ui::OwnedWidgetGtk chrome_to_mobile_view_; | |
| 442 GtkWidget* chrome_to_mobile_image_; | |
| 443 | |
| 444 // An icon to the left of the address bar. | 429 // An icon to the left of the address bar. |
| 445 GtkWidget* site_type_alignment_; | 430 GtkWidget* site_type_alignment_; |
| 446 GtkWidget* site_type_event_box_; | 431 GtkWidget* site_type_event_box_; |
| 447 GtkWidget* location_icon_image_; | 432 GtkWidget* location_icon_image_; |
| 448 GtkWidget* drag_icon_; | 433 GtkWidget* drag_icon_; |
| 449 bool enable_location_drag_; | 434 bool enable_location_drag_; |
| 450 // TODO(pkasting): Split this label off and move the rest of the items to the | 435 // TODO(pkasting): Split this label off and move the rest of the items to the |
| 451 // left of the address bar. | 436 // left of the address bar. |
| 452 GtkWidget* security_info_label_; | 437 GtkWidget* security_info_label_; |
| 453 | 438 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 BooleanPrefMember edit_bookmarks_enabled_; | 521 BooleanPrefMember edit_bookmarks_enabled_; |
| 537 | 522 |
| 538 // Used to remember the URL and title text when drag&drop has begun. | 523 // Used to remember the URL and title text when drag&drop has begun. |
| 539 GURL drag_url_; | 524 GURL drag_url_; |
| 540 string16 drag_title_; | 525 string16 drag_title_; |
| 541 | 526 |
| 542 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); | 527 DISALLOW_COPY_AND_ASSIGN(LocationBarViewGtk); |
| 543 }; | 528 }; |
| 544 | 529 |
| 545 #endif // CHROME_BROWSER_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ | 530 #endif // CHROME_BROWSER_UI_GTK_LOCATION_BAR_VIEW_GTK_H_ |
| OLD | NEW |