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

Unified 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: Call the right superclass method 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/gtk_theme_service.cc ('k') | chrome/browser/ui/omnibox/location_bar_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/location_bar_view_gtk.cc
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index 8f86c171c5db5ad9acf02723a626c2dbab64c3a9..318a59a76d4742081d0090e4259d57bd0743486e 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -122,9 +122,7 @@ const int kHboxBorder = 2;
// Padding between the elements in the bar.
const int kInnerPadding = 2;
-
-// Padding between the right of the star and the edge of the URL entry.
-const int kStarRightPadding = 2;
+const int kScriptBadgeInnerPadding = 9;
// Colors used to draw the EV certificate rounded bubble.
const GdkColor kEvSecureTextColor = GDK_COLOR_RGB(0x07, 0x95, 0x00);
@@ -164,6 +162,11 @@ const GdkColor kGrayBorderColor = GDK_COLOR_RGB(0xa0, 0xa0, 0xa0);
const GdkColor kTopColorGray = GDK_COLOR_RGB(0xe5, 0xe5, 0xe5);
const GdkColor kBottomColorGray = GDK_COLOR_RGB(0xd0, 0xd0, 0xd0);
+inline int InnerPadding() {
+ return extensions::switch_utils::AreScriptBadgesEnabled() ?
+ kScriptBadgeInnerPadding : kInnerPadding;
+}
+
// If widget is visible, increment the int pointed to by count.
// Suitible for use with gtk_container_foreach.
void CountVisibleWidgets(GtkWidget* widget, gpointer count) {
@@ -439,7 +442,7 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
theme_service_ = GtkThemeService::GetFrom(profile);
// Create the widget first, so we can pass it to the OmniboxViewGtk.
- hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding));
+ hbox_.Own(gtk_hbox_new(FALSE, InnerPadding()));
gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder);
// We will paint for the alignment, to paint the background and border.
gtk_widget_set_app_paintable(hbox_.get(), TRUE);
@@ -460,7 +463,7 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
// Put |tab_to_search_box_|, |location_entry_|, and |tab_to_search_hint_| into
// a sub hbox, so that we can make this part horizontally shrinkable without
// affecting other elements in the location bar.
- entry_box_ = gtk_hbox_new(FALSE, kInnerPadding);
+ entry_box_ = gtk_hbox_new(FALSE, InnerPadding());
gtk_widget_show(entry_box_);
gtk_widget_set_size_request(entry_box_, 0, -1);
gtk_box_pack_start(GTK_BOX(hbox_.get()), entry_box_, TRUE, TRUE, 0);
@@ -553,7 +556,7 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
0, kMagicActionBoxYOffset,
- 0, kInnerPadding);
+ 0, InnerPadding());
gtk_container_add(GTK_CONTAINER(alignment), action_box_button_->widget());
gtk_box_pack_end(GTK_BOX(hbox_.get()), alignment,
@@ -569,7 +572,7 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
CreateZoomButton();
gtk_box_pack_end(GTK_BOX(hbox_.get()), zoom_.get(), FALSE, FALSE, 0);
- content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1));
+ content_setting_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding() + 1));
gtk_widget_set_name(content_setting_hbox_.get(),
"chrome-content-setting-hbox");
gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(),
@@ -584,13 +587,13 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
content_setting_view->widget(), FALSE, FALSE, 0);
}
- page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding));
+ page_action_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding()));
gtk_widget_set_name(page_action_hbox_.get(),
"chrome-page-action-hbox");
gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(),
FALSE, FALSE, 0);
- web_intents_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding));
+ web_intents_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding()));
gtk_widget_set_name(web_intents_hbox_.get(),
"chrome-web-intents-hbox");
gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(),
@@ -809,7 +812,7 @@ GtkWidget* LocationBarViewGtk::CreateIconButton(
GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0,
- 0, kInnerPadding);
+ 0, InnerPadding());
gtk_container_add(GTK_CONTAINER(alignment), *image);
GtkWidget* result = gtk_event_box_new();
@@ -989,6 +992,7 @@ void LocationBarViewGtk::UpdatePageActions() {
page_action_views_[i]->UpdateVisibility(
toolbar_model_->input_in_progress() ? NULL : contents, url);
}
+ gtk_widget_queue_draw(hbox_.get());
}
// If there are no visible page actions, hide the hbox too, so that it does
@@ -1185,6 +1189,39 @@ gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget,
background.RenderToWidget(widget);
}
+ // Draw ExtensionAction backgrounds and borders, if necessary. The borders
+ // appear exactly between the elements, so they can't draw the borders
+ // themselves.
+ gfx::CanvasSkiaPaint canvas(event, /*opaque=*/false);
+ for (ScopedVector<PageActionViewGtk>::const_iterator
+ page_action_view = page_action_views_.begin();
+ page_action_view != page_action_views_.end();
+ ++page_action_view) {
+ if ((*page_action_view)->IsVisible()) {
+ // Figure out where the page action is drawn so we can draw
+ // borders to its left and right.
+ GtkAllocation allocation;
+ gtk_widget_get_allocation((*page_action_view)->widget(), &allocation);
+ ExtensionAction* action = (*page_action_view)->page_action();
+ gfx::Rect bounds(allocation);
+ // Make the bounding rectangle include the whole vertical range of the
+ // location bar, and the mid-point pixels between adjacent page actions.
+ //
+ // For odd InnerPadding()s, "InnerPadding() + 1" includes the mid-point
+ // between two page actions in the bounding rectangle. For even paddings,
+ // the +1 is dropped, which is right since there is no pixel at the
+ // mid-point.
+ bounds.Inset(-(InnerPadding() + 1) / 2,
+ theme_service_->UsingNativeTheme() ? -1 : 0);
+ location_bar_util::PaintExtensionActionBackground(
+ *action, SessionID::IdForTab(GetWebContents()),
+ &canvas, bounds,
+ theme_service_->get_location_bar_text_color(),
+ theme_service_->get_location_bar_bg_color());
+ }
+ }
+ // Destroying |canvas| draws the background.
+
return FALSE; // Continue propagating the expose.
}
@@ -1588,7 +1625,7 @@ bool LocationBarViewGtk::ShouldOnlyShowLocation() {
void LocationBarViewGtk::AdjustChildrenVisibility() {
int text_width = location_entry_->TextWidth();
- int available_width = entry_box_width_ - text_width - kInnerPadding;
+ int available_width = entry_box_width_ - text_width - InnerPadding();
// Only one of |tab_to_search_alignment_| and |tab_to_search_hint_| can be
// visible at the same time.
@@ -1616,7 +1653,7 @@ void LocationBarViewGtk::AdjustChildrenVisibility() {
full_box_width = partial_box_width + full_partial_width_diff;
}
- if (partial_box_width >= entry_box_width_ - kInnerPadding) {
+ if (partial_box_width >= entry_box_width_ - InnerPadding()) {
gtk_widget_hide(tab_to_search_alignment_);
} else if (full_box_width >= available_width) {
gtk_widget_hide(tab_to_search_full_label_);
@@ -1634,7 +1671,7 @@ void LocationBarViewGtk::AdjustChildrenVisibility() {
gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing);
int full_width = leading.width + icon.width + trailing.width;
- if (icon.width >= entry_box_width_ - kInnerPadding) {
+ if (icon.width >= entry_box_width_ - InnerPadding()) {
gtk_widget_hide(tab_to_search_hint_);
} else if (full_width >= available_width) {
gtk_widget_hide(tab_to_search_hint_leading_label_);
@@ -1655,7 +1692,7 @@ LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk(
const LocationBarViewGtk* parent)
: alignment_(gtk_alignment_new(0, 0, 1, 1)),
event_box_(gtk_event_box_new()),
- hbox_(gtk_hbox_new(FALSE, kInnerPadding)),
+ hbox_(gtk_hbox_new(FALSE, InnerPadding())),
image_(gtk_image_new()),
label_(gtk_label_new(NULL)),
parent_(parent),
« no previous file with comments | « chrome/browser/ui/gtk/gtk_theme_service.cc ('k') | chrome/browser/ui/omnibox/location_bar_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698