| 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/edit_search_engine_dialog.h" | 5 #include "chrome/browser/gtk/edit_search_engine_dialog.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "base/i18n/rtl.h" |
| 11 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/gtk/accessible_widget_helper_gtk.h" | 14 #include "chrome/browser/gtk/accessible_widget_helper_gtk.h" |
| 14 #include "chrome/browser/gtk/gtk_util.h" | 15 #include "chrome/browser/gtk/gtk_util.h" |
| 15 #include "chrome/browser/net/url_fixer_upper.h" | 16 #include "chrome/browser/net/url_fixer_upper.h" |
| 16 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
| 17 #include "chrome/browser/search_engines/edit_search_engine_controller.h" | 18 #include "chrome/browser/search_engines/edit_search_engine_controller.h" |
| 18 #include "chrome/browser/search_engines/template_url.h" | 19 #include "chrome/browser/search_engines/template_url.h" |
| 19 #include "chrome/browser/search_engines/template_url_model.h" | 20 #include "chrome/browser/search_engines/template_url_model.h" |
| 20 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // displayed correctly since it contains the substring "%s". This substring | 176 // displayed correctly since it contains the substring "%s". This substring |
| 176 // is not interpreted by the Unicode BiDi algorithm as an LTR string and | 177 // is not interpreted by the Unicode BiDi algorithm as an LTR string and |
| 177 // therefore the end result is that the following right to left text is | 178 // therefore the end result is that the following right to left text is |
| 178 // displayed: ".three two s% one" (where 'one', 'two', etc. are words in | 179 // displayed: ".three two s% one" (where 'one', 'two', etc. are words in |
| 179 // Hebrew). | 180 // Hebrew). |
| 180 // | 181 // |
| 181 // In order to fix this problem we transform the substring "%s" so that it | 182 // In order to fix this problem we transform the substring "%s" so that it |
| 182 // is displayed correctly when rendered in an RTL context. | 183 // is displayed correctly when rendered in an RTL context. |
| 183 std::string description = | 184 std::string description = |
| 184 l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_URL_DESCRIPTION_LABEL); | 185 l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_URL_DESCRIPTION_LABEL); |
| 185 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { | 186 if (base::i18n::IsRTL()) { |
| 186 const std::string reversed_percent("s%"); | 187 const std::string reversed_percent("s%"); |
| 187 std::wstring::size_type percent_index = | 188 std::wstring::size_type percent_index = |
| 188 description.find("%s", static_cast<std::string::size_type>(0)); | 189 description.find("%s", static_cast<std::string::size_type>(0)); |
| 189 if (percent_index != std::string::npos) | 190 if (percent_index != std::string::npos) |
| 190 description.replace(percent_index, | 191 description.replace(percent_index, |
| 191 reversed_percent.length(), | 192 reversed_percent.length(), |
| 192 reversed_percent); | 193 reversed_percent); |
| 193 } | 194 } |
| 194 | 195 |
| 195 GtkWidget* description_label = gtk_label_new(description.c_str()); | 196 GtkWidget* description_label = gtk_label_new(description.c_str()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 window->controller_->CleanUpCancelledAdd(); | 267 window->controller_->CleanUpCancelledAdd(); |
| 267 } | 268 } |
| 268 gtk_widget_destroy(window->dialog_); | 269 gtk_widget_destroy(window->dialog_); |
| 269 } | 270 } |
| 270 | 271 |
| 271 // static | 272 // static |
| 272 void EditSearchEngineDialog::OnWindowDestroy( | 273 void EditSearchEngineDialog::OnWindowDestroy( |
| 273 GtkWidget* widget, EditSearchEngineDialog* window) { | 274 GtkWidget* widget, EditSearchEngineDialog* window) { |
| 274 MessageLoop::current()->DeleteSoon(FROM_HERE, window); | 275 MessageLoop::current()->DeleteSoon(FROM_HERE, window); |
| 275 } | 276 } |
| OLD | NEW |