| OLD | NEW |
| 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/json_writer.h" |
| 9 #include "base/json_writer.h" | |
| 10 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 11 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 12 #include "base/values.h" | 11 #include "base/values.h" |
| 13 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/profile.h" |
| 14 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
| 15 #include "chrome/browser/tab_contents/tab_contents_view.h" | 14 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 16 #include "chrome/common/bindings_policy.h" | 15 #include "chrome/common/bindings_policy.h" |
| 17 | 16 |
| 18 DOMUI::DOMUI(TabContents* contents) | 17 DOMUI::DOMUI(TabContents* contents) |
| 19 : hide_favicon_(false), | 18 : hide_favicon_(false), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 49 } | 48 } |
| 50 | 49 |
| 51 void DOMUI::CallJavascriptFunction(const std::wstring& function_name) { | 50 void DOMUI::CallJavascriptFunction(const std::wstring& function_name) { |
| 52 std::wstring javascript = function_name + L"();"; | 51 std::wstring javascript = function_name + L"();"; |
| 53 ExecuteJavascript(javascript); | 52 ExecuteJavascript(javascript); |
| 54 } | 53 } |
| 55 | 54 |
| 56 void DOMUI::CallJavascriptFunction(const std::wstring& function_name, | 55 void DOMUI::CallJavascriptFunction(const std::wstring& function_name, |
| 57 const Value& arg) { | 56 const Value& arg) { |
| 58 std::string json; | 57 std::string json; |
| 59 JSONWriter::Write(&arg, false, &json); | 58 base::JSONWriter::Write(&arg, false, &json); |
| 60 std::wstring javascript = function_name + L"(" + UTF8ToWide(json) + L");"; | 59 std::wstring javascript = function_name + L"(" + UTF8ToWide(json) + L");"; |
| 61 | 60 |
| 62 ExecuteJavascript(javascript); | 61 ExecuteJavascript(javascript); |
| 63 } | 62 } |
| 64 | 63 |
| 65 void DOMUI::CallJavascriptFunction( | 64 void DOMUI::CallJavascriptFunction( |
| 66 const std::wstring& function_name, | 65 const std::wstring& function_name, |
| 67 const Value& arg1, const Value& arg2) { | 66 const Value& arg1, const Value& arg2) { |
| 68 std::string json; | 67 std::string json; |
| 69 JSONWriter::Write(&arg1, false, &json); | 68 base::JSONWriter::Write(&arg1, false, &json); |
| 70 std::wstring javascript = function_name + L"(" + UTF8ToWide(json); | 69 std::wstring javascript = function_name + L"(" + UTF8ToWide(json); |
| 71 JSONWriter::Write(&arg2, false, &json); | 70 base::JSONWriter::Write(&arg2, false, &json); |
| 72 javascript += L"," + UTF8ToWide(json) + L");"; | 71 javascript += L"," + UTF8ToWide(json) + L");"; |
| 73 | 72 |
| 74 ExecuteJavascript(javascript); | 73 ExecuteJavascript(javascript); |
| 75 } | 74 } |
| 76 | 75 |
| 77 ThemeProvider* DOMUI::GetThemeProvider() const { | 76 ThemeProvider* DOMUI::GetThemeProvider() const { |
| 78 return tab_contents_->profile()->GetThemeProvider(); | 77 return tab_contents_->profile()->GetThemeProvider(); |
| 79 } | 78 } |
| 80 | 79 |
| 81 void DOMUI::RegisterMessageCallback(const std::string &message, | 80 void DOMUI::RegisterMessageCallback(const std::string &message, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 list_member->GetType() == Value::TYPE_STRING) { | 169 list_member->GetType() == Value::TYPE_STRING) { |
| 171 const StringValue* string_value = | 170 const StringValue* string_value = |
| 172 static_cast<const StringValue*>(list_member); | 171 static_cast<const StringValue*>(list_member); |
| 173 std::wstring wstring_value; | 172 std::wstring wstring_value; |
| 174 string_value->GetAsString(&wstring_value); | 173 string_value->GetAsString(&wstring_value); |
| 175 return wstring_value; | 174 return wstring_value; |
| 176 } | 175 } |
| 177 } | 176 } |
| 178 return std::wstring(); | 177 return std::wstring(); |
| 179 } | 178 } |
| OLD | NEW |