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 "chrome/test/chromedriver/commands.h" | 5 #include "chrome/test/chromedriver/commands.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 std::string script; | 98 std::string script; |
99 if (!params.GetString("script", &script)) | 99 if (!params.GetString("script", &script)) |
100 return Status(kUnknownError, "'script' must be a string"); | 100 return Status(kUnknownError, "'script' must be a string"); |
101 const base::ListValue* args; | 101 const base::ListValue* args; |
102 if (!params.GetList("args", &args)) | 102 if (!params.GetList("args", &args)) |
103 return Status(kUnknownError, "'args' must be a list"); | 103 return Status(kUnknownError, "'args' must be a list"); |
104 | 104 |
105 return session->chrome->CallFunction( | 105 return session->chrome->CallFunction( |
106 "function(){" + script + "}", *args, value); | 106 "function(){" + script + "}", *args, value); |
107 } | 107 } |
| 108 |
| 109 Status ExecuteGetTitle( |
| 110 Session* session, |
| 111 const base::DictionaryValue& params, |
| 112 scoped_ptr<base::Value>* value) { |
| 113 const char* kGetTitleScript = |
| 114 "function() {" |
| 115 " if (document.title)" |
| 116 " return document.title;" |
| 117 " else" |
| 118 " return document.URL;" |
| 119 "}"; |
| 120 base::ListValue args; |
| 121 return session->chrome->CallFunction( |
| 122 kGetTitleScript, args, value); |
| 123 } |
OLD | NEW |