OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/automation/tab_proxy.h" | 5 #include "chrome/test/automation/tab_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string16.h" |
10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
11 #include "chrome/common/json_value_serializer.h" | 12 #include "chrome/common/json_value_serializer.h" |
12 #include "chrome/test/automation/automation_constants.h" | 13 #include "chrome/test/automation/automation_constants.h" |
13 #include "chrome/test/automation/automation_messages.h" | 14 #include "chrome/test/automation/automation_messages.h" |
14 #include "chrome/test/automation/automation_proxy.h" | 15 #include "chrome/test/automation/automation_proxy.h" |
15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
16 | 17 |
17 bool TabProxy::GetTabTitle(std::wstring* title) const { | 18 bool TabProxy::GetTabTitle(std::wstring* title) const { |
18 if (!is_valid()) | 19 if (!is_valid()) |
19 return false; | 20 return false; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 250 } |
250 | 251 |
251 bool TabProxy::ExecuteAndExtractString(const std::wstring& frame_xpath, | 252 bool TabProxy::ExecuteAndExtractString(const std::wstring& frame_xpath, |
252 const std::wstring& jscript, | 253 const std::wstring& jscript, |
253 std::wstring* string_value) { | 254 std::wstring* string_value) { |
254 Value* root = NULL; | 255 Value* root = NULL; |
255 bool succeeded = ExecuteAndExtractValue(frame_xpath, jscript, &root); | 256 bool succeeded = ExecuteAndExtractValue(frame_xpath, jscript, &root); |
256 if (!succeeded) | 257 if (!succeeded) |
257 return false; | 258 return false; |
258 | 259 |
259 std::wstring read_value; | |
260 DCHECK(root->IsType(Value::TYPE_LIST)); | 260 DCHECK(root->IsType(Value::TYPE_LIST)); |
261 Value* value = NULL; | 261 Value* value = NULL; |
262 succeeded = static_cast<ListValue*>(root)->Get(0, &value); | 262 succeeded = static_cast<ListValue*>(root)->Get(0, &value); |
263 if (succeeded) { | 263 if (succeeded) { |
| 264 string16 read_value; |
264 succeeded = value->GetAsString(&read_value); | 265 succeeded = value->GetAsString(&read_value); |
265 if (succeeded) { | 266 if (succeeded) { |
266 string_value->swap(read_value); | 267 // TODO(viettrungluu): remove conversion. (But should |jscript| be UTF-8?) |
| 268 *string_value = UTF16ToWideHack(read_value); |
267 } | 269 } |
268 } | 270 } |
269 | 271 |
270 delete root; | 272 delete root; |
271 return succeeded; | 273 return succeeded; |
272 } | 274 } |
273 | 275 |
274 bool TabProxy::ExecuteAndExtractBool(const std::wstring& frame_xpath, | 276 bool TabProxy::ExecuteAndExtractBool(const std::wstring& frame_xpath, |
275 const std::wstring& jscript, | 277 const std::wstring& jscript, |
276 bool* bool_value) { | 278 bool* bool_value) { |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 json)); | 816 json)); |
815 } | 817 } |
816 | 818 |
817 void TabProxy::FirstObjectAdded() { | 819 void TabProxy::FirstObjectAdded() { |
818 AddRef(); | 820 AddRef(); |
819 } | 821 } |
820 | 822 |
821 void TabProxy::LastObjectRemoved() { | 823 void TabProxy::LastObjectRemoved() { |
822 Release(); | 824 Release(); |
823 } | 825 } |
OLD | NEW |