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

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

Issue 251093: Modify extension request IPC messages to pass a ListValue instead of a string. (Closed)
Patch Set: notreached messages Created 11 years, 2 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
« no previous file with comments | « chrome/browser/dom_ui/dom_ui.h ('k') | chrome/browser/extensions/extension_dom_ui.h » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/json_reader.h" 8 #include "base/json_reader.h"
9 #include "base/json_writer.h" 9 #include "base/json_writer.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 17 matching lines...) Expand all
28 28
29 DOMUI::~DOMUI() { 29 DOMUI::~DOMUI() {
30 STLDeleteContainerPairSecondPointers(message_callbacks_.begin(), 30 STLDeleteContainerPairSecondPointers(message_callbacks_.begin(),
31 message_callbacks_.end()); 31 message_callbacks_.end());
32 STLDeleteContainerPointers(handlers_.begin(), handlers_.end()); 32 STLDeleteContainerPointers(handlers_.begin(), handlers_.end());
33 } 33 }
34 34
35 // DOMUI, public: ------------------------------------------------------------- 35 // DOMUI, public: -------------------------------------------------------------
36 36
37 void DOMUI::ProcessDOMUIMessage(const std::string& message, 37 void DOMUI::ProcessDOMUIMessage(const std::string& message,
38 const std::string& content, 38 const Value* content,
39 int request_id, 39 int request_id,
40 bool has_callback) { 40 bool has_callback) {
41 // Look up the callback for this message. 41 // Look up the callback for this message.
42 MessageCallbackMap::const_iterator callback = 42 MessageCallbackMap::const_iterator callback =
43 message_callbacks_.find(message); 43 message_callbacks_.find(message);
44 if (callback == message_callbacks_.end()) 44 if (callback == message_callbacks_.end())
45 return; 45 return;
46 46
47 // Convert the content JSON into a Value.
48 scoped_ptr<Value> value;
49 if (!content.empty()) {
50 value.reset(JSONReader::Read(content, false));
51 if (!value.get()) {
52 // The page sent us something that we didn't understand.
53 // This probably indicates a programming error.
54 NOTREACHED();
55 return;
56 }
57 }
58
59 // Forward this message and content on. 47 // Forward this message and content on.
60 callback->second->Run(value.get()); 48 callback->second->Run(content);
61 } 49 }
62 50
63 void DOMUI::CallJavascriptFunction(const std::wstring& function_name) { 51 void DOMUI::CallJavascriptFunction(const std::wstring& function_name) {
64 std::wstring javascript = function_name + L"();"; 52 std::wstring javascript = function_name + L"();";
65 ExecuteJavascript(javascript); 53 ExecuteJavascript(javascript);
66 } 54 }
67 55
68 void DOMUI::CallJavascriptFunction(const std::wstring& function_name, 56 void DOMUI::CallJavascriptFunction(const std::wstring& function_name,
69 const Value& arg) { 57 const Value& arg) {
70 std::string json; 58 std::string json;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 list_member->GetType() == Value::TYPE_STRING) { 170 list_member->GetType() == Value::TYPE_STRING) {
183 const StringValue* string_value = 171 const StringValue* string_value =
184 static_cast<const StringValue*>(list_member); 172 static_cast<const StringValue*>(list_member);
185 std::wstring wstring_value; 173 std::wstring wstring_value;
186 string_value->GetAsString(&wstring_value); 174 string_value->GetAsString(&wstring_value);
187 return wstring_value; 175 return wstring_value;
188 } 176 }
189 } 177 }
190 return std::wstring(); 178 return std::wstring();
191 } 179 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/dom_ui.h ('k') | chrome/browser/extensions/extension_dom_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698