| 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/dom_ui/dom_ui.h" | 5 #include "chrome/browser/dom_ui/dom_ui.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 // Since the title can contain BiDi text, we need to mark the text as either | 173 // Since the title can contain BiDi text, we need to mark the text as either |
| 174 // RTL or LTR, depending on the characters in the string. If we use the URL | 174 // RTL or LTR, depending on the characters in the string. If we use the URL |
| 175 // as the title, we mark the title as LTR since URLs are always treated as | 175 // as the title, we mark the title as LTR since URLs are always treated as |
| 176 // left to right strings. | 176 // left to right strings. |
| 177 string16 title_to_set(title); | 177 string16 title_to_set(title); |
| 178 if (base::i18n::IsRTL()) { | 178 if (base::i18n::IsRTL()) { |
| 179 if (using_url_as_the_title) { | 179 if (using_url_as_the_title) { |
| 180 base::i18n::WrapStringWithLTRFormatting(&title_to_set); | 180 base::i18n::WrapStringWithLTRFormatting(&title_to_set); |
| 181 } else { | 181 } else { |
| 182 bool success = | 182 base::i18n::AdjustStringForLocaleDirection(&title_to_set); |
| 183 base::i18n::AdjustStringForLocaleDirection(title, &title_to_set); | |
| 184 DCHECK(success ? (title != title_to_set) : (title == title_to_set)); | |
| 185 } | 183 } |
| 186 } | 184 } |
| 187 dictionary->SetString("title", title_to_set); | 185 dictionary->SetString("title", title_to_set); |
| 188 } | 186 } |
| 189 | 187 |
| 190 bool DOMMessageHandler::ExtractIntegerValue(const ListValue* value, | 188 bool DOMMessageHandler::ExtractIntegerValue(const ListValue* value, |
| 191 int* out_int) { | 189 int* out_int) { |
| 192 std::string string_value; | 190 std::string string_value; |
| 193 if (value->GetString(0, &string_value)) | 191 if (value->GetString(0, &string_value)) |
| 194 return base::StringToInt(string_value, out_int); | 192 return base::StringToInt(string_value, out_int); |
| 195 NOTREACHED(); | 193 NOTREACHED(); |
| 196 return false; | 194 return false; |
| 197 } | 195 } |
| 198 | 196 |
| 199 // TODO(viettrungluu): convert to string16 (or UTF-8 std::string?). | 197 // TODO(viettrungluu): convert to string16 (or UTF-8 std::string?). |
| 200 std::wstring DOMMessageHandler::ExtractStringValue(const ListValue* value) { | 198 std::wstring DOMMessageHandler::ExtractStringValue(const ListValue* value) { |
| 201 string16 string16_value; | 199 string16 string16_value; |
| 202 if (value->GetString(0, &string16_value)) | 200 if (value->GetString(0, &string16_value)) |
| 203 return UTF16ToWideHack(string16_value); | 201 return UTF16ToWideHack(string16_value); |
| 204 NOTREACHED(); | 202 NOTREACHED(); |
| 205 return std::wstring(); | 203 return std::wstring(); |
| 206 } | 204 } |
| OLD | NEW |