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/views/go_button.h" | 5 #include "chrome/browser/views/go_button.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/i18n/rtl.h" |
9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 11 #include "chrome/app/chrome_dll_resource.h" |
11 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
12 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
13 #include "chrome/browser/search_engines/template_url_model.h" | 14 #include "chrome/browser/search_engines/template_url_model.h" |
14 #include "chrome/browser/views/event_utils.h" | 15 #include "chrome/browser/views/event_utils.h" |
15 #include "chrome/browser/views/location_bar_view.h" | 16 #include "chrome/browser/views/location_bar_view.h" |
16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
17 | 18 |
18 //////////////////////////////////////////////////////////////////////////////// | 19 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 98 |
98 // Need to make sure the text direction is adjusted based on the locale so | 99 // Need to make sure the text direction is adjusted based on the locale so |
99 // that pure LTR strings are displayed appropriately on RTL locales. For | 100 // that pure LTR strings are displayed appropriately on RTL locales. For |
100 // example, not adjusting the string will cause the URL | 101 // example, not adjusting the string will cause the URL |
101 // "http://www.google.com/" to be displayed in the tooltip as | 102 // "http://www.google.com/" to be displayed in the tooltip as |
102 // "/http://www.google.com". | 103 // "/http://www.google.com". |
103 // | 104 // |
104 // Note that we mark the URL's text as LTR (instead of examining the | 105 // Note that we mark the URL's text as LTR (instead of examining the |
105 // characters and guessing the text directionality) since URLs are always | 106 // characters and guessing the text directionality) since URLs are always |
106 // treated as left-to-right text, even when they contain RTL characters. | 107 // treated as left-to-right text, even when they contain RTL characters. |
107 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) | 108 if (base::i18n::IsRTL()) |
108 l10n_util::WrapStringWithLTRFormatting(¤t_text); | 109 base::i18n::WrapStringWithLTRFormatting(¤t_text); |
109 | 110 |
110 AutocompleteEditModel* edit_model = location_bar_->location_entry()->model(); | 111 AutocompleteEditModel* edit_model = location_bar_->location_entry()->model(); |
111 if (edit_model->CurrentTextIsURL()) { | 112 if (edit_model->CurrentTextIsURL()) { |
112 tooltip->assign(l10n_util::GetStringF(IDS_TOOLTIP_GO_SITE, current_text)); | 113 tooltip->assign(l10n_util::GetStringF(IDS_TOOLTIP_GO_SITE, current_text)); |
113 } else { | 114 } else { |
114 std::wstring keyword(edit_model->keyword()); | 115 std::wstring keyword(edit_model->keyword()); |
115 TemplateURLModel* template_url_model = | 116 TemplateURLModel* template_url_model = |
116 location_bar_->profile()->GetTemplateURLModel(); | 117 location_bar_->profile()->GetTemplateURLModel(); |
117 const TemplateURL* provider = | 118 const TemplateURL* provider = |
118 (keyword.empty() || edit_model->is_keyword_hint()) ? | 119 (keyword.empty() || edit_model->is_keyword_hint()) ? |
119 template_url_model->GetDefaultSearchProvider() : | 120 template_url_model->GetDefaultSearchProvider() : |
120 template_url_model->GetTemplateURLForKeyword(keyword); | 121 template_url_model->GetTemplateURLForKeyword(keyword); |
121 if (!provider) | 122 if (!provider) |
122 return false; | 123 return false; |
123 tooltip->assign(l10n_util::GetStringF(IDS_TOOLTIP_GO_SEARCH, | 124 tooltip->assign(l10n_util::GetStringF(IDS_TOOLTIP_GO_SEARCH, |
124 provider->AdjustedShortNameForLocaleDirection(), current_text)); | 125 provider->AdjustedShortNameForLocaleDirection(), current_text)); |
125 } | 126 } |
126 return true; | 127 return true; |
127 } | 128 } |
128 | 129 |
129 //////////////////////////////////////////////////////////////////////////////// | 130 //////////////////////////////////////////////////////////////////////////////// |
130 // GoButton, private: | 131 // GoButton, private: |
131 | 132 |
132 void GoButton::OnButtonTimer() { | 133 void GoButton::OnButtonTimer() { |
133 stop_timer_.RevokeAll(); | 134 stop_timer_.RevokeAll(); |
134 ChangeMode(intended_mode_, true); | 135 ChangeMode(intended_mode_, true); |
135 } | 136 } |
OLD | NEW |