| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/webui/web_ui_impl.h" | 5 #include "content/browser/webui/web_ui_impl.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 WebUIController* WebUIImpl::GetController() const { | 133 WebUIController* WebUIImpl::GetController() const { |
| 134 return controller_.get(); | 134 return controller_.get(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void WebUIImpl::SetController(WebUIController* controller) { | 137 void WebUIImpl::SetController(WebUIController* controller) { |
| 138 controller_.reset(controller); | 138 controller_.reset(controller); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void WebUIImpl::CallJavascriptFunction(const std::string& function_name) { | 141 void WebUIImpl::CallJavascriptFunction(const std::string& function_name) { |
| 142 DCHECK(IsStringASCII(function_name)); | 142 DCHECK(base::IsStringASCII(function_name)); |
| 143 base::string16 javascript = base::ASCIIToUTF16(function_name + "();"); | 143 base::string16 javascript = base::ASCIIToUTF16(function_name + "();"); |
| 144 ExecuteJavascript(javascript); | 144 ExecuteJavascript(javascript); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void WebUIImpl::CallJavascriptFunction(const std::string& function_name, | 147 void WebUIImpl::CallJavascriptFunction(const std::string& function_name, |
| 148 const base::Value& arg) { | 148 const base::Value& arg) { |
| 149 DCHECK(IsStringASCII(function_name)); | 149 DCHECK(base::IsStringASCII(function_name)); |
| 150 std::vector<const base::Value*> args; | 150 std::vector<const base::Value*> args; |
| 151 args.push_back(&arg); | 151 args.push_back(&arg); |
| 152 ExecuteJavascript(GetJavascriptCall(function_name, args)); | 152 ExecuteJavascript(GetJavascriptCall(function_name, args)); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void WebUIImpl::CallJavascriptFunction( | 155 void WebUIImpl::CallJavascriptFunction( |
| 156 const std::string& function_name, | 156 const std::string& function_name, |
| 157 const base::Value& arg1, const base::Value& arg2) { | 157 const base::Value& arg1, const base::Value& arg2) { |
| 158 DCHECK(IsStringASCII(function_name)); | 158 DCHECK(base::IsStringASCII(function_name)); |
| 159 std::vector<const base::Value*> args; | 159 std::vector<const base::Value*> args; |
| 160 args.push_back(&arg1); | 160 args.push_back(&arg1); |
| 161 args.push_back(&arg2); | 161 args.push_back(&arg2); |
| 162 ExecuteJavascript(GetJavascriptCall(function_name, args)); | 162 ExecuteJavascript(GetJavascriptCall(function_name, args)); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void WebUIImpl::CallJavascriptFunction( | 165 void WebUIImpl::CallJavascriptFunction( |
| 166 const std::string& function_name, | 166 const std::string& function_name, |
| 167 const base::Value& arg1, const base::Value& arg2, const base::Value& arg3) { | 167 const base::Value& arg1, const base::Value& arg2, const base::Value& arg3) { |
| 168 DCHECK(IsStringASCII(function_name)); | 168 DCHECK(base::IsStringASCII(function_name)); |
| 169 std::vector<const base::Value*> args; | 169 std::vector<const base::Value*> args; |
| 170 args.push_back(&arg1); | 170 args.push_back(&arg1); |
| 171 args.push_back(&arg2); | 171 args.push_back(&arg2); |
| 172 args.push_back(&arg3); | 172 args.push_back(&arg3); |
| 173 ExecuteJavascript(GetJavascriptCall(function_name, args)); | 173 ExecuteJavascript(GetJavascriptCall(function_name, args)); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void WebUIImpl::CallJavascriptFunction( | 176 void WebUIImpl::CallJavascriptFunction( |
| 177 const std::string& function_name, | 177 const std::string& function_name, |
| 178 const base::Value& arg1, | 178 const base::Value& arg1, |
| 179 const base::Value& arg2, | 179 const base::Value& arg2, |
| 180 const base::Value& arg3, | 180 const base::Value& arg3, |
| 181 const base::Value& arg4) { | 181 const base::Value& arg4) { |
| 182 DCHECK(IsStringASCII(function_name)); | 182 DCHECK(base::IsStringASCII(function_name)); |
| 183 std::vector<const base::Value*> args; | 183 std::vector<const base::Value*> args; |
| 184 args.push_back(&arg1); | 184 args.push_back(&arg1); |
| 185 args.push_back(&arg2); | 185 args.push_back(&arg2); |
| 186 args.push_back(&arg3); | 186 args.push_back(&arg3); |
| 187 args.push_back(&arg4); | 187 args.push_back(&arg4); |
| 188 ExecuteJavascript(GetJavascriptCall(function_name, args)); | 188 ExecuteJavascript(GetJavascriptCall(function_name, args)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void WebUIImpl::CallJavascriptFunction( | 191 void WebUIImpl::CallJavascriptFunction( |
| 192 const std::string& function_name, | 192 const std::string& function_name, |
| 193 const std::vector<const base::Value*>& args) { | 193 const std::vector<const base::Value*>& args) { |
| 194 DCHECK(IsStringASCII(function_name)); | 194 DCHECK(base::IsStringASCII(function_name)); |
| 195 ExecuteJavascript(GetJavascriptCall(function_name, args)); | 195 ExecuteJavascript(GetJavascriptCall(function_name, args)); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void WebUIImpl::RegisterMessageCallback(const std::string &message, | 198 void WebUIImpl::RegisterMessageCallback(const std::string &message, |
| 199 const MessageCallback& callback) { | 199 const MessageCallback& callback) { |
| 200 message_callbacks_.insert(std::make_pair(message, callback)); | 200 message_callbacks_.insert(std::make_pair(message, callback)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void WebUIImpl::ProcessWebUIMessage(const GURL& source_url, | 203 void WebUIImpl::ProcessWebUIMessage(const GURL& source_url, |
| 204 const std::string& message, | 204 const std::string& message, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 250 } |
| 251 | 251 |
| 252 void WebUIImpl::AddToSetIfFrameNameMatches( | 252 void WebUIImpl::AddToSetIfFrameNameMatches( |
| 253 std::set<RenderFrameHost*>* frame_set, | 253 std::set<RenderFrameHost*>* frame_set, |
| 254 RenderFrameHost* host) { | 254 RenderFrameHost* host) { |
| 255 if (host->GetFrameName() == frame_name_) | 255 if (host->GetFrameName() == frame_name_) |
| 256 frame_set->insert(host); | 256 frame_set->insert(host); |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace content | 259 } // namespace content |
| OLD | NEW |