Chromium Code Reviews| Index: chrome/browser/dom_ui/dom_ui.cc |
| =================================================================== |
| --- chrome/browser/dom_ui/dom_ui.cc (revision 9684) |
| +++ chrome/browser/dom_ui/dom_ui.cc (working copy) |
| @@ -47,6 +47,11 @@ |
| callback->second->Run(value.get()); |
| } |
| +void DOMUI::CallJavascriptFunction(const std::wstring& function_name) { |
| + std::wstring javascript = function_name + L"();"; |
| + ExecuteJavascript(javascript); |
| +} |
| + |
| void DOMUI::CallJavascriptFunction(const std::wstring& function_name, |
| const Value& arg) { |
| std::string json; |
| @@ -122,4 +127,41 @@ |
| } |
| } |
| dictionary->SetString(L"title", title_to_set); |
| -} |
| +} |
| + |
| +int DOMMessageHandler::ExtractIntegerValue(const Value* value) { |
| + if (value && value->GetType() == Value::TYPE_LIST) { |
| + const ListValue* list_value = static_cast<const ListValue*>(value); |
| + Value* list_member; |
| + |
| + // Get id. |
| + if (list_value->Get(0, &list_member) && |
| + list_member->GetType() == Value::TYPE_STRING) { |
| + const StringValue* string_value = |
| + static_cast<const StringValue*>(list_member); |
| + std::wstring wstring_value; |
| + string_value->GetAsString(&wstring_value); |
| + return StringToInt(wstring_value); |
| + } |
| + } |
| + return NULL; |
|
Paul Godavari
2009/02/17 22:23:19
Nit: I think this should return some default value
|
| +} |
| + |
| +std::wstring DOMMessageHandler::ExtractStringValue(const Value* value) { |
| + if (value && value->GetType() == Value::TYPE_LIST) { |
| + const ListValue* list_value = static_cast<const ListValue*>(value); |
| + Value* list_member; |
| + |
| + // Get id. |
| + if (list_value->Get(0, &list_member) && |
| + list_member->GetType() == Value::TYPE_STRING) { |
| + const StringValue* string_value = |
| + static_cast<const StringValue*>(list_member); |
| + std::wstring wstring_value; |
| + string_value->GetAsString(&wstring_value); |
| + return wstring_value; |
| + } |
| + } |
| + return std::wstring(); |
| +} |
| + |