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

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

Issue 16270: Change the signature of JSONReader::Read() and related methods to be more (Closed)
Patch Set: fixens Created 11 years, 11 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
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 "chrome/common/l10n_util.h" 9 #include "chrome/common/l10n_util.h"
10 10
(...skipping 13 matching lines...) Expand all
24 24
25 void DOMUI::ProcessDOMUIMessage(const std::string& message, 25 void DOMUI::ProcessDOMUIMessage(const std::string& message,
26 const std::string& content) { 26 const std::string& content) {
27 // Look up the callback for this message. 27 // Look up the callback for this message.
28 MessageCallbackMap::const_iterator callback = 28 MessageCallbackMap::const_iterator callback =
29 message_callbacks_.find(message); 29 message_callbacks_.find(message);
30 if (callback == message_callbacks_.end()) 30 if (callback == message_callbacks_.end())
31 return; 31 return;
32 32
33 // Convert the content JSON into a Value. 33 // Convert the content JSON into a Value.
34 Value* value = NULL; 34 scoped_ptr<Value> value;
35 if (!content.empty()) { 35 if (!content.empty()) {
36 if (!JSONReader::Read(content, &value, false)) { 36 value.reset(JSONReader::Read(content, false));
37 if (!value.get()) {
37 // The page sent us something that we didn't understand. 38 // The page sent us something that we didn't understand.
38 // This probably indicates a programming error. 39 // This probably indicates a programming error.
39 NOTREACHED(); 40 NOTREACHED();
40 return; 41 return;
41 } 42 }
42 } 43 }
43 44
44 // Forward this message and content on. 45 // Forward this message and content on.
45 callback->second->Run(value); 46 callback->second->Run(value.get());
46 delete value;
47 } 47 }
48 48
49 void DOMUI::CallJavascriptFunction(const std::wstring& function_name, 49 void DOMUI::CallJavascriptFunction(const std::wstring& function_name,
50 const Value& arg) { 50 const Value& arg) {
51 std::string json; 51 std::string json;
52 JSONWriter::Write(&arg, false, &json); 52 JSONWriter::Write(&arg, false, &json);
53 std::wstring javascript = function_name + L"(" + UTF8ToWide(json) + L");"; 53 std::wstring javascript = function_name + L"(" + UTF8ToWide(json) + L");";
54 54
55 ExecuteJavascript(javascript); 55 ExecuteJavascript(javascript);
56 } 56 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (using_url_as_the_title) { 115 if (using_url_as_the_title) {
116 l10n_util::WrapStringWithLTRFormatting(&title_to_set); 116 l10n_util::WrapStringWithLTRFormatting(&title_to_set);
117 } else { 117 } else {
118 bool success = 118 bool success =
119 l10n_util::AdjustStringForLocaleDirection(title, &title_to_set); 119 l10n_util::AdjustStringForLocaleDirection(title, &title_to_set);
120 DCHECK(success ? (title != title_to_set) : (title == title_to_set)); 120 DCHECK(success ? (title != title_to_set) : (title == title_to_set));
121 } 121 }
122 } 122 }
123 dictionary->SetString(L"title", title_to_set); 123 dictionary->SetString(L"title", title_to_set);
124 } 124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698