| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/singleton.h" | 6 #include "base/memory/singleton.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // Executes the javascript synchronously and makes sure the returned value is | 268 // Executes the javascript synchronously and makes sure the returned value is |
| 269 // freed properly. | 269 // freed properly. |
| 270 void ExecuteSyncJSFunction(RenderViewHost* rvh, const std::string& jscript) { | 270 void ExecuteSyncJSFunction(RenderViewHost* rvh, const std::string& jscript) { |
| 271 scoped_ptr<base::Value> value = | 271 scoped_ptr<base::Value> value = |
| 272 content::ExecuteScriptAndGetValue(rvh, jscript); | 272 content::ExecuteScriptAndGetValue(rvh, jscript); |
| 273 } | 273 } |
| 274 | 274 |
| 275 bool IsAttributeNull(RenderViewHost* rvh, const std::string& attribute) { | 275 bool IsAttributeNull(RenderViewHost* rvh, const std::string& attribute) { |
| 276 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue(rvh, | 276 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue(rvh, |
| 277 "document.getElementById('plugin').getAttribute('" + attribute + "');"); | 277 "document.getElementById('plugin').getAttribute('" + attribute + "');"); |
| 278 return value->GetType() == Value::TYPE_NULL; | 278 return value->GetType() == base::Value::TYPE_NULL; |
| 279 } | 279 } |
| 280 | 280 |
| 281 // Removes all attributes in the comma-delimited string |attributes|. | 281 // Removes all attributes in the comma-delimited string |attributes|. |
| 282 void RemoveAttributes(RenderViewHost* rvh, const std::string& attributes) { | 282 void RemoveAttributes(RenderViewHost* rvh, const std::string& attributes) { |
| 283 std::vector<std::string> attributes_list; | 283 std::vector<std::string> attributes_list; |
| 284 base::SplitString(attributes, ',', &attributes_list); | 284 base::SplitString(attributes, ',', &attributes_list); |
| 285 std::vector<std::string>::const_iterator itr; | 285 std::vector<std::string>::const_iterator itr; |
| 286 for (itr = attributes_list.begin(); itr != attributes_list.end(); ++itr) { | 286 for (itr = attributes_list.begin(); itr != attributes_list.end(); ++itr) { |
| 287 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin')" | 287 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin')" |
| 288 "." + *itr + " = null;"); | 288 "." + *itr + " = null;"); |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 scoped_ptr<base::Value> value = | 1030 scoped_ptr<base::Value> value = |
| 1031 content::ExecuteScriptAndGetValue( | 1031 content::ExecuteScriptAndGetValue( |
| 1032 guest_rvh, "document.getElementById('input1').value"); | 1032 guest_rvh, "document.getElementById('input1').value"); |
| 1033 std::string actual_value; | 1033 std::string actual_value; |
| 1034 ASSERT_TRUE(value->GetAsString(&actual_value)); | 1034 ASSERT_TRUE(value->GetAsString(&actual_value)); |
| 1035 EXPECT_EQ(UTF16ToUTF8(expected_value), actual_value); | 1035 EXPECT_EQ(UTF16ToUTF8(expected_value), actual_value); |
| 1036 } | 1036 } |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 } // namespace content | 1039 } // namespace content |
| OLD | NEW |