Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: chrome/browser/dom_ui/dom_ui.cc

Issue 31014: Port DictionaryValue to use string16 instead of wstring. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/dom_ui/history_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/json_reader.h" 7 #include "base/json_reader.h"
8 #include "base/json_writer.h" 8 #include "base/json_writer.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 DOMMessageHandler::DOMMessageHandler(DOMUI *dom_ui) : dom_ui_(dom_ui) { 105 DOMMessageHandler::DOMMessageHandler(DOMUI *dom_ui) : dom_ui_(dom_ui) {
106 } 106 }
107 107
108 // DOMMessageHandler, protected: ---------------------------------------------- 108 // DOMMessageHandler, protected: ----------------------------------------------
109 109
110 void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary, 110 void DOMMessageHandler::SetURLAndTitle(DictionaryValue* dictionary,
111 std::wstring title, 111 std::wstring title,
112 const GURL& gurl) { 112 const GURL& gurl) {
113 std::wstring wstring_url = UTF8ToWide(gurl.spec()); 113 std::wstring wstring_url = UTF8ToWide(gurl.spec());
114 dictionary->SetString(L"url", wstring_url); 114 dictionary->SetString(ASCIIToUTF16("url"), WideToUTF16Hack(wstring_url));
115 115
116 bool using_url_as_the_title = false; 116 bool using_url_as_the_title = false;
117 if (title.empty()) { 117 if (title.empty()) {
118 using_url_as_the_title = true; 118 using_url_as_the_title = true;
119 title = wstring_url; 119 title = wstring_url;
120 } 120 }
121 121
122 // Since the title can contain BiDi text, we need to mark the text as either 122 // Since the title can contain BiDi text, we need to mark the text as either
123 // RTL or LTR, depending on the characters in the string. If we use the URL 123 // RTL or LTR, depending on the characters in the string. If we use the URL
124 // as the title, we mark the title as LTR since URLs are always treated as 124 // as the title, we mark the title as LTR since URLs are always treated as
125 // left to right strings. 125 // left to right strings.
126 std::wstring title_to_set(title); 126 std::wstring title_to_set(title);
127 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { 127 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) {
128 if (using_url_as_the_title) { 128 if (using_url_as_the_title) {
129 l10n_util::WrapStringWithLTRFormatting(&title_to_set); 129 l10n_util::WrapStringWithLTRFormatting(&title_to_set);
130 } else { 130 } else {
131 bool success = 131 bool success =
132 l10n_util::AdjustStringForLocaleDirection(title, &title_to_set); 132 l10n_util::AdjustStringForLocaleDirection(title, &title_to_set);
133 DCHECK(success ? (title != title_to_set) : (title == title_to_set)); 133 DCHECK(success ? (title != title_to_set) : (title == title_to_set));
134 } 134 }
135 } 135 }
136 dictionary->SetString(L"title", title_to_set); 136 dictionary->SetString(ASCIIToUTF16("title"), WideToUTF16Hack(title_to_set));
137 } 137 }
138 138
139 bool DOMMessageHandler::ExtractIntegerValue(const Value* value, int* out_int) { 139 bool DOMMessageHandler::ExtractIntegerValue(const Value* value, int* out_int) {
140 if (value && value->GetType() == Value::TYPE_LIST) { 140 if (value && value->GetType() == Value::TYPE_LIST) {
141 const ListValue* list_value = static_cast<const ListValue*>(value); 141 const ListValue* list_value = static_cast<const ListValue*>(value);
142 Value* list_member; 142 Value* list_member;
143 143
144 // Get id. 144 // Get id.
145 if (list_value->Get(0, &list_member) && 145 if (list_value->Get(0, &list_member) &&
146 list_member->GetType() == Value::TYPE_STRING) { 146 list_member->GetType() == Value::TYPE_STRING) {
(...skipping 19 matching lines...) Expand all
166 list_member->GetType() == Value::TYPE_STRING) { 166 list_member->GetType() == Value::TYPE_STRING) {
167 const StringValue* string_value = 167 const StringValue* string_value =
168 static_cast<const StringValue*>(list_member); 168 static_cast<const StringValue*>(list_member);
169 std::wstring wstring_value; 169 std::wstring wstring_value;
170 string_value->GetAsString(&wstring_value); 170 string_value->GetAsString(&wstring_value);
171 return wstring_value; 171 return wstring_value;
172 } 172 }
173 } 173 }
174 return std::wstring(); 174 return std::wstring();
175 } 175 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/dom_ui/history_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698