Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/browser/ui/gtk/location_bar_view_gtk.cc

Issue 10834279: Give request-to-act badges a grey background, and increase spacing to make it fit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final (??) Windows and GTK support Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 10 matching lines...) Expand all
21 #include "chrome/app/chrome_command_ids.h" 21 #include "chrome/app/chrome_command_ids.h"
22 #include "chrome/browser/accessibility/accessibility_events.h" 22 #include "chrome/browser/accessibility/accessibility_events.h"
23 #include "chrome/browser/alternate_nav_url_fetcher.h" 23 #include "chrome/browser/alternate_nav_url_fetcher.h"
24 #include "chrome/browser/chrome_to_mobile_service.h" 24 #include "chrome/browser/chrome_to_mobile_service.h"
25 #include "chrome/browser/chrome_to_mobile_service_factory.h" 25 #include "chrome/browser/chrome_to_mobile_service_factory.h"
26 #include "chrome/browser/command_updater.h" 26 #include "chrome/browser/command_updater.h"
27 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 27 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
28 #include "chrome/browser/defaults.h" 28 #include "chrome/browser/defaults.h"
29 #include "chrome/browser/extensions/api/commands/command_service.h" 29 #include "chrome/browser/extensions/api/commands/command_service.h"
30 #include "chrome/browser/extensions/api/commands/command_service_factory.h" 30 #include "chrome/browser/extensions/api/commands/command_service_factory.h"
31 #include "chrome/browser/extensions/extension_action_util.h"
31 #include "chrome/browser/extensions/extension_service.h" 32 #include "chrome/browser/extensions/extension_service.h"
32 #include "chrome/browser/extensions/extension_tab_util.h" 33 #include "chrome/browser/extensions/extension_tab_util.h"
33 #include "chrome/browser/extensions/location_bar_controller.h" 34 #include "chrome/browser/extensions/location_bar_controller.h"
34 #include "chrome/browser/extensions/tab_helper.h" 35 #include "chrome/browser/extensions/tab_helper.h"
35 #include "chrome/browser/favicon/favicon_tab_helper.h" 36 #include "chrome/browser/favicon/favicon_tab_helper.h"
36 #include "chrome/browser/prefs/pref_service.h" 37 #include "chrome/browser/prefs/pref_service.h"
37 #include "chrome/browser/profiles/profile.h" 38 #include "chrome/browser/profiles/profile.h"
38 #include "chrome/browser/search_engines/template_url.h" 39 #include "chrome/browser/search_engines/template_url.h"
39 #include "chrome/browser/search_engines/template_url_service.h" 40 #include "chrome/browser/search_engines/template_url_service.h"
40 #include "chrome/browser/search_engines/template_url_service_factory.h" 41 #include "chrome/browser/search_engines/template_url_service_factory.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const int kFirstRunBubbleLeftSpacing = 4; 116 const int kFirstRunBubbleLeftSpacing = 4;
116 117
117 // The padding around the top, bottom, and sides of the location bar hbox. 118 // 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, 119 // 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 120 // 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. 121 // top and bottom to avoid drawing larger than the location bar space.
121 const int kHboxBorder = 2; 122 const int kHboxBorder = 2;
122 123
123 // Padding between the elements in the bar. 124 // Padding between the elements in the bar.
124 const int kInnerPadding = 2; 125 const int kInnerPadding = 2;
125 126 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 127
129 // Colors used to draw the EV certificate rounded bubble. 128 // Colors used to draw the EV certificate rounded bubble.
130 const GdkColor kEvSecureTextColor = GDK_COLOR_RGB(0x07, 0x95, 0x00); 129 const GdkColor kEvSecureTextColor = GDK_COLOR_RGB(0x07, 0x95, 0x00);
131 const GdkColor kEvSecureBackgroundColor = GDK_COLOR_RGB(0xef, 0xfc, 0xef); 130 const GdkColor kEvSecureBackgroundColor = GDK_COLOR_RGB(0xef, 0xfc, 0xef);
132 const GdkColor kEvSecureBorderColor = GDK_COLOR_RGB(0x90, 0xc3, 0x90); 131 const GdkColor kEvSecureBorderColor = GDK_COLOR_RGB(0x90, 0xc3, 0x90);
133 132
134 // Colors used to draw the Tab to Search rounded bubble. 133 // Colors used to draw the Tab to Search rounded bubble.
135 const GdkColor kKeywordBackgroundColor = GDK_COLOR_RGB(0xf0, 0xf4, 0xfa); 134 const GdkColor kKeywordBackgroundColor = GDK_COLOR_RGB(0xf0, 0xf4, 0xfa);
136 const GdkColor kKeywordBorderColor = GDK_COLOR_RGB(0xcb, 0xde, 0xf7); 135 const GdkColor kKeywordBorderColor = GDK_COLOR_RGB(0xcb, 0xde, 0xf7);
137 136
(...skipping 19 matching lines...) Expand all
157 const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66); 156 const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66);
158 // Colors for the background gradient. 157 // Colors for the background gradient.
159 const GdkColor kContentSettingTopColor = GDK_COLOR_RGB(0xff, 0xf8, 0xd4); 158 const GdkColor kContentSettingTopColor = GDK_COLOR_RGB(0xff, 0xf8, 0xd4);
160 const GdkColor kContentSettingBottomColor = GDK_COLOR_RGB(0xff, 0xe6, 0xaf); 159 const GdkColor kContentSettingBottomColor = GDK_COLOR_RGB(0xff, 0xe6, 0xaf);
161 160
162 // Styling for gray button. 161 // Styling for gray button.
163 const GdkColor kGrayBorderColor = GDK_COLOR_RGB(0xa0, 0xa0, 0xa0); 162 const GdkColor kGrayBorderColor = GDK_COLOR_RGB(0xa0, 0xa0, 0xa0);
164 const GdkColor kTopColorGray = GDK_COLOR_RGB(0xe5, 0xe5, 0xe5); 163 const GdkColor kTopColorGray = GDK_COLOR_RGB(0xe5, 0xe5, 0xe5);
165 const GdkColor kBottomColorGray = GDK_COLOR_RGB(0xd0, 0xd0, 0xd0); 164 const GdkColor kBottomColorGray = GDK_COLOR_RGB(0xd0, 0xd0, 0xd0);
166 165
166 inline int InnerPadding() {
167 return extensions::switch_utils::AreScriptBadgesEnabled() ?
168 kScriptBadgeInnerPadding : kInnerPadding;
169 }
170
167 // If widget is visible, increment the int pointed to by count. 171 // If widget is visible, increment the int pointed to by count.
168 // Suitible for use with gtk_container_foreach. 172 // Suitible for use with gtk_container_foreach.
169 void CountVisibleWidgets(GtkWidget* widget, gpointer count) { 173 void CountVisibleWidgets(GtkWidget* widget, gpointer count) {
170 if (gtk_widget_get_visible(widget)) 174 if (gtk_widget_get_visible(widget))
171 *static_cast<int*>(count) += 1; 175 *static_cast<int*>(count) += 1;
172 } 176 }
173 177
174 class ContentSettingImageViewGtk : public LocationBarViewGtk::PageToolViewGtk, 178 class ContentSettingImageViewGtk : public LocationBarViewGtk::PageToolViewGtk,
175 public BubbleDelegateGtk { 179 public BubbleDelegateGtk {
176 public: 180 public:
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 web_intents_hbox_.Destroy(); 436 web_intents_hbox_.Destroy();
433 } 437 }
434 438
435 void LocationBarViewGtk::Init(bool popup_window_mode) { 439 void LocationBarViewGtk::Init(bool popup_window_mode) {
436 popup_window_mode_ = popup_window_mode; 440 popup_window_mode_ = popup_window_mode;
437 441
438 Profile* profile = browser_->profile(); 442 Profile* profile = browser_->profile();
439 theme_service_ = GtkThemeService::GetFrom(profile); 443 theme_service_ = GtkThemeService::GetFrom(profile);
440 444
441 // Create the widget first, so we can pass it to the OmniboxViewGtk. 445 // Create the widget first, so we can pass it to the OmniboxViewGtk.
442 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); 446 hbox_.Own(gtk_hbox_new(FALSE, InnerPadding()));
443 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); 447 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder);
444 // We will paint for the alignment, to paint the background and border. 448 // We will paint for the alignment, to paint the background and border.
445 gtk_widget_set_app_paintable(hbox_.get(), TRUE); 449 gtk_widget_set_app_paintable(hbox_.get(), TRUE);
446 // Redraw the whole location bar when it changes size (e.g., when toggling 450 // Redraw the whole location bar when it changes size (e.g., when toggling
447 // the home button on/off. 451 // the home button on/off.
448 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); 452 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE);
449 453
450 // Now initialize the OmniboxViewGtk. 454 // Now initialize the OmniboxViewGtk.
451 location_entry_.reset(new OmniboxViewGtk(this, toolbar_model_, browser_, 455 location_entry_.reset(new OmniboxViewGtk(this, toolbar_model_, browser_,
452 command_updater_, popup_window_mode_, hbox_.get())); 456 command_updater_, popup_window_mode_, hbox_.get()));
453 location_entry_->Init(); 457 location_entry_->Init();
454 458
455 g_signal_connect(hbox_.get(), "expose-event", 459 g_signal_connect(hbox_.get(), "expose-event",
456 G_CALLBACK(&HandleExposeThunk), this); 460 G_CALLBACK(&HandleExposeThunk), this);
457 461
458 BuildSiteTypeArea(); 462 BuildSiteTypeArea();
459 463
460 // Put |tab_to_search_box_|, |location_entry_|, and |tab_to_search_hint_| into 464 // 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 465 // a sub hbox, so that we can make this part horizontally shrinkable without
462 // affecting other elements in the location bar. 466 // affecting other elements in the location bar.
463 entry_box_ = gtk_hbox_new(FALSE, kInnerPadding); 467 entry_box_ = gtk_hbox_new(FALSE, InnerPadding());
464 gtk_widget_show(entry_box_); 468 gtk_widget_show(entry_box_);
465 gtk_widget_set_size_request(entry_box_, 0, -1); 469 gtk_widget_set_size_request(entry_box_, 0, -1);
466 gtk_box_pack_start(GTK_BOX(hbox_.get()), entry_box_, TRUE, TRUE, 0); 470 gtk_box_pack_start(GTK_BOX(hbox_.get()), entry_box_, TRUE, TRUE, 0);
467 471
468 // We need to adjust the visibility of the search hint widgets according to 472 // We need to adjust the visibility of the search hint widgets according to
469 // the horizontal space in the |entry_box_|. 473 // the horizontal space in the |entry_box_|.
470 g_signal_connect(entry_box_, "size-allocate", 474 g_signal_connect(entry_box_, "size-allocate",
471 G_CALLBACK(&OnEntryBoxSizeAllocateThunk), this); 475 G_CALLBACK(&OnEntryBoxSizeAllocateThunk), this);
472 476
473 // Tab to search (the keyword box on the left hand side). 477 // Tab to search (the keyword box on the left hand side).
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableActionBox)) { 550 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableActionBox)) {
547 // TODO(mpcomplete): should we hide this if ShouldOnlyShowLocation()==true? 551 // TODO(mpcomplete): should we hide this if ShouldOnlyShowLocation()==true?
548 action_box_button_.reset(new ActionBoxButtonGtk(browser_)); 552 action_box_button_.reset(new ActionBoxButtonGtk(browser_));
549 553
550 // TODO(mpcomplete): Figure out why CustomDrawButton is offset 3 pixels. 554 // TODO(mpcomplete): Figure out why CustomDrawButton is offset 3 pixels.
551 // This offset corrects the strange offset of CustomDrawButton. 555 // This offset corrects the strange offset of CustomDrawButton.
552 const int kMagicActionBoxYOffset = 3; 556 const int kMagicActionBoxYOffset = 3;
553 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); 557 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
554 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 558 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
555 0, kMagicActionBoxYOffset, 559 0, kMagicActionBoxYOffset,
556 0, kInnerPadding); 560 0, InnerPadding());
557 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget()); 561 gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget());
558 562
559 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment, 563 gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment,
560 FALSE, FALSE, 0); 564 FALSE, FALSE, 0);
561 } 565 }
562 566
563 if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) { 567 if (browser_defaults::bookmarks_enabled && !ShouldOnlyShowLocation()) {
564 // Hide the star icon in popups, app windows, etc. 568 // Hide the star icon in popups, app windows, etc.
565 CreateStarButton(); 569 CreateStarButton();
566 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0); 570 gtk_box_pack_end(GTK_BOX(hbox_.get()), star_.get(), FALSE, FALSE, 0);
567 } 571 }
568 572
569 CreateZoomButton(); 573 CreateZoomButton();
570 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0); 574 gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0);
571 575
572 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1)); 576 content_setting_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding() + 1));
573 gtk_widget_set_name(content_setting_hbox_.get(), 577 gtk_widget_set_name(content_setting_hbox_.get(),
574 "chrome-content-setting-hbox"); 578 "chrome-content-setting-hbox");
575 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), 579 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(),
576 FALSE, FALSE, 1); 580 FALSE, FALSE, 1);
577 581
578 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 582 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
579 ContentSettingImageViewGtk* content_setting_view = 583 ContentSettingImageViewGtk* content_setting_view =
580 new ContentSettingImageViewGtk( 584 new ContentSettingImageViewGtk(
581 static_cast<ContentSettingsType>(i), this); 585 static_cast<ContentSettingsType>(i), this);
582 content_setting_views_.push_back(content_setting_view); 586 content_setting_views_.push_back(content_setting_view);
583 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()), 587 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()),
584 content_setting_view->widget(), FALSE, FALSE, 0); 588 content_setting_view->widget(), FALSE, FALSE, 0);
585 } 589 }
586 590
587 page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); 591 page_action_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding()));
588 gtk_widget_set_name(page_action_hbox_.get(), 592 gtk_widget_set_name(page_action_hbox_.get(),
589 "chrome-page-action-hbox"); 593 "chrome-page-action-hbox");
590 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), 594 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(),
591 FALSE, FALSE, 0); 595 FALSE, FALSE, 0);
592 596
593 web_intents_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); 597 web_intents_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding()));
594 gtk_widget_set_name(web_intents_hbox_.get(), 598 gtk_widget_set_name(web_intents_hbox_.get(),
595 "chrome-web-intents-hbox"); 599 "chrome-web-intents-hbox");
596 gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(), 600 gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(),
597 FALSE, FALSE, 0); 601 FALSE, FALSE, 0);
598 gtk_box_pack_end(GTK_BOX(web_intents_hbox_.get()), 602 gtk_box_pack_end(GTK_BOX(web_intents_hbox_.get()),
599 web_intents_button_view_->widget(), FALSE, FALSE, 0); 603 web_intents_button_view_->widget(), FALSE, FALSE, 0);
600 604
601 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s 605 // 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 606 // size-allocate so we can do proper resizing and eliding on
603 // |security_info_label_|. 607 // |security_info_label_|.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 ViewID debug_id, 805 ViewID debug_id,
802 int tooltip_id, 806 int tooltip_id,
803 gboolean (click_callback)(GtkWidget*, GdkEventButton*, gpointer)) { 807 gboolean (click_callback)(GtkWidget*, GdkEventButton*, gpointer)) {
804 *image = image_id ? 808 *image = image_id ?
805 gtk_image_new_from_pixbuf( 809 gtk_image_new_from_pixbuf(
806 theme_service_->GetImageNamed(image_id)->ToGdkPixbuf()) : 810 theme_service_->GetImageNamed(image_id)->ToGdkPixbuf()) :
807 gtk_image_new(); 811 gtk_image_new();
808 812
809 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); 813 GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
810 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, 814 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0,
811 0, kInnerPadding); 815 0, InnerPadding());
812 gtk_container_add(GTK_CONTAINER(alignment), *image); 816 gtk_container_add(GTK_CONTAINER(alignment), *image);
813 817
814 GtkWidget* result = gtk_event_box_new(); 818 GtkWidget* result = gtk_event_box_new();
815 gtk_event_box_set_visible_window(GTK_EVENT_BOX(result), FALSE); 819 gtk_event_box_set_visible_window(GTK_EVENT_BOX(result), FALSE);
816 gtk_container_add(GTK_CONTAINER(result), alignment); 820 gtk_container_add(GTK_CONTAINER(result), alignment);
817 gtk_widget_show_all(result); 821 gtk_widget_show_all(result);
818 822
819 if (debug_id != VIEW_ID_NONE) 823 if (debug_id != VIEW_ID_NONE)
820 ViewIDUtil::SetID(result, debug_id); 824 ViewIDUtil::SetID(result, debug_id);
821 825
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 } 985 }
982 986
983 WebContents* contents = GetWebContents(); 987 WebContents* contents = GetWebContents();
984 if (!page_action_views_.empty() && contents) { 988 if (!page_action_views_.empty() && contents) {
985 GURL url = chrome::GetActiveWebContents(browser())->GetURL(); 989 GURL url = chrome::GetActiveWebContents(browser())->GetURL();
986 990
987 for (size_t i = 0; i < page_action_views_.size(); i++) { 991 for (size_t i = 0; i < page_action_views_.size(); i++) {
988 page_action_views_[i]->UpdateVisibility( 992 page_action_views_[i]->UpdateVisibility(
989 toolbar_model_->input_in_progress() ? NULL : contents, url); 993 toolbar_model_->input_in_progress() ? NULL : contents, url);
990 } 994 }
995 gtk_widget_queue_draw(hbox_.get());
991 } 996 }
992 997
993 // 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
994 // not affect the padding in the location bar. 999 // not affect the padding in the location bar.
995 gtk_widget_set_visible(page_action_hbox_.get(), 1000 gtk_widget_set_visible(page_action_hbox_.get(),
996 PageActionVisibleCount() && !ShouldOnlyShowLocation()); 1001 PageActionVisibleCount() && !ShouldOnlyShowLocation());
997 } 1002 }
998 1003
999 void LocationBarViewGtk::InvalidatePageActions() { 1004 void LocationBarViewGtk::InvalidatePageActions() {
1000 size_t count_before = page_action_views_.size(); 1005 size_t count_before = page_action_views_.size();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 left = IDR_LOCATIONBG_L; 1179 left = IDR_LOCATIONBG_L;
1175 center = IDR_LOCATIONBG_C; 1180 center = IDR_LOCATIONBG_C;
1176 right = IDR_LOCATIONBG_R; 1181 right = IDR_LOCATIONBG_R;
1177 } 1182 }
1178 1183
1179 NineBox background(left, center, right, 1184 NineBox background(left, center, right,
1180 0, 0, 0, 0, 0, 0); 1185 0, 0, 0, 0, 0, 0);
1181 background.RenderToWidget(widget); 1186 background.RenderToWidget(widget);
1182 } 1187 }
1183 1188
1189 // Draw ExtensionAction backgrounds and borders, if necessary. The borders
1190 // appear exactly between the elements, so they can't draw the borders
1191 // themselves.
1192 gfx::CanvasSkiaPaint canvas(event, /*opaque=*/false);
1193 for (ScopedVector<PageActionViewGtk>::const_iterator
1194 page_action_view = page_action_views_.begin();
1195 page_action_view != page_action_views_.end();
1196 ++page_action_view) {
1197 if ((*page_action_view)->IsVisible()) {
1198 // Figure out where the page action is drawn so we can draw
1199 // borders to its left and right.
1200 GtkAllocation allocation;
1201 gtk_widget_get_allocation((*page_action_view)->widget(), &allocation);
1202 ExtensionAction* action = (*page_action_view)->page_action();
1203 gfx::Rect bounds(allocation);
1204 // Make the bounding rectangle include the whole vertical range of the
1205 // location bar, and the mid-point pixels between adjacent page actions.
1206 //
1207 // For odd InnerPadding()s, "InnerPadding() + 1" includes the mid-point
1208 // between two page actions in the bounding rectangle. For even paddings,
1209 // the +1 is dropped, which is right since there is no pixel at the
1210 // mid-point.
1211 bounds.Inset(-(InnerPadding() + 1) / 2,
1212 theme_service_->UsingNativeTheme() ? -1 : 0);
1213 extensions::PaintExtensionActionBackground(
1214 *action, SessionID::IdForTab(GetTabContents()),
1215 &canvas, bounds,
1216 theme_service_->get_location_bar_text_color(),
1217 theme_service_->get_location_bar_bg_color());
1218 }
1219 }
1220
1184 return FALSE; // Continue propagating the expose. 1221 return FALSE; // Continue propagating the expose.
1185 } 1222 }
1186 1223
1187 void LocationBarViewGtk::UpdateSiteTypeArea() { 1224 void LocationBarViewGtk::UpdateSiteTypeArea() {
1188 // The icon is always visible except when the |tab_to_search_alignment_| is 1225 // The icon is always visible except when the |tab_to_search_alignment_| is
1189 // visible. 1226 // visible.
1190 if (!location_entry_->model()->keyword().empty() && 1227 if (!location_entry_->model()->keyword().empty() &&
1191 !location_entry_->model()->is_keyword_hint()) { 1228 !location_entry_->model()->is_keyword_hint()) {
1192 gtk_widget_hide(site_type_area()); 1229 gtk_widget_hide(site_type_area());
1193 return; 1230 return;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 gtk_widget_hide_all(star_.get()); 1610 gtk_widget_hide_all(star_.get());
1574 } 1611 }
1575 } 1612 }
1576 1613
1577 bool LocationBarViewGtk::ShouldOnlyShowLocation() { 1614 bool LocationBarViewGtk::ShouldOnlyShowLocation() {
1578 return !browser_->is_type_tabbed(); 1615 return !browser_->is_type_tabbed();
1579 } 1616 }
1580 1617
1581 void LocationBarViewGtk::AdjustChildrenVisibility() { 1618 void LocationBarViewGtk::AdjustChildrenVisibility() {
1582 int text_width = location_entry_->TextWidth(); 1619 int text_width = location_entry_->TextWidth();
1583 int available_width = entry_box_width_ - text_width - kInnerPadding; 1620 int available_width = entry_box_width_ - text_width - InnerPadding();
1584 1621
1585 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be 1622 // Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be
1586 // visible at the same time. 1623 // visible at the same time.
1587 if (!show_selected_keyword_ && 1624 if (!show_selected_keyword_ &&
1588 gtk_widget_get_visible(tab_to_search_alignment_)) { 1625 gtk_widget_get_visible(tab_to_search_alignment_)) {
1589 gtk_widget_hide(tab_to_search_alignment_); 1626 gtk_widget_hide(tab_to_search_alignment_);
1590 } else if (!show_keyword_hint_ && 1627 } else if (!show_keyword_hint_ &&
1591 gtk_widget_get_visible(tab_to_search_hint_)) { 1628 gtk_widget_get_visible(tab_to_search_hint_)) {
1592 gtk_widget_hide(tab_to_search_hint_); 1629 gtk_widget_hide(tab_to_search_hint_);
1593 } 1630 }
1594 1631
1595 if (show_selected_keyword_) { 1632 if (show_selected_keyword_) {
1596 GtkRequisition box, full_label, partial_label; 1633 GtkRequisition box, full_label, partial_label;
1597 gtk_widget_size_request(tab_to_search_box_, &box); 1634 gtk_widget_size_request(tab_to_search_box_, &box);
1598 gtk_widget_size_request(tab_to_search_full_label_, &full_label); 1635 gtk_widget_size_request(tab_to_search_full_label_, &full_label);
1599 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); 1636 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label);
1600 int full_partial_width_diff = full_label.width - partial_label.width; 1637 int full_partial_width_diff = full_label.width - partial_label.width;
1601 int full_box_width; 1638 int full_box_width;
1602 int partial_box_width; 1639 int partial_box_width;
1603 if (gtk_widget_get_visible(tab_to_search_full_label_)) { 1640 if (gtk_widget_get_visible(tab_to_search_full_label_)) {
1604 full_box_width = box.width; 1641 full_box_width = box.width;
1605 partial_box_width = full_box_width - full_partial_width_diff; 1642 partial_box_width = full_box_width - full_partial_width_diff;
1606 } else { 1643 } else {
1607 partial_box_width = box.width; 1644 partial_box_width = box.width;
1608 full_box_width = partial_box_width + full_partial_width_diff; 1645 full_box_width = partial_box_width + full_partial_width_diff;
1609 } 1646 }
1610 1647
1611 if (partial_box_width >= entry_box_width_ - kInnerPadding) { 1648 if (partial_box_width >= entry_box_width_ - InnerPadding()) {
1612 gtk_widget_hide(tab_to_search_alignment_); 1649 gtk_widget_hide(tab_to_search_alignment_);
1613 } else if (full_box_width >= available_width) { 1650 } else if (full_box_width >= available_width) {
1614 gtk_widget_hide(tab_to_search_full_label_); 1651 gtk_widget_hide(tab_to_search_full_label_);
1615 gtk_widget_show(tab_to_search_partial_label_); 1652 gtk_widget_show(tab_to_search_partial_label_);
1616 gtk_widget_show(tab_to_search_alignment_); 1653 gtk_widget_show(tab_to_search_alignment_);
1617 } else if (full_box_width < available_width) { 1654 } else if (full_box_width < available_width) {
1618 gtk_widget_hide(tab_to_search_partial_label_); 1655 gtk_widget_hide(tab_to_search_partial_label_);
1619 gtk_widget_show(tab_to_search_full_label_); 1656 gtk_widget_show(tab_to_search_full_label_);
1620 gtk_widget_show(tab_to_search_alignment_); 1657 gtk_widget_show(tab_to_search_alignment_);
1621 } 1658 }
1622 } else if (show_keyword_hint_) { 1659 } else if (show_keyword_hint_) {
1623 GtkRequisition leading, icon, trailing; 1660 GtkRequisition leading, icon, trailing;
1624 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading); 1661 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading);
1625 gtk_widget_size_request(tab_to_search_hint_icon_, &icon); 1662 gtk_widget_size_request(tab_to_search_hint_icon_, &icon);
1626 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing); 1663 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing);
1627 int full_width = leading.width + icon.width + trailing.width; 1664 int full_width = leading.width + icon.width + trailing.width;
1628 1665
1629 if (icon.width >= entry_box_width_ - kInnerPadding) { 1666 if (icon.width >= entry_box_width_ - InnerPadding()) {
1630 gtk_widget_hide(tab_to_search_hint_); 1667 gtk_widget_hide(tab_to_search_hint_);
1631 } else if (full_width >= available_width) { 1668 } else if (full_width >= available_width) {
1632 gtk_widget_hide(tab_to_search_hint_leading_label_); 1669 gtk_widget_hide(tab_to_search_hint_leading_label_);
1633 gtk_widget_hide(tab_to_search_hint_trailing_label_); 1670 gtk_widget_hide(tab_to_search_hint_trailing_label_);
1634 gtk_widget_show(tab_to_search_hint_); 1671 gtk_widget_show(tab_to_search_hint_);
1635 } else if (full_width < available_width) { 1672 } else if (full_width < available_width) {
1636 gtk_widget_show(tab_to_search_hint_leading_label_); 1673 gtk_widget_show(tab_to_search_hint_leading_label_);
1637 gtk_widget_show(tab_to_search_hint_trailing_label_); 1674 gtk_widget_show(tab_to_search_hint_trailing_label_);
1638 gtk_widget_show(tab_to_search_hint_); 1675 gtk_widget_show(tab_to_search_hint_);
1639 } 1676 }
1640 } 1677 }
1641 } 1678 }
1642 1679
1643 //////////////////////////////////////////////////////////////////////////////// 1680 ////////////////////////////////////////////////////////////////////////////////
1644 // LocationBarViewGtk::PageToolViewGtk 1681 // LocationBarViewGtk::PageToolViewGtk
1645 1682
1646 LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk( 1683 LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk(
1647 const LocationBarViewGtk* parent) 1684 const LocationBarViewGtk* parent)
1648 : alignment_(gtk_alignment_new(0, 0, 1, 1)), 1685 : alignment_(gtk_alignment_new(0, 0, 1, 1)),
1649 event_box_(gtk_event_box_new()), 1686 event_box_(gtk_event_box_new()),
1650 hbox_(gtk_hbox_new(FALSE, kInnerPadding)), 1687 hbox_(gtk_hbox_new(FALSE, InnerPadding())),
1651 image_(gtk_image_new()), 1688 image_(gtk_image_new()),
1652 label_(gtk_label_new(NULL)), 1689 label_(gtk_label_new(NULL)),
1653 parent_(parent), 1690 parent_(parent),
1654 animation_(this), 1691 animation_(this),
1655 weak_factory_(this) { 1692 weak_factory_(this) {
1656 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0); 1693 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0);
1657 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get()); 1694 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get());
1658 1695
1659 // Make the event box not visible so it does not paint a background. 1696 // Make the event box not visible so it does not paint a background.
1660 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); 1697 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE);
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 } 2148 }
2112 2149
2113 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( 2150 void LocationBarViewGtk::PageActionViewGtk::InspectPopup(
2114 ExtensionAction* action) { 2151 ExtensionAction* action) {
2115 ExtensionPopupGtk::Show( 2152 ExtensionPopupGtk::Show(
2116 action->GetPopupUrl(current_tab_id_), 2153 action->GetPopupUrl(current_tab_id_),
2117 owner_->browser_, 2154 owner_->browser_,
2118 event_box_.get(), 2155 event_box_.get(),
2119 ExtensionPopupGtk::SHOW_AND_INSPECT); 2156 ExtensionPopupGtk::SHOW_AND_INSPECT);
2120 } 2157 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698