| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk/location_bar_view_gtk.h" | 5 #include "chrome/browser/gtk/location_bar_view_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 } | 606 } |
| 607 | 607 |
| 608 SkBitmap LocationBarViewGtk::GetFavIcon() const { | 608 SkBitmap LocationBarViewGtk::GetFavIcon() const { |
| 609 return GetTabContents()->GetFavIcon(); | 609 return GetTabContents()->GetFavIcon(); |
| 610 } | 610 } |
| 611 | 611 |
| 612 std::wstring LocationBarViewGtk::GetTitle() const { | 612 std::wstring LocationBarViewGtk::GetTitle() const { |
| 613 return UTF16ToWideHack(GetTabContents()->GetTitle()); | 613 return UTF16ToWideHack(GetTabContents()->GetTitle()); |
| 614 } | 614 } |
| 615 | 615 |
| 616 bool LocationBarViewGtk::IsKeywordHintVisible() const { |
| 617 return GTK_WIDGET_VISIBLE(tab_to_search_hint_); |
| 618 } |
| 619 |
| 616 void LocationBarViewGtk::ShowFirstRunBubble(FirstRun::BubbleType bubble_type) { | 620 void LocationBarViewGtk::ShowFirstRunBubble(FirstRun::BubbleType bubble_type) { |
| 617 // We need the browser window to be shown before we can show the bubble, but | 621 // We need the browser window to be shown before we can show the bubble, but |
| 618 // we get called before that's happened. | 622 // we get called before that's happened. |
| 619 Task* task = first_run_bubble_.NewRunnableMethod( | 623 Task* task = first_run_bubble_.NewRunnableMethod( |
| 620 &LocationBarViewGtk::ShowFirstRunBubbleInternal, bubble_type); | 624 &LocationBarViewGtk::ShowFirstRunBubbleInternal, bubble_type); |
| 621 MessageLoop::current()->PostTask(FROM_HERE, task); | 625 MessageLoop::current()->PostTask(FROM_HERE, task); |
| 622 } | 626 } |
| 623 | 627 |
| 624 void LocationBarViewGtk::SetSuggestedText(const string16& text) { | 628 void LocationBarViewGtk::SetSuggestedText(const string16& text) { |
| 625 if (CommandLine::ForCurrentProcess()->HasSwitch( | 629 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 bool LocationBarViewGtk::ShouldOnlyShowLocation() { | 1196 bool LocationBarViewGtk::ShouldOnlyShowLocation() { |
| 1193 return browser_->type() != Browser::TYPE_NORMAL; | 1197 return browser_->type() != Browser::TYPE_NORMAL; |
| 1194 } | 1198 } |
| 1195 | 1199 |
| 1196 void LocationBarViewGtk::AdjustChildrenVisibility() { | 1200 void LocationBarViewGtk::AdjustChildrenVisibility() { |
| 1197 int text_width = location_entry_->TextWidth(); | 1201 int text_width = location_entry_->TextWidth(); |
| 1198 int available_width = entry_box_width_ - text_width - kInnerPadding; | 1202 int available_width = entry_box_width_ - text_width - kInnerPadding; |
| 1199 | 1203 |
| 1200 // Only one of |tab_to_search_box_| and |tab_to_search_hint_| can be visible | 1204 // Only one of |tab_to_search_box_| and |tab_to_search_hint_| can be visible |
| 1201 // at the same time. | 1205 // at the same time. |
| 1202 if (!show_selected_keyword_ && GTK_WIDGET_VISIBLE(tab_to_search_box_)) { | 1206 if (!show_selected_keyword_ && GTK_WIDGET_VISIBLE(tab_to_search_box_)) |
| 1203 gtk_widget_hide(tab_to_search_box_); | 1207 gtk_widget_hide(tab_to_search_box_); |
| 1204 } else if (!show_keyword_hint_ && GTK_WIDGET_VISIBLE(tab_to_search_hint_)) { | 1208 else if (!show_keyword_hint_ && GTK_WIDGET_VISIBLE(tab_to_search_hint_)) |
| 1205 gtk_widget_hide(tab_to_search_hint_); | 1209 gtk_widget_hide(tab_to_search_hint_); |
| 1206 location_entry_->set_enable_tab_to_search(false); | |
| 1207 } | |
| 1208 | 1210 |
| 1209 if (show_selected_keyword_) { | 1211 if (show_selected_keyword_) { |
| 1210 GtkRequisition box, full_label, partial_label; | 1212 GtkRequisition box, full_label, partial_label; |
| 1211 gtk_widget_size_request(tab_to_search_box_, &box); | 1213 gtk_widget_size_request(tab_to_search_box_, &box); |
| 1212 gtk_widget_size_request(tab_to_search_full_label_, &full_label); | 1214 gtk_widget_size_request(tab_to_search_full_label_, &full_label); |
| 1213 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); | 1215 gtk_widget_size_request(tab_to_search_partial_label_, &partial_label); |
| 1214 int full_partial_width_diff = full_label.width - partial_label.width; | 1216 int full_partial_width_diff = full_label.width - partial_label.width; |
| 1215 int full_box_width; | 1217 int full_box_width; |
| 1216 int partial_box_width; | 1218 int partial_box_width; |
| 1217 if (GTK_WIDGET_VISIBLE(tab_to_search_full_label_)) { | 1219 if (GTK_WIDGET_VISIBLE(tab_to_search_full_label_)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1235 } | 1237 } |
| 1236 } else if (show_keyword_hint_) { | 1238 } else if (show_keyword_hint_) { |
| 1237 GtkRequisition leading, icon, trailing; | 1239 GtkRequisition leading, icon, trailing; |
| 1238 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading); | 1240 gtk_widget_size_request(tab_to_search_hint_leading_label_, &leading); |
| 1239 gtk_widget_size_request(tab_to_search_hint_icon_, &icon); | 1241 gtk_widget_size_request(tab_to_search_hint_icon_, &icon); |
| 1240 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing); | 1242 gtk_widget_size_request(tab_to_search_hint_trailing_label_, &trailing); |
| 1241 int full_width = leading.width + icon.width + trailing.width; | 1243 int full_width = leading.width + icon.width + trailing.width; |
| 1242 | 1244 |
| 1243 if (icon.width >= entry_box_width_ - kInnerPadding) { | 1245 if (icon.width >= entry_box_width_ - kInnerPadding) { |
| 1244 gtk_widget_hide(tab_to_search_hint_); | 1246 gtk_widget_hide(tab_to_search_hint_); |
| 1245 location_entry_->set_enable_tab_to_search(false); | |
| 1246 } else if (full_width >= available_width) { | 1247 } else if (full_width >= available_width) { |
| 1247 gtk_widget_hide(tab_to_search_hint_leading_label_); | 1248 gtk_widget_hide(tab_to_search_hint_leading_label_); |
| 1248 gtk_widget_hide(tab_to_search_hint_trailing_label_); | 1249 gtk_widget_hide(tab_to_search_hint_trailing_label_); |
| 1249 gtk_widget_show(tab_to_search_hint_); | 1250 gtk_widget_show(tab_to_search_hint_); |
| 1250 location_entry_->set_enable_tab_to_search(true); | |
| 1251 } else if (full_width < available_width) { | 1251 } else if (full_width < available_width) { |
| 1252 gtk_widget_show(tab_to_search_hint_leading_label_); | 1252 gtk_widget_show(tab_to_search_hint_leading_label_); |
| 1253 gtk_widget_show(tab_to_search_hint_trailing_label_); | 1253 gtk_widget_show(tab_to_search_hint_trailing_label_); |
| 1254 gtk_widget_show(tab_to_search_hint_); | 1254 gtk_widget_show(tab_to_search_hint_); |
| 1255 location_entry_->set_enable_tab_to_search(true); | |
| 1256 } | 1255 } |
| 1257 } | 1256 } |
| 1258 } | 1257 } |
| 1259 | 1258 |
| 1260 //////////////////////////////////////////////////////////////////////////////// | 1259 //////////////////////////////////////////////////////////////////////////////// |
| 1261 // LocationBarViewGtk::ContentSettingImageViewGtk | 1260 // LocationBarViewGtk::ContentSettingImageViewGtk |
| 1262 LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk( | 1261 LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk( |
| 1263 ContentSettingsType content_type, | 1262 ContentSettingsType content_type, |
| 1264 const LocationBarViewGtk* parent, | 1263 const LocationBarViewGtk* parent, |
| 1265 Profile* profile) | 1264 Profile* profile) |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 | 1547 |
| 1549 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1548 std::string badge_text = page_action_->GetBadgeText(tab_id); |
| 1550 if (badge_text.empty()) | 1549 if (badge_text.empty()) |
| 1551 return FALSE; | 1550 return FALSE; |
| 1552 | 1551 |
| 1553 gfx::CanvasSkiaPaint canvas(event, false); | 1552 gfx::CanvasSkiaPaint canvas(event, false); |
| 1554 gfx::Rect bounding_rect(widget->allocation); | 1553 gfx::Rect bounding_rect(widget->allocation); |
| 1555 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1554 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
| 1556 return FALSE; | 1555 return FALSE; |
| 1557 } | 1556 } |
| OLD | NEW |