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/gfx/canvas_paint.h" | 9 #include "app/gfx/canvas_paint.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/i18n/rtl.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "chrome/app/chrome_dll_resource.h" | 16 #include "chrome/app/chrome_dll_resource.h" |
16 #include "chrome/browser/accessibility_events.h" | 17 #include "chrome/browser/accessibility_events.h" |
17 #include "chrome/browser/alternate_nav_url_fetcher.h" | 18 #include "chrome/browser/alternate_nav_url_fetcher.h" |
18 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" | 19 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h" |
19 #include "chrome/browser/browser.h" | 20 #include "chrome/browser/browser.h" |
20 #include "chrome/browser/browser_list.h" | 21 #include "chrome/browser/browser_list.h" |
21 #include "chrome/browser/command_updater.h" | 22 #include "chrome/browser/command_updater.h" |
22 #include "chrome/browser/content_setting_bubble_model.h" | 23 #include "chrome/browser/content_setting_bubble_model.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 const size_t dot_index = description.find(L'.'); | 114 const size_t dot_index = description.find(L'.'); |
114 const size_t ws_index = description.find_first_of(kWhitespaceWide); | 115 const size_t ws_index = description.find_first_of(kWhitespaceWide); |
115 size_t chop_index = std::min(dot_index, ws_index); | 116 size_t chop_index = std::min(dot_index, ws_index); |
116 std::wstring min_string; | 117 std::wstring min_string; |
117 if (chop_index == std::wstring::npos) { | 118 if (chop_index == std::wstring::npos) { |
118 // No dot or whitespace, truncate to at most 3 chars. | 119 // No dot or whitespace, truncate to at most 3 chars. |
119 min_string = l10n_util::TruncateString(description, 3); | 120 min_string = l10n_util::TruncateString(description, 3); |
120 } else { | 121 } else { |
121 min_string = description.substr(0, chop_index); | 122 min_string = description.substr(0, chop_index); |
122 } | 123 } |
123 l10n_util::AdjustStringForLocaleDirection(min_string, &min_string); | 124 base::i18n::AdjustStringForLocaleDirection(min_string, &min_string); |
124 return min_string; | 125 return min_string; |
125 } | 126 } |
126 | 127 |
127 } // namespace | 128 } // namespace |
128 | 129 |
129 //////////////////////////////////////////////////////////////////////////////// | 130 //////////////////////////////////////////////////////////////////////////////// |
130 // LocationBarViewGtk | 131 // LocationBarViewGtk |
131 | 132 |
132 // static | 133 // static |
133 const GdkColor LocationBarViewGtk::kBackgroundColorByLevel[3] = { | 134 const GdkColor LocationBarViewGtk::kBackgroundColorByLevel[3] = { |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 return; | 835 return; |
835 | 836 |
836 gfx::Rect rect = gtk_util::GetWidgetRectRelativeToToplevel(widget()); | 837 gfx::Rect rect = gtk_util::GetWidgetRectRelativeToToplevel(widget()); |
837 rect.set_width(0); | 838 rect.set_width(0); |
838 rect.set_height(0); | 839 rect.set_height(0); |
839 | 840 |
840 // The bubble needs to be just below the Omnibox and slightly to the right | 841 // The bubble needs to be just below the Omnibox and slightly to the right |
841 // of star button, so shift x and y co-ordinates. | 842 // of star button, so shift x and y co-ordinates. |
842 int y_offset = widget()->allocation.height + kFirstRunBubbleTopMargin; | 843 int y_offset = widget()->allocation.height + kFirstRunBubbleTopMargin; |
843 int x_offset = 0; | 844 int x_offset = 0; |
844 if (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) | 845 if (!base::i18n::IsRTL()) |
845 x_offset = kFirstRunBubbleLeftMargin; | 846 x_offset = kFirstRunBubbleLeftMargin; |
846 else | 847 else |
847 x_offset = widget()->allocation.width - kFirstRunBubbleLeftMargin; | 848 x_offset = widget()->allocation.width - kFirstRunBubbleLeftMargin; |
848 rect.Offset(x_offset, y_offset); | 849 rect.Offset(x_offset, y_offset); |
849 | 850 |
850 FirstRunBubble::Show(profile_, | 851 FirstRunBubble::Show(profile_, |
851 GTK_WINDOW(gtk_widget_get_toplevel(widget())), | 852 GTK_WINDOW(gtk_widget_get_toplevel(widget())), |
852 rect, | 853 rect, |
853 use_OEM_bubble); | 854 use_OEM_bubble); |
854 } | 855 } |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 | 1243 |
1243 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1244 std::string badge_text = page_action_->GetBadgeText(tab_id); |
1244 if (badge_text.empty()) | 1245 if (badge_text.empty()) |
1245 return FALSE; | 1246 return FALSE; |
1246 | 1247 |
1247 gfx::CanvasPaint canvas(event, false); | 1248 gfx::CanvasPaint canvas(event, false); |
1248 gfx::Rect bounding_rect(widget->allocation); | 1249 gfx::Rect bounding_rect(widget->allocation); |
1249 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1250 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
1250 return FALSE; | 1251 return FALSE; |
1251 } | 1252 } |
OLD | NEW |