| 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 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 const int kFirstRunBubbleLeftSpacing = 4; | 115 const int kFirstRunBubbleLeftSpacing = 4; |
| 116 | 116 |
| 117 // The padding around the top, bottom, and sides of the location bar hbox. | 117 // The padding around the top, bottom, and sides of the location bar hbox. |
| 118 // We don't want to edit control's text to be right against the edge, | 118 // We don't want to edit control's text to be right against the edge, |
| 119 // as well the tab to search box and other widgets need to have the padding on | 119 // as well the tab to search box and other widgets need to have the padding on |
| 120 // top and bottom to avoid drawing larger than the location bar space. | 120 // top and bottom to avoid drawing larger than the location bar space. |
| 121 const int kHboxBorder = 2; | 121 const int kHboxBorder = 2; |
| 122 | 122 |
| 123 // Padding between the elements in the bar. | 123 // Padding between the elements in the bar. |
| 124 const int kInnerPadding = 2; | 124 const int kInnerPadding = 2; |
| 125 | 125 const int kScriptBadgeInnerPadding = 9; |
| 126 // Padding between the right of the star and the edge of the URL entry. | |
| 127 const int kStarRightPadding = 2; | |
| 128 | 126 |
| 129 // Colors used to draw the EV certificate rounded bubble. | 127 // Colors used to draw the EV certificate rounded bubble. |
| 130 const GdkColor kEvSecureTextColor = GDK_COLOR_RGB(0x07, 0x95, 0x00); | 128 const GdkColor kEvSecureTextColor = GDK_COLOR_RGB(0x07, 0x95, 0x00); |
| 131 const GdkColor kEvSecureBackgroundColor = GDK_COLOR_RGB(0xef, 0xfc, 0xef); | 129 const GdkColor kEvSecureBackgroundColor = GDK_COLOR_RGB(0xef, 0xfc, 0xef); |
| 132 const GdkColor kEvSecureBorderColor = GDK_COLOR_RGB(0x90, 0xc3, 0x90); | 130 const GdkColor kEvSecureBorderColor = GDK_COLOR_RGB(0x90, 0xc3, 0x90); |
| 133 | 131 |
| 134 // Colors used to draw the Tab to Search rounded bubble. | 132 // Colors used to draw the Tab to Search rounded bubble. |
| 135 const GdkColor kKeywordBackgroundColor = GDK_COLOR_RGB(0xf0, 0xf4, 0xfa); | 133 const GdkColor kKeywordBackgroundColor = GDK_COLOR_RGB(0xf0, 0xf4, 0xfa); |
| 136 const GdkColor kKeywordBorderColor = GDK_COLOR_RGB(0xcb, 0xde, 0xf7); | 134 const GdkColor kKeywordBorderColor = GDK_COLOR_RGB(0xcb, 0xde, 0xf7); |
| 137 | 135 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 157 const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66); | 155 const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66); |
| 158 // Colors for the background gradient. | 156 // Colors for the background gradient. |
| 159 const GdkColor kContentSettingTopColor = GDK_COLOR_RGB(0xff, 0xf8, 0xd4); | 157 const GdkColor kContentSettingTopColor = GDK_COLOR_RGB(0xff, 0xf8, 0xd4); |
| 160 const GdkColor kContentSettingBottomColor = GDK_COLOR_RGB(0xff, 0xe6, 0xaf); | 158 const GdkColor kContentSettingBottomColor = GDK_COLOR_RGB(0xff, 0xe6, 0xaf); |
| 161 | 159 |
| 162 // Styling for gray button. | 160 // Styling for gray button. |
| 163 const GdkColor kGrayBorderColor = GDK_COLOR_RGB(0xa0, 0xa0, 0xa0); | 161 const GdkColor kGrayBorderColor = GDK_COLOR_RGB(0xa0, 0xa0, 0xa0); |
| 164 const GdkColor kTopColorGray = GDK_COLOR_RGB(0xe5, 0xe5, 0xe5); | 162 const GdkColor kTopColorGray = GDK_COLOR_RGB(0xe5, 0xe5, 0xe5); |
| 165 const GdkColor kBottomColorGray = GDK_COLOR_RGB(0xd0, 0xd0, 0xd0); | 163 const GdkColor kBottomColorGray = GDK_COLOR_RGB(0xd0, 0xd0, 0xd0); |
| 166 | 164 |
| 165 inline int InnerPadding() { |
| 166 return extensions::switch_utils::AreScriptBadgesEnabled() ? |
| 167 kScriptBadgeInnerPadding : kInnerPadding; |
| 168 } |
| 169 |
| 167 // If widget is visible, increment the int pointed to by count. | 170 // If widget is visible, increment the int pointed to by count. |
| 168 // Suitible for use with gtk_container_foreach. | 171 // Suitible for use with gtk_container_foreach. |
| 169 void CountVisibleWidgets(GtkWidget* widget, gpointer count) { | 172 void CountVisibleWidgets(GtkWidget* widget, gpointer count) { |
| 170 if (gtk_widget_get_visible(widget)) | 173 if (gtk_widget_get_visible(widget)) |
| 171 *static_cast<int*>(count) += 1; | 174 *static_cast<int*>(count) += 1; |
| 172 } | 175 } |
| 173 | 176 |
| 174 class ContentSettingImageViewGtk : public LocationBarViewGtk::PageToolViewGtk, | 177 class ContentSettingImageViewGtk : public LocationBarViewGtk::PageToolViewGtk, |
| 175 public BubbleDelegateGtk { | 178 public BubbleDelegateGtk { |
| 176 public: | 179 public: |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 web_intents_hbox_.Destroy(); | 435 web_intents_hbox_.Destroy(); |
| 433 } | 436 } |
| 434 | 437 |
| 435 void LocationBarViewGtk::Init(bool popup_window_mode) { | 438 void LocationBarViewGtk::Init(bool popup_window_mode) { |
| 436 popup_window_mode_ = popup_window_mode; | 439 popup_window_mode_ = popup_window_mode; |
| 437 | 440 |
| 438 Profile* profile = browser_->profile(); | 441 Profile* profile = browser_->profile(); |
| 439 theme_service_ = GtkThemeService::GetFrom(profile); | 442 theme_service_ = GtkThemeService::GetFrom(profile); |
| 440 | 443 |
| 441 // Create the widget first, so we can pass it to the OmniboxViewGtk. | 444 // Create the widget first, so we can pass it to the OmniboxViewGtk. |
| 442 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 445 hbox_.Own(gtk_hbox_new(FALSE, InnerPadding())); |
| 443 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); | 446 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); |
| 444 // We will paint for the alignment, to paint the background and border. | 447 // We will paint for the alignment, to paint the background and border. |
| 445 gtk_widget_set_app_paintable(hbox_.get(), TRUE); | 448 gtk_widget_set_app_paintable(hbox_.get(), TRUE); |
| 446 // Redraw the whole location bar when it changes size (e.g., when toggling | 449 // Redraw the whole location bar when it changes size (e.g., when toggling |
| 447 // the home button on/off. | 450 // the home button on/off. |
| 448 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); | 451 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); |
| 449 | 452 |
| 450 // Now initialize the OmniboxViewGtk. | 453 // Now initialize the OmniboxViewGtk. |
| 451 location_entry_.reset(new OmniboxViewGtk(this, toolbar_model_, browser_, | 454 location_entry_.reset(new OmniboxViewGtk(this, toolbar_model_, browser_, |
| 452 command_updater_, popup_window_mode_, hbox_.get())); | 455 command_updater_, popup_window_mode_, hbox_.get())); |
| 453 location_entry_->Init(); | 456 location_entry_->Init(); |
| 454 | 457 |
| 455 g_signal_connect(hbox_.get(), "expose-event", | 458 g_signal_connect(hbox_.get(), "expose-event", |
| 456 G_CALLBACK(&HandleExposeThunk), this); | 459 G_CALLBACK(&HandleExposeThunk), this); |
| 457 | 460 |
| 458 BuildSiteTypeArea(); | 461 BuildSiteTypeArea(); |
| 459 | 462 |
| 460 // Put |tab_to_search_box_|, |location_entry_|, and |tab_to_search_hint_| into | 463 // Put |tab_to_search_box_|, |location_entry_|, and |tab_to_search_hint_| into |
| 461 // a sub hbox, so that we can make this part horizontally shrinkable without | 464 // a sub hbox, so that we can make this part horizontally shrinkable without |
| 462 // affecting other elements in the location bar. | 465 // affecting other elements in the location bar. |
| 463 entry_box_ = gtk_hbox_new(FALSE, kInnerPadding); | 466 entry_box_ = gtk_hbox_new(FALSE, InnerPadding()); |
| 464 gtk_widget_show(entry_box_); | 467 gtk_widget_show(entry_box_); |
| 465 gtk_widget_set_size_request(entry_box_, 0, -1); | 468 gtk_widget_set_size_request(entry_box_, 0, -1); |
| 466 gtk_box_pack_start(GTK_BOX(hbox_.get()), entry_box_, TRUE, TRUE, 0); | 469 gtk_box_pack_start(GTK_BOX(hbox_.get()), entry_box_, TRUE, TRUE, 0); |
| 467 | 470 |
| 468 // We need to adjust the visibility of the search hint widgets according to | 471 // We need to adjust the visibility of the search hint widgets according to |
| 469 // the horizontal space in the |entry_box_|. | 472 // the horizontal space in the |entry_box_|. |
| 470 g_signal_connect(entry_box_, "size-allocate", | 473 g_signal_connect(entry_box_, "size-allocate", |
| 471 G_CALLBACK(&OnEntryBoxSizeAllocateThunk), this); | 474 G_CALLBACK(&OnEntryBoxSizeAllocateThunk), this); |
| 472 | 475 |
| 473 // Tab to search (the keyword box on the left hand side). | 476 // Tab to search (the keyword box on the left hand side). |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 if (extensions::switch_utils::IsActionBoxEnabled()) { | 549 if (extensions::switch_utils::IsActionBoxEnabled()) { |
| 547 // TODO(mpcomplete): should we hide this if ShouldOnlyShowLocation()==true? | 550 // TODO(mpcomplete): should we hide this if ShouldOnlyShowLocation()==true? |
| 548 action_box_button_.reset(new ActionBoxButtonGtk(browser_)); | 551 action_box_button_.reset(new ActionBoxButtonGtk(browser_)); |
| 549 | 552 |
| 550 // TODO(mpcomplete): Figure out why CustomDrawButton is offset 3 pixels. | 553 // TODO(mpcomplete): Figure out why CustomDrawButton is offset 3 pixels. |
| 551 // This offset corrects the strange offset of CustomDrawButton. | 554 // This offset corrects the strange offset of CustomDrawButton. |
| 552 const int kMagicActionBoxYOffset = 3; | 555 const int kMagicActionBoxYOffset = 3; |
| 553 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); | 556 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); |
| 554 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), | 557 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), |
| 555 0, kMagicActionBoxYOffset, | 558 0, kMagicActionBoxYOffset, |
| 556 0, kInnerPadding); | 559 0, InnerPadding()); |
| 557 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget()); | 560 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget()); |
| 558 | 561 |
| 559 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment, | 562 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment, |
| 560 FALSE, FALSE, 0); | 563 FALSE, FALSE, 0); |
| 561 } | 564 } |
| 562 | 565 |
| 563 if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { | 566 if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { |
| 564 // Hide the star icon in popups, app windows, etc. | 567 // Hide the star icon in popups, app windows, etc. |
| 565 CreateStarButton(); | 568 CreateStarButton(); |
| 566 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); | 569 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); |
| 567 } | 570 } |
| 568 | 571 |
| 569 CreateZoomButton(); | 572 CreateZoomButton(); |
| 570 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); | 573 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); |
| 571 | 574 |
| 572 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1)); | 575 content_setting_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding() + 1)); |
| 573 gtk_widget_set_name(content_setting_hbox_.get(), | 576 gtk_widget_set_name(content_setting_hbox_.get(), |
| 574 "chrome-content-setting-hbox"); | 577 "chrome-content-setting-hbox"); |
| 575 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), | 578 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), |
| 576 FALSE, FALSE, 1); | 579 FALSE, FALSE, 1); |
| 577 | 580 |
| 578 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 581 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 579 ContentSettingImageViewGtk* content_setting_view = | 582 ContentSettingImageViewGtk* content_setting_view = |
| 580 new ContentSettingImageViewGtk( | 583 new ContentSettingImageViewGtk( |
| 581 static_cast<ContentSettingsType>(i), this); | 584 static_cast<ContentSettingsType>(i), this); |
| 582 content_setting_views_.push_back(content_setting_view); | 585 content_setting_views_.push_back(content_setting_view); |
| 583 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()), | 586 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()), |
| 584 content_setting_view->widget(), FALSE, FALSE, 0); | 587 content_setting_view->widget(), FALSE, FALSE, 0); |
| 585 } | 588 } |
| 586 | 589 |
| 587 page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 590 page_action_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding())); |
| 588 gtk_widget_set_name(page_action_hbox_.get(), | 591 gtk_widget_set_name(page_action_hbox_.get(), |
| 589 "chrome-page-action-hbox"); | 592 "chrome-page-action-hbox"); |
| 590 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), | 593 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), |
| 591 FALSE, FALSE, 0); | 594 FALSE, FALSE, 0); |
| 592 | 595 |
| 593 web_intents_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 596 web_intents_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding())); |
| 594 gtk_widget_set_name(web_intents_hbox_.get(), | 597 gtk_widget_set_name(web_intents_hbox_.get(), |
| 595 "chrome-web-intents-hbox"); | 598 "chrome-web-intents-hbox"); |
| 596 gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(), | 599 gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(), |
| 597 FALSE, FALSE, 0); | 600 FALSE, FALSE, 0); |
| 598 gtk_box_pack_end(GTK_BOX(web_intents_hbox_.get()), | 601 gtk_box_pack_end(GTK_BOX(web_intents_hbox_.get()), |
| 599 web_intents_button_view_->widget(), FALSE, FALSE, 0); | 602 web_intents_button_view_->widget(), FALSE, FALSE, 0); |
| 600 | 603 |
| 601 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s | 604 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s |
| 602 // size-allocate so we can do proper resizing and eliding on | 605 // size-allocate so we can do proper resizing and eliding on |
| 603 // |security_info_label_|. | 606 // |security_info_label_|. |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 ViewID debug_id, | 805 ViewID debug_id, |
| 803 int tooltip_id, | 806 int tooltip_id, |
| 804 gboolean (click_callback)(GtkWidget*, GdkEventButton*, gpointer)) { | 807 gboolean (click_callback)(GtkWidget*, GdkEventButton*, gpointer)) { |
| 805 *image = image_id ? | 808 *image = image_id ? |
| 806 gtk_image_new_from_pixbuf( | 809 gtk_image_new_from_pixbuf( |
| 807 theme_service_->GetImageNamed(image_id)->ToGdkPixbuf()) : | 810 theme_service_->GetImageNamed(image_id)->ToGdkPixbuf()) : |
| 808 gtk_image_new(); | 811 gtk_image_new(); |
| 809 | 812 |
| 810 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); | 813 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); |
| 811 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, | 814 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, |
| 812 0, kInnerPadding); | 815 0, InnerPadding()); |
| 813 gtk_container_add(GTK_CONTAINER(alignment), *image); | 816 gtk_container_add(GTK_CONTAINER(alignment), *image); |
| 814 | 817 |
| 815 GtkWidget* result = gtk_event_box_new(); | 818 GtkWidget* result = gtk_event_box_new(); |
| 816 gtk_event_box_set_visible_window(GTK_EVENT_BOX(result), FALSE); | 819 gtk_event_box_set_visible_window(GTK_EVENT_BOX(result), FALSE); |
| 817 gtk_container_add(GTK_CONTAINER(result), alignment); | 820 gtk_container_add(GTK_CONTAINER(result), alignment); |
| 818 gtk_widget_show_all(result); | 821 gtk_widget_show_all(result); |
| 819 | 822 |
| 820 if (debug_id != VIEW_ID_NONE) | 823 if (debug_id != VIEW_ID_NONE) |
| 821 ViewIDUtil::SetID(result, debug_id); | 824 ViewIDUtil::SetID(result, debug_id); |
| 822 | 825 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 content::NotificationService::NoDetails()); | 985 content::NotificationService::NoDetails()); |
| 983 } | 986 } |
| 984 | 987 |
| 985 if (!page_action_views_.empty() && contents) { | 988 if (!page_action_views_.empty() && contents) { |
| 986 GURL url = chrome::GetActiveWebContents(browser())->GetURL(); | 989 GURL url = chrome::GetActiveWebContents(browser())->GetURL(); |
| 987 | 990 |
| 988 for (size_t i = 0; i < page_action_views_.size(); i++) { | 991 for (size_t i = 0; i < page_action_views_.size(); i++) { |
| 989 page_action_views_[i]->UpdateVisibility( | 992 page_action_views_[i]->UpdateVisibility( |
| 990 toolbar_model_->input_in_progress() ? NULL : contents, url); | 993 toolbar_model_->input_in_progress() ? NULL : contents, url); |
| 991 } | 994 } |
| 995 gtk_widget_queue_draw(hbox_.get()); |
| 992 } | 996 } |
| 993 | 997 |
| 994 // If there are no visible page actions, hide the hbox too, so that it does | 998 // If there are no visible page actions, hide the hbox too, so that it does |
| 995 // not affect the padding in the location bar. | 999 // not affect the padding in the location bar. |
| 996 gtk_widget_set_visible(page_action_hbox_.get(), | 1000 gtk_widget_set_visible(page_action_hbox_.get(), |
| 997 PageActionVisibleCount() && !ShouldOnlyShowLocation()); | 1001 PageActionVisibleCount() && !ShouldOnlyShowLocation()); |
| 998 } | 1002 } |
| 999 | 1003 |
| 1000 void LocationBarViewGtk::InvalidatePageActions() { | 1004 void LocationBarViewGtk::InvalidatePageActions() { |
| 1001 size_t count_before = page_action_views_.size(); | 1005 size_t count_before = page_action_views_.size(); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 left = IDR_LOCATIONBG_L; | 1182 left = IDR_LOCATIONBG_L; |
| 1179 center = IDR_LOCATIONBG_C; | 1183 center = IDR_LOCATIONBG_C; |
| 1180 right = IDR_LOCATIONBG_R; | 1184 right = IDR_LOCATIONBG_R; |
| 1181 } | 1185 } |
| 1182 | 1186 |
| 1183 NineBox background(left, center, right, | 1187 NineBox background(left, center, right, |
| 1184 0, 0, 0, 0, 0, 0); | 1188 0, 0, 0, 0, 0, 0); |
| 1185 background.RenderToWidget(widget); | 1189 background.RenderToWidget(widget); |
| 1186 } | 1190 } |
| 1187 | 1191 |
| 1192 // Draw ExtensionAction backgrounds and borders, if necessary. The borders |
| 1193 // appear exactly between the elements, so they can't draw the borders |
| 1194 // themselves. |
| 1195 gfx::CanvasSkiaPaint canvas(event, /*opaque=*/false); |
| 1196 for (ScopedVector<PageActionViewGtk>::const_iterator |
| 1197 page_action_view = page_action_views_.begin(); |
| 1198 page_action_view != page_action_views_.end(); |
| 1199 ++page_action_view) { |
| 1200 if ((*page_action_view)->IsVisible()) { |
| 1201 // Figure out where the page action is drawn so we can draw |
| 1202 // borders to its left and right. |
| 1203 GtkAllocation allocation; |
| 1204 gtk_widget_get_allocation((*page_action_view)->widget(), &allocation); |
| 1205 ExtensionAction* action = (*page_action_view)->page_action(); |
| 1206 gfx::Rect bounds(allocation); |
| 1207 // Make the bounding rectangle include the whole vertical range of the |
| 1208 // location bar, and the mid-point pixels between adjacent page actions. |
| 1209 // |
| 1210 // For odd InnerPadding()s, "InnerPadding() + 1" includes the mid-point |
| 1211 // between two page actions in the bounding rectangle. For even paddings, |
| 1212 // the +1 is dropped, which is right since there is no pixel at the |
| 1213 // mid-point. |
| 1214 bounds.Inset(-(InnerPadding() + 1) / 2, |
| 1215 theme_service_->UsingNativeTheme() ? -1 : 0); |
| 1216 location_bar_util::PaintExtensionActionBackground( |
| 1217 *action, SessionID::IdForTab(GetWebContents()), |
| 1218 &canvas, bounds, |
| 1219 theme_service_->get_location_bar_text_color(), |
| 1220 theme_service_->get_location_bar_bg_color()); |
| 1221 } |
| 1222 } |
| 1223 // Destroying |canvas| draws the background. |
| 1224 |
| 1188 return FALSE; // Continue propagating the expose. | 1225 return FALSE; // Continue propagating the expose. |
| 1189 } | 1226 } |
| 1190 | 1227 |
| 1191 void LocationBarViewGtk::UpdateSiteTypeArea() { | 1228 void LocationBarViewGtk::UpdateSiteTypeArea() { |
| 1192 // The icon is always visible except when the |tab_to_search_alignment_| is | 1229 // The icon is always visible except when the |tab_to_search_alignment_| is |
| 1193 // visible. | 1230 // visible. |
| 1194 if (!location_entry_->model()->keyword().empty() && | 1231 if (!location_entry_->model()->keyword().empty() && |
| 1195 !location_entry_->model()->is_keyword_hint()) { | 1232 !location_entry_->model()->is_keyword_hint()) { |
| 1196 gtk_widget_hide(site_type_area()); | 1233 gtk_widget_hide(site_type_area()); |
| 1197 return; | 1234 return; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, | 1618 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, |
| 1582 !toolbar_model_->input_in_progress() && service && service->HasMobiles()); | 1619 !toolbar_model_->input_in_progress() && service && service->HasMobiles()); |
| 1583 } | 1620 } |
| 1584 | 1621 |
| 1585 bool LocationBarViewGtk::ShouldOnlyShowLocation() { | 1622 bool LocationBarViewGtk::ShouldOnlyShowLocation() { |
| 1586 return !browser_->is_type_tabbed(); | 1623 return !browser_->is_type_tabbed(); |
| 1587 } | 1624 } |
| 1588 | 1625 |
| 1589 void LocationBarViewGtk::AdjustChildrenVisibility() { | 1626 void LocationBarViewGtk::AdjustChildrenVisibility() { |
| 1590 int text_width = location_entry_->TextWidth(); | 1627 int text_width = location_entry_->TextWidth(); |
| 1591 int available_width = entry_box_width_ - text_width - kInnerPadding; | 1628 int available_width = entry_box_width_ - text_width - InnerPadding(); |
| 1592 | 1629 |
| 1593 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be | 1630 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be |
| 1594 // visible at the same time. | 1631 // visible at the same time. |
| 1595 if (!show_selected_keyword_ && | 1632 if (!show_selected_keyword_ && |
| 1596 gtk_widget_get_visible(tab_to_search_alignment_)) { | 1633 gtk_widget_get_visible(tab_to_search_alignment_)) { |
| 1597 gtk_widget_hide(tab_to_search_alignment_); | 1634 gtk_widget_hide(tab_to_search_alignment_); |
| 1598 } else if (!show_keyword_hint_ && | 1635 } else if (!show_keyword_hint_ && |
| 1599 gtk_widget_get_visible(tab_to_search_hint_)) { | 1636 gtk_widget_get_visible(tab_to_search_hint_)) { |
| 1600 gtk_widget_hide(tab_to_search_hint_); | 1637 gtk_widget_hide(tab_to_search_hint_); |
| 1601 } | 1638 } |
| 1602 | 1639 |
| 1603 if (show_selected_keyword_) { | 1640 if (show_selected_keyword_) { |
| 1604 GtkRequisition box, full_label, partial_label; | 1641 GtkRequisition box, full_label, partial_label; |
| 1605 gtk_widget_size_request(tab_to_search_box_, &box); | 1642 gtk_widget_size_request(tab_to_search_box_, &box); |
| 1606 gtk_widget_size_request(tab_to_search_full_label_, &full_label); | 1643 gtk_widget_size_request(tab_to_search_full_label_, &full_label); |
| 1607 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); | 1644 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); |
| 1608 int full_partial_width_diff = full_label.width - partial_label.width; | 1645 int full_partial_width_diff = full_label.width - partial_label.width; |
| 1609 int full_box_width; | 1646 int full_box_width; |
| 1610 int partial_box_width; | 1647 int partial_box_width; |
| 1611 if (gtk_widget_get_visible(tab_to_search_full_label_)) { | 1648 if (gtk_widget_get_visible(tab_to_search_full_label_)) { |
| 1612 full_box_width = box.width; | 1649 full_box_width = box.width; |
| 1613 partial_box_width = full_box_width - full_partial_width_diff; | 1650 partial_box_width = full_box_width - full_partial_width_diff; |
| 1614 } else { | 1651 } else { |
| 1615 partial_box_width = box.width; | 1652 partial_box_width = box.width; |
| 1616 full_box_width = partial_box_width + full_partial_width_diff; | 1653 full_box_width = partial_box_width + full_partial_width_diff; |
| 1617 } | 1654 } |
| 1618 | 1655 |
| 1619 if (partial_box_width >= entry_box_width_ - kInnerPadding) { | 1656 if (partial_box_width >= entry_box_width_ - InnerPadding()) { |
| 1620 gtk_widget_hide(tab_to_search_alignment_); | 1657 gtk_widget_hide(tab_to_search_alignment_); |
| 1621 } else if (full_box_width >= available_width) { | 1658 } else if (full_box_width >= available_width) { |
| 1622 gtk_widget_hide(tab_to_search_full_label_); | 1659 gtk_widget_hide(tab_to_search_full_label_); |
| 1623 gtk_widget_show(tab_to_search_partial_label_); | 1660 gtk_widget_show(tab_to_search_partial_label_); |
| 1624 gtk_widget_show(tab_to_search_alignment_); | 1661 gtk_widget_show(tab_to_search_alignment_); |
| 1625 } else if (full_box_width < available_width) { | 1662 } else if (full_box_width < available_width) { |
| 1626 gtk_widget_hide(tab_to_search_partial_label_); | 1663 gtk_widget_hide(tab_to_search_partial_label_); |
| 1627 gtk_widget_show(tab_to_search_full_label_); | 1664 gtk_widget_show(tab_to_search_full_label_); |
| 1628 gtk_widget_show(tab_to_search_alignment_); | 1665 gtk_widget_show(tab_to_search_alignment_); |
| 1629 } | 1666 } |
| 1630 } else if (show_keyword_hint_) { | 1667 } else if (show_keyword_hint_) { |
| 1631 GtkRequisition leading, icon, trailing; | 1668 GtkRequisition leading, icon, trailing; |
| 1632 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading); | 1669 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading); |
| 1633 gtk_widget_size_request(tab_to_search_hint_icon_, &icon); | 1670 gtk_widget_size_request(tab_to_search_hint_icon_, &icon); |
| 1634 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing); | 1671 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing); |
| 1635 int full_width = leading.width + icon.width + trailing.width; | 1672 int full_width = leading.width + icon.width + trailing.width; |
| 1636 | 1673 |
| 1637 if (icon.width >= entry_box_width_ - kInnerPadding) { | 1674 if (icon.width >= entry_box_width_ - InnerPadding()) { |
| 1638 gtk_widget_hide(tab_to_search_hint_); | 1675 gtk_widget_hide(tab_to_search_hint_); |
| 1639 } else if (full_width >= available_width) { | 1676 } else if (full_width >= available_width) { |
| 1640 gtk_widget_hide(tab_to_search_hint_leading_label_); | 1677 gtk_widget_hide(tab_to_search_hint_leading_label_); |
| 1641 gtk_widget_hide(tab_to_search_hint_trailing_label_); | 1678 gtk_widget_hide(tab_to_search_hint_trailing_label_); |
| 1642 gtk_widget_show(tab_to_search_hint_); | 1679 gtk_widget_show(tab_to_search_hint_); |
| 1643 } else if (full_width < available_width) { | 1680 } else if (full_width < available_width) { |
| 1644 gtk_widget_show(tab_to_search_hint_leading_label_); | 1681 gtk_widget_show(tab_to_search_hint_leading_label_); |
| 1645 gtk_widget_show(tab_to_search_hint_trailing_label_); | 1682 gtk_widget_show(tab_to_search_hint_trailing_label_); |
| 1646 gtk_widget_show(tab_to_search_hint_); | 1683 gtk_widget_show(tab_to_search_hint_); |
| 1647 } | 1684 } |
| 1648 } | 1685 } |
| 1649 } | 1686 } |
| 1650 | 1687 |
| 1651 //////////////////////////////////////////////////////////////////////////////// | 1688 //////////////////////////////////////////////////////////////////////////////// |
| 1652 // LocationBarViewGtk::PageToolViewGtk | 1689 // LocationBarViewGtk::PageToolViewGtk |
| 1653 | 1690 |
| 1654 LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk( | 1691 LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk( |
| 1655 const LocationBarViewGtk* parent) | 1692 const LocationBarViewGtk* parent) |
| 1656 : alignment_(gtk_alignment_new(0, 0, 1, 1)), | 1693 : alignment_(gtk_alignment_new(0, 0, 1, 1)), |
| 1657 event_box_(gtk_event_box_new()), | 1694 event_box_(gtk_event_box_new()), |
| 1658 hbox_(gtk_hbox_new(FALSE, kInnerPadding)), | 1695 hbox_(gtk_hbox_new(FALSE, InnerPadding())), |
| 1659 image_(gtk_image_new()), | 1696 image_(gtk_image_new()), |
| 1660 label_(gtk_label_new(NULL)), | 1697 label_(gtk_label_new(NULL)), |
| 1661 parent_(parent), | 1698 parent_(parent), |
| 1662 animation_(this), | 1699 animation_(this), |
| 1663 weak_factory_(this) { | 1700 weak_factory_(this) { |
| 1664 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0); | 1701 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0); |
| 1665 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get()); | 1702 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get()); |
| 1666 | 1703 |
| 1667 // Make the event box not visible so it does not paint a background. | 1704 // Make the event box not visible so it does not paint a background. |
| 1668 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); | 1705 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2090 } | 2127 } |
| 2091 | 2128 |
| 2092 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 2129 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
| 2093 ExtensionAction* action) { | 2130 ExtensionAction* action) { |
| 2094 ExtensionPopupGtk::Show( | 2131 ExtensionPopupGtk::Show( |
| 2095 action->GetPopupUrl(current_tab_id_), | 2132 action->GetPopupUrl(current_tab_id_), |
| 2096 owner_->browser_, | 2133 owner_->browser_, |
| 2097 event_box_.get(), | 2134 event_box_.get(), |
| 2098 ExtensionPopupGtk::SHOW_AND_INSPECT); | 2135 ExtensionPopupGtk::SHOW_AND_INSPECT); |
| 2099 } | 2136 } |
| OLD | NEW |