Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: chrome/test/automation/browser_proxy.cc

Issue 5998006: Clean up Automation and Chrome Frame IPC code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser_proxy.h" 5 #include "chrome/test/automation/browser_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 11 matching lines...) Expand all
22 using base::TimeTicks; 22 using base::TimeTicks;
23 23
24 24
25 bool BrowserProxy::ActivateTab(int tab_index) { 25 bool BrowserProxy::ActivateTab(int tab_index) {
26 if (!is_valid()) 26 if (!is_valid())
27 return false; 27 return false;
28 28
29 int activate_tab_response = -1; 29 int activate_tab_response = -1;
30 30
31 if (!sender_->Send(new AutomationMsg_ActivateTab( 31 if (!sender_->Send(new AutomationMsg_ActivateTab(
32 0, handle_, tab_index, &activate_tab_response))) { 32 handle_, tab_index, &activate_tab_response))) {
33 return false; 33 return false;
34 } 34 }
35 35
36 if (activate_tab_response >= 0) 36 if (activate_tab_response >= 0)
37 return true; 37 return true;
38 38
39 return false; 39 return false;
40 } 40 }
41 41
42 bool BrowserProxy::BringToFront() { 42 bool BrowserProxy::BringToFront() {
43 if (!is_valid()) 43 if (!is_valid())
44 return false; 44 return false;
45 45
46 bool succeeded = false; 46 bool succeeded = false;
47 47
48 if (!sender_->Send(new AutomationMsg_BringBrowserToFront( 48 if (!sender_->Send(new AutomationMsg_BringBrowserToFront(
49 0, handle_, &succeeded))) { 49 handle_, &succeeded))) {
50 return false; 50 return false;
51 } 51 }
52 52
53 return succeeded; 53 return succeeded;
54 } 54 }
55 55
56 bool BrowserProxy::IsMenuCommandEnabled(int id, bool* enabled) { 56 bool BrowserProxy::IsMenuCommandEnabled(int id, bool* enabled) {
57 if (!is_valid()) 57 if (!is_valid())
58 return false; 58 return false;
59 59
60 return sender_->Send(new AutomationMsg_IsMenuCommandEnabled(0, handle_, id, 60 return sender_->Send(new AutomationMsg_IsMenuCommandEnabled(handle_, id,
61 enabled)); 61 enabled));
62 } 62 }
63 63
64 bool BrowserProxy::AppendTab(const GURL& tab_url) { 64 bool BrowserProxy::AppendTab(const GURL& tab_url) {
65 if (!is_valid()) 65 if (!is_valid())
66 return false; 66 return false;
67 67
68 int append_tab_response = -1; 68 int append_tab_response = -1;
69 69
70 sender_->Send(new AutomationMsg_AppendTab(0, handle_, tab_url, 70 sender_->Send(new AutomationMsg_AppendTab(handle_, tab_url,
71 &append_tab_response)); 71 &append_tab_response));
72 return append_tab_response >= 0; 72 return append_tab_response >= 0;
73 } 73 }
74 74
75 bool BrowserProxy::GetActiveTabIndex(int* active_tab_index) const { 75 bool BrowserProxy::GetActiveTabIndex(int* active_tab_index) const {
76 if (!is_valid()) 76 if (!is_valid())
77 return false; 77 return false;
78 78
79 if (!active_tab_index) { 79 if (!active_tab_index) {
80 NOTREACHED(); 80 NOTREACHED();
81 return false; 81 return false;
82 } 82 }
83 83
84 int active_tab_index_response = -1; 84 int active_tab_index_response = -1;
85 85
86 if (!sender_->Send(new AutomationMsg_ActiveTabIndex( 86 if (!sender_->Send(new AutomationMsg_ActiveTabIndex(
87 0, handle_, &active_tab_index_response))) { 87 handle_, &active_tab_index_response))) {
88 return false; 88 return false;
89 } 89 }
90 90
91 if (active_tab_index_response >= 0) { 91 if (active_tab_index_response >= 0) {
92 *active_tab_index = active_tab_index_response; 92 *active_tab_index = active_tab_index_response;
93 return true; 93 return true;
94 } 94 }
95 95
96 return false; 96 return false;
97 } 97 }
98 98
99 scoped_refptr<TabProxy> BrowserProxy::GetTab(int tab_index) const { 99 scoped_refptr<TabProxy> BrowserProxy::GetTab(int tab_index) const {
100 if (!is_valid()) 100 if (!is_valid())
101 return NULL; 101 return NULL;
102 102
103 int tab_handle = 0; 103 int tab_handle = 0;
104 104
105 sender_->Send(new AutomationMsg_Tab(0, handle_, tab_index, &tab_handle)); 105 sender_->Send(new AutomationMsg_Tab(handle_, tab_index, &tab_handle));
106 if (!tab_handle) 106 if (!tab_handle)
107 return NULL; 107 return NULL;
108 108
109 TabProxy* tab = static_cast<TabProxy*>(tracker_->GetResource(tab_handle)); 109 TabProxy* tab = static_cast<TabProxy*>(tracker_->GetResource(tab_handle));
110 if (!tab) { 110 if (!tab) {
111 tab = new TabProxy(sender_, tracker_, tab_handle); 111 tab = new TabProxy(sender_, tracker_, tab_handle);
112 tab->AddRef(); 112 tab->AddRef();
113 } 113 }
114 114
115 // Since there is no scoped_refptr::attach. 115 // Since there is no scoped_refptr::attach.
(...skipping 14 matching lines...) Expand all
130 return false; 130 return false;
131 131
132 if (!num_tabs) { 132 if (!num_tabs) {
133 NOTREACHED(); 133 NOTREACHED();
134 return false; 134 return false;
135 } 135 }
136 136
137 int tab_count_response = -1; 137 int tab_count_response = -1;
138 138
139 if (!sender_->Send(new AutomationMsg_TabCount( 139 if (!sender_->Send(new AutomationMsg_TabCount(
140 0, handle_, &tab_count_response))) { 140 handle_, &tab_count_response))) {
141 return false; 141 return false;
142 } 142 }
143 143
144 if (tab_count_response >= 0) { 144 if (tab_count_response >= 0) {
145 *num_tabs = tab_count_response; 145 *num_tabs = tab_count_response;
146 return true; 146 return true;
147 } 147 }
148 148
149 return false; 149 return false;
150 } 150 }
151 151
152 bool BrowserProxy::GetType(Browser::Type* type) const { 152 bool BrowserProxy::GetType(Browser::Type* type) const {
153 if (!is_valid()) 153 if (!is_valid())
154 return false; 154 return false;
155 155
156 if (!type) { 156 if (!type) {
157 NOTREACHED(); 157 NOTREACHED();
158 return false; 158 return false;
159 } 159 }
160 160
161 int type_as_int; 161 int type_as_int;
162 if (!sender_->Send(new AutomationMsg_Type(0, handle_, &type_as_int))) 162 if (!sender_->Send(new AutomationMsg_Type(handle_, &type_as_int)))
163 return false; 163 return false;
164 164
165 *type = static_cast<Browser::Type>(type_as_int); 165 *type = static_cast<Browser::Type>(type_as_int);
166 return true; 166 return true;
167 } 167 }
168 168
169 bool BrowserProxy::ApplyAccelerator(int id) { 169 bool BrowserProxy::ApplyAccelerator(int id) {
170 return RunCommandAsync(id); 170 return RunCommandAsync(id);
171 } 171 }
172 172
173 bool BrowserProxy::SimulateDrag(const gfx::Point& start, 173 bool BrowserProxy::SimulateDrag(const gfx::Point& start,
174 const gfx::Point& end, 174 const gfx::Point& end,
175 int flags, 175 int flags,
176 bool press_escape_en_route) { 176 bool press_escape_en_route) {
177 if (!is_valid()) 177 if (!is_valid())
178 return false; 178 return false;
179 179
180 std::vector<gfx::Point> drag_path; 180 std::vector<gfx::Point> drag_path;
181 drag_path.push_back(start); 181 drag_path.push_back(start);
182 drag_path.push_back(end); 182 drag_path.push_back(end);
183 183
184 bool result = false; 184 bool result = false;
185 185
186 if (!sender_->Send(new AutomationMsg_WindowDrag( 186 if (!sender_->Send(new AutomationMsg_WindowDrag(
187 0, handle_, drag_path, flags, press_escape_en_route, &result))) { 187 handle_, drag_path, flags, press_escape_en_route, &result))) {
188 return false; 188 return false;
189 } 189 }
190 190
191 return result; 191 return result;
192 } 192 }
193 193
194 bool BrowserProxy::WaitForTabCountToBecome(int count) { 194 bool BrowserProxy::WaitForTabCountToBecome(int count) {
195 bool success = false; 195 bool success = false;
196 if (!sender_->Send(new AutomationMsg_WaitForTabCountToBecome( 196 if (!sender_->Send(new AutomationMsg_WaitForTabCountToBecome(
197 0, handle_, count, &success))) { 197 handle_, count, &success))) {
198 return false; 198 return false;
199 } 199 }
200 200
201 return success; 201 return success;
202 } 202 }
203 203
204 bool BrowserProxy::WaitForTabToBecomeActive(int tab, 204 bool BrowserProxy::WaitForTabToBecomeActive(int tab,
205 int wait_timeout) { 205 int wait_timeout) {
206 const TimeTicks start = TimeTicks::Now(); 206 const TimeTicks start = TimeTicks::Now();
207 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); 207 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout);
208 while (TimeTicks::Now() - start < timeout) { 208 while (TimeTicks::Now() - start < timeout) {
209 PlatformThread::Sleep(automation::kSleepTime); 209 PlatformThread::Sleep(automation::kSleepTime);
210 int active_tab; 210 int active_tab;
211 if (GetActiveTabIndex(&active_tab) && active_tab == tab) 211 if (GetActiveTabIndex(&active_tab) && active_tab == tab)
212 return true; 212 return true;
213 } 213 }
214 // If we get here, the active tab hasn't changed. 214 // If we get here, the active tab hasn't changed.
215 return false; 215 return false;
216 } 216 }
217 217
218 bool BrowserProxy::OpenFindInPage() { 218 bool BrowserProxy::OpenFindInPage() {
219 if (!is_valid()) 219 if (!is_valid())
220 return false; 220 return false;
221 221
222 return sender_->Send(new AutomationMsg_OpenFindInPage(0, handle_)); 222 return sender_->Send(new AutomationMsg_OpenFindInPage(handle_));
223 // This message expects no response. 223 // This message expects no response.
224 } 224 }
225 225
226 bool BrowserProxy::GetFindWindowLocation(int* x, int* y) { 226 bool BrowserProxy::GetFindWindowLocation(int* x, int* y) {
227 if (!is_valid() || !x || !y) 227 if (!is_valid() || !x || !y)
228 return false; 228 return false;
229 229
230 return sender_->Send( 230 return sender_->Send(new AutomationMsg_FindWindowLocation(handle_, x, y));
231 new AutomationMsg_FindWindowLocation(0, handle_, x, y));
232 } 231 }
233 232
234 bool BrowserProxy::IsFindWindowFullyVisible(bool* is_visible) { 233 bool BrowserProxy::IsFindWindowFullyVisible(bool* is_visible) {
235 if (!is_valid()) 234 if (!is_valid())
236 return false; 235 return false;
237 236
238 if (!is_visible) { 237 if (!is_visible) {
239 NOTREACHED(); 238 NOTREACHED();
240 return false; 239 return false;
241 } 240 }
242 241
243 return sender_->Send( 242 return sender_->Send(
244 new AutomationMsg_FindWindowVisibility(0, handle_, is_visible)); 243 new AutomationMsg_FindWindowVisibility(handle_, is_visible));
245 } 244 }
246 245
247 bool BrowserProxy::RunCommandAsync(int browser_command) const { 246 bool BrowserProxy::RunCommandAsync(int browser_command) const {
248 if (!is_valid()) 247 if (!is_valid())
249 return false; 248 return false;
250 249
251 bool result = false; 250 bool result = false;
252 251
253 sender_->Send(new AutomationMsg_WindowExecuteCommandAsync(0, handle_, 252 sender_->Send(new AutomationMsg_WindowExecuteCommandAsync(handle_,
254 browser_command, 253 browser_command,
255 &result)); 254 &result));
256 255
257 return result; 256 return result;
258 } 257 }
259 258
260 bool BrowserProxy::RunCommand(int browser_command) const { 259 bool BrowserProxy::RunCommand(int browser_command) const {
261 if (!is_valid()) 260 if (!is_valid())
262 return false; 261 return false;
263 262
264 bool result = false; 263 bool result = false;
265 264
266 sender_->Send(new AutomationMsg_WindowExecuteCommand(0, handle_, 265 sender_->Send(new AutomationMsg_WindowExecuteCommand(handle_,
267 browser_command, 266 browser_command,
268 &result)); 267 &result));
269 268
270 return result; 269 return result;
271 } 270 }
272 271
273 bool BrowserProxy::GetBookmarkBarVisibility(bool* is_visible, 272 bool BrowserProxy::GetBookmarkBarVisibility(bool* is_visible,
274 bool* is_animating) { 273 bool* is_animating) {
275 if (!is_valid()) 274 if (!is_valid())
276 return false; 275 return false;
277 276
278 if (!is_visible || !is_animating) { 277 if (!is_visible || !is_animating) {
279 NOTREACHED(); 278 NOTREACHED();
280 return false; 279 return false;
281 } 280 }
282 281
283 return sender_->Send(new AutomationMsg_BookmarkBarVisibility( 282 return sender_->Send(new AutomationMsg_BookmarkBarVisibility(
284 0, handle_, is_visible, is_animating)); 283 handle_, is_visible, is_animating));
285 } 284 }
286 285
287 bool BrowserProxy::GetBookmarksAsJSON(std::string *json_string) { 286 bool BrowserProxy::GetBookmarksAsJSON(std::string *json_string) {
288 if (!is_valid()) 287 if (!is_valid())
289 return false; 288 return false;
290 289
291 if (!WaitForBookmarkModelToLoad()) 290 if (!WaitForBookmarkModelToLoad())
292 return false; 291 return false;
293 292
294 bool result = false; 293 bool result = false;
295 sender_->Send(new AutomationMsg_GetBookmarksAsJSON(0, handle_, 294 sender_->Send(new AutomationMsg_GetBookmarksAsJSON(handle_,
296 json_string, 295 json_string,
297 &result)); 296 &result));
298 return result; 297 return result;
299 } 298 }
300 299
301 bool BrowserProxy::WaitForBookmarkModelToLoad() { 300 bool BrowserProxy::WaitForBookmarkModelToLoad() {
302 if (!is_valid()) 301 if (!is_valid())
303 return false; 302 return false;
304 303
305 bool result = false; 304 bool result = false;
306 sender_->Send(new AutomationMsg_WaitForBookmarkModelToLoad(0, handle_, 305 sender_->Send(new AutomationMsg_WaitForBookmarkModelToLoad(handle_, &result));
307 &result));
308 return result; 306 return result;
309 } 307 }
310 308
311 bool BrowserProxy::AddBookmarkGroup(int64 parent_id, int index, 309 bool BrowserProxy::AddBookmarkGroup(int64 parent_id, int index,
312 std::wstring& title) { 310 std::wstring& title) {
313 if (!is_valid()) 311 if (!is_valid())
314 return false; 312 return false;
315 bool result = false; 313 bool result = false;
316 sender_->Send(new AutomationMsg_AddBookmarkGroup(0, handle_, 314 sender_->Send(new AutomationMsg_AddBookmarkGroup(handle_,
317 parent_id, index, 315 parent_id, index,
318 title, 316 title,
319 &result)); 317 &result));
320 return result; 318 return result;
321 } 319 }
322 320
323 bool BrowserProxy::AddBookmarkURL(int64 parent_id, int index, 321 bool BrowserProxy::AddBookmarkURL(int64 parent_id, int index,
324 std::wstring& title, const GURL& url) { 322 std::wstring& title, const GURL& url) {
325 if (!is_valid()) 323 if (!is_valid())
326 return false; 324 return false;
327 bool result = false; 325 bool result = false;
328 sender_->Send(new AutomationMsg_AddBookmarkURL(0, handle_, 326 sender_->Send(new AutomationMsg_AddBookmarkURL(handle_,
329 parent_id, index, 327 parent_id, index,
330 title, url, 328 title, url,
331 &result)); 329 &result));
332 return result; 330 return result;
333 } 331 }
334 332
335 bool BrowserProxy::ReparentBookmark(int64 id, int64 new_parent_id, int index) { 333 bool BrowserProxy::ReparentBookmark(int64 id, int64 new_parent_id, int index) {
336 if (!is_valid()) 334 if (!is_valid())
337 return false; 335 return false;
338 bool result = false; 336 bool result = false;
339 sender_->Send(new AutomationMsg_ReparentBookmark(0, handle_, 337 sender_->Send(new AutomationMsg_ReparentBookmark(handle_,
340 id, new_parent_id, 338 id, new_parent_id,
341 index, 339 index,
342 &result)); 340 &result));
343 return result; 341 return result;
344 } 342 }
345 343
346 bool BrowserProxy::SetBookmarkTitle(int64 id, const std::wstring& title) { 344 bool BrowserProxy::SetBookmarkTitle(int64 id, const std::wstring& title) {
347 if (!is_valid()) 345 if (!is_valid())
348 return false; 346 return false;
349 bool result = false; 347 bool result = false;
350 sender_->Send(new AutomationMsg_SetBookmarkTitle(0, handle_, 348 sender_->Send(new AutomationMsg_SetBookmarkTitle(handle_,
351 id, title, 349 id, title,
352 &result)); 350 &result));
353 return result; 351 return result;
354 } 352 }
355 353
356 bool BrowserProxy::SetBookmarkURL(int64 id, const GURL& url) { 354 bool BrowserProxy::SetBookmarkURL(int64 id, const GURL& url) {
357 if (!is_valid()) 355 if (!is_valid())
358 return false; 356 return false;
359 bool result = false; 357 bool result = false;
360 sender_->Send(new AutomationMsg_SetBookmarkURL(0, handle_, 358 sender_->Send(new AutomationMsg_SetBookmarkURL(handle_,
361 id, url, 359 id, url,
362 &result)); 360 &result));
363 return result; 361 return result;
364 } 362 }
365 363
366 bool BrowserProxy::RemoveBookmark(int64 id) { 364 bool BrowserProxy::RemoveBookmark(int64 id) {
367 if (!is_valid()) 365 if (!is_valid())
368 return false; 366 return false;
369 bool result = false; 367 bool result = false;
370 sender_->Send(new AutomationMsg_RemoveBookmark(0, handle_, 368 sender_->Send(new AutomationMsg_RemoveBookmark(handle_,
371 id, 369 id,
372 &result)); 370 &result));
373 return result; 371 return result;
374 } 372 }
375 373
376 bool BrowserProxy::IsShelfVisible(bool* is_visible) { 374 bool BrowserProxy::IsShelfVisible(bool* is_visible) {
377 if (!is_valid()) 375 if (!is_valid())
378 return false; 376 return false;
379 377
380 if (!is_visible) { 378 if (!is_visible) {
381 NOTREACHED(); 379 NOTREACHED();
382 return false; 380 return false;
383 } 381 }
384 382
385 return sender_->Send(new AutomationMsg_ShelfVisibility(0, handle_, 383 return sender_->Send(new AutomationMsg_ShelfVisibility(handle_,
386 is_visible)); 384 is_visible));
387 } 385 }
388 386
389 bool BrowserProxy::SetShelfVisible(bool is_visible) { 387 bool BrowserProxy::SetShelfVisible(bool is_visible) {
390 if (!is_valid()) 388 if (!is_valid())
391 return false; 389 return false;
392 390
393 return sender_->Send(new AutomationMsg_SetShelfVisibility(0, handle_, 391 return sender_->Send(new AutomationMsg_SetShelfVisibility(handle_,
394 is_visible)); 392 is_visible));
395 } 393 }
396 394
397 bool BrowserProxy::SetIntPreference(const std::string& name, int value) { 395 bool BrowserProxy::SetIntPreference(const std::string& name, int value) {
398 if (!is_valid()) 396 if (!is_valid())
399 return false; 397 return false;
400 398
401 bool result = false; 399 bool result = false;
402 400
403 sender_->Send(new AutomationMsg_SetIntPreference(0, handle_, name, value, 401 sender_->Send(new AutomationMsg_SetIntPreference(handle_, name, value,
404 &result)); 402 &result));
405 return result; 403 return result;
406 } 404 }
407 405
408 bool BrowserProxy::SetStringPreference(const std::string& name, 406 bool BrowserProxy::SetStringPreference(const std::string& name,
409 const std::string& value) { 407 const std::string& value) {
410 if (!is_valid()) 408 if (!is_valid())
411 return false; 409 return false;
412 410
413 bool result = false; 411 bool result = false;
414 412
415 sender_->Send(new AutomationMsg_SetStringPreference(0, handle_, name, value, 413 sender_->Send(new AutomationMsg_SetStringPreference(handle_, name, value,
416 &result)); 414 &result));
417 return result; 415 return result;
418 } 416 }
419 417
420 bool BrowserProxy::GetBooleanPreference(const std::string& name, 418 bool BrowserProxy::GetBooleanPreference(const std::string& name,
421 bool* value) { 419 bool* value) {
422 if (!is_valid()) 420 if (!is_valid())
423 return false; 421 return false;
424 422
425 bool result = false; 423 bool result = false;
426 424
427 sender_->Send(new AutomationMsg_GetBooleanPreference(0, handle_, name, value, 425 sender_->Send(new AutomationMsg_GetBooleanPreference(handle_, name, value,
428 &result)); 426 &result));
429 return result; 427 return result;
430 } 428 }
431 429
432 bool BrowserProxy::SetBooleanPreference(const std::string& name, 430 bool BrowserProxy::SetBooleanPreference(const std::string& name,
433 bool value) { 431 bool value) {
434 if (!is_valid()) 432 if (!is_valid())
435 return false; 433 return false;
436 434
437 bool result = false; 435 bool result = false;
438 436
439 sender_->Send(new AutomationMsg_SetBooleanPreference(0, handle_, name, 437 sender_->Send(new AutomationMsg_SetBooleanPreference(handle_, name,
440 value, &result)); 438 value, &result));
441 return result; 439 return result;
442 } 440 }
443 441
444 bool BrowserProxy::SetDefaultContentSetting(ContentSettingsType content_type, 442 bool BrowserProxy::SetDefaultContentSetting(ContentSettingsType content_type,
445 ContentSetting setting) { 443 ContentSetting setting) {
446 return SetContentSetting(std::string(), content_type, setting); 444 return SetContentSetting(std::string(), content_type, setting);
447 } 445 }
448 446
449 bool BrowserProxy::SetContentSetting(const std::string& host, 447 bool BrowserProxy::SetContentSetting(const std::string& host,
450 ContentSettingsType content_type, 448 ContentSettingsType content_type,
451 ContentSetting setting) { 449 ContentSetting setting) {
452 if (!is_valid()) 450 if (!is_valid())
453 return false; 451 return false;
454 452
455 bool result = false; 453 bool result = false;
456 454
457 sender_->Send(new AutomationMsg_SetContentSetting(0, handle_, host, 455 sender_->Send(new AutomationMsg_SetContentSetting(handle_, host,
458 content_type, setting, 456 content_type, setting,
459 &result)); 457 &result));
460 return result; 458 return result;
461 } 459 }
462 460
463 bool BrowserProxy::TerminateSession() { 461 bool BrowserProxy::TerminateSession() {
464 if (!is_valid()) 462 if (!is_valid())
465 return false; 463 return false;
466 464
467 bool result = false; 465 bool result = false;
468 466
469 sender_->Send(new AutomationMsg_TerminateSession(0, handle_, &result)); 467 sender_->Send(new AutomationMsg_TerminateSession(handle_, &result));
470 468
471 return result; 469 return result;
472 } 470 }
473 471
474 scoped_refptr<WindowProxy> BrowserProxy::GetWindow() const { 472 scoped_refptr<WindowProxy> BrowserProxy::GetWindow() const {
475 if (!is_valid()) 473 if (!is_valid())
476 return NULL; 474 return NULL;
477 475
478 bool handle_ok = false; 476 bool handle_ok = false;
479 int window_handle = 0; 477 int window_handle = 0;
480 478
481 sender_->Send(new AutomationMsg_WindowForBrowser(0, handle_, &handle_ok, 479 sender_->Send(new AutomationMsg_WindowForBrowser(handle_, &handle_ok,
482 &window_handle)); 480 &window_handle));
483 if (!handle_ok) 481 if (!handle_ok)
484 return NULL; 482 return NULL;
485 483
486 WindowProxy* window = 484 WindowProxy* window =
487 static_cast<WindowProxy*>(tracker_->GetResource(window_handle)); 485 static_cast<WindowProxy*>(tracker_->GetResource(window_handle));
488 if (!window) { 486 if (!window) {
489 window = new WindowProxy(sender_, tracker_, window_handle); 487 window = new WindowProxy(sender_, tracker_, window_handle);
490 window->AddRef(); 488 window->AddRef();
491 } 489 }
492 490
493 // Since there is no scoped_refptr::attach. 491 // Since there is no scoped_refptr::attach.
494 scoped_refptr<WindowProxy> result; 492 scoped_refptr<WindowProxy> result;
495 result.swap(&window); 493 result.swap(&window);
496 return result; 494 return result;
497 } 495 }
498 496
499 scoped_refptr<AutocompleteEditProxy> BrowserProxy::GetAutocompleteEdit() { 497 scoped_refptr<AutocompleteEditProxy> BrowserProxy::GetAutocompleteEdit() {
500 if (!is_valid()) 498 if (!is_valid())
501 return NULL; 499 return NULL;
502 500
503 bool handle_ok = false; 501 bool handle_ok = false;
504 int autocomplete_edit_handle = 0; 502 int autocomplete_edit_handle = 0;
505 503
506 sender_->Send(new AutomationMsg_AutocompleteEditForBrowser( 504 sender_->Send(new AutomationMsg_AutocompleteEditForBrowser(
507 0, handle_, &handle_ok, &autocomplete_edit_handle)); 505 handle_, &handle_ok, &autocomplete_edit_handle));
508 506
509 if (!handle_ok) 507 if (!handle_ok)
510 return NULL; 508 return NULL;
511 509
512 AutocompleteEditProxy* p = static_cast<AutocompleteEditProxy*>( 510 AutocompleteEditProxy* p = static_cast<AutocompleteEditProxy*>(
513 tracker_->GetResource(autocomplete_edit_handle)); 511 tracker_->GetResource(autocomplete_edit_handle));
514 512
515 if (!p) { 513 if (!p) {
516 p = new AutocompleteEditProxy(sender_, tracker_, autocomplete_edit_handle); 514 p = new AutocompleteEditProxy(sender_, tracker_, autocomplete_edit_handle);
517 p->AddRef(); 515 p->AddRef();
518 } 516 }
519 517
520 // Since there is no scoped_refptr::attach. 518 // Since there is no scoped_refptr::attach.
521 scoped_refptr<AutocompleteEditProxy> result; 519 scoped_refptr<AutocompleteEditProxy> result;
522 result.swap(&p); 520 result.swap(&p);
523 return result; 521 return result;
524 } 522 }
525 523
526 bool BrowserProxy::IsFullscreen(bool* is_fullscreen) { 524 bool BrowserProxy::IsFullscreen(bool* is_fullscreen) {
527 DCHECK(is_fullscreen); 525 DCHECK(is_fullscreen);
528 526
529 if (!is_valid()) 527 if (!is_valid())
530 return false; 528 return false;
531 529
532 return sender_->Send(new AutomationMsg_IsFullscreen(0, handle_, 530 return sender_->Send(new AutomationMsg_IsFullscreen(handle_, is_fullscreen));
533 is_fullscreen));
534 } 531 }
535 532
536 bool BrowserProxy::IsFullscreenBubbleVisible(bool* is_visible) { 533 bool BrowserProxy::IsFullscreenBubbleVisible(bool* is_visible) {
537 DCHECK(is_visible); 534 DCHECK(is_visible);
538 535
539 if (!is_valid()) 536 if (!is_valid())
540 return false; 537 return false;
541 538
542 return sender_->Send(new AutomationMsg_IsFullscreenBubbleVisible(0, handle_, 539 return sender_->Send(new AutomationMsg_IsFullscreenBubbleVisible(handle_,
543 is_visible)); 540 is_visible));
544 } 541 }
545 542
546 bool BrowserProxy::ShutdownSessionService() { 543 bool BrowserProxy::ShutdownSessionService() {
547 bool did_shutdown = false; 544 bool did_shutdown = false;
548 bool succeeded = sender_->Send( 545 bool succeeded = sender_->Send(
549 new AutomationMsg_ShutdownSessionService(0, handle_, &did_shutdown)); 546 new AutomationMsg_ShutdownSessionService(handle_, &did_shutdown));
550 547
551 if (!succeeded) { 548 if (!succeeded) {
552 DLOG(ERROR) << 549 DLOG(ERROR) <<
553 "ShutdownSessionService did not complete in a timely fashion"; 550 "ShutdownSessionService did not complete in a timely fashion";
554 return false; 551 return false;
555 } 552 }
556 553
557 return did_shutdown; 554 return did_shutdown;
558 } 555 }
559 556
560 bool BrowserProxy::StartTrackingPopupMenus() { 557 bool BrowserProxy::StartTrackingPopupMenus() {
561 if (!is_valid()) 558 if (!is_valid())
562 return false; 559 return false;
563 560
564 bool result = false; 561 bool result = false;
565 if (!sender_->Send(new AutomationMsg_StartTrackingPopupMenus 562 if (!sender_->Send(new AutomationMsg_StartTrackingPopupMenus(
566 (0, handle_, &result))) 563 handle_, &result)))
567 return false; 564 return false;
568 return result; 565 return result;
569 } 566 }
570 567
571 bool BrowserProxy::WaitForPopupMenuToOpen() { 568 bool BrowserProxy::WaitForPopupMenuToOpen() {
572 if (!is_valid()) 569 if (!is_valid())
573 return false; 570 return false;
574 571
575 bool result = false; 572 bool result = false;
576 if (!sender_->Send(new AutomationMsg_WaitForPopupMenuToOpen 573 if (!sender_->Send(new AutomationMsg_WaitForPopupMenuToOpen(&result)))
577 (0, &result)))
578 return false; 574 return false;
579 return result; 575 return result;
580 } 576 }
581 577
582 bool BrowserProxy::SendJSONRequest(const std::string& request, 578 bool BrowserProxy::SendJSONRequest(const std::string& request,
583 std::string* response) { 579 std::string* response) {
584 if (!is_valid()) 580 if (!is_valid())
585 return false; 581 return false;
586 582
587 bool result = false; 583 bool result = false;
588 return sender_->Send(new AutomationMsg_SendJSONRequest(0, handle_, 584 return sender_->Send(new AutomationMsg_SendJSONRequest(handle_,
589 request, response, 585 request, response,
590 &result)); 586 &result));
591 return result; 587 return result;
592 } 588 }
593 589
594 bool BrowserProxy::GetInitialLoadTimes(float* min_start_time, 590 bool BrowserProxy::GetInitialLoadTimes(float* min_start_time,
595 float* max_stop_time, 591 float* max_stop_time,
596 std::vector<float>* stop_times) { 592 std::vector<float>* stop_times) {
597 std::string json_response; 593 std::string json_response;
598 const char* kJSONCommand = "{\"command\": \"GetInitialLoadTimes\"}"; 594 const char* kJSONCommand = "{\"command\": \"GetInitialLoadTimes\"}";
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 if (i == 0) 639 if (i == 0)
644 *min_start_time = start_ms; 640 *min_start_time = start_ms;
645 641
646 *min_start_time = std::min(start_ms, *min_start_time); 642 *min_start_time = std::min(start_ms, *min_start_time);
647 *max_stop_time = std::max(stop_ms, *max_stop_time); 643 *max_stop_time = std::max(stop_ms, *max_stop_time);
648 stop_times->push_back(stop_ms); 644 stop_times->push_back(stop_ms);
649 } 645 }
650 std::sort(stop_times->begin(), stop_times->end()); 646 std::sort(stop_times->begin(), stop_times->end());
651 return true; 647 return true;
652 } 648 }
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_proxy_uitest.cc ('k') | chrome/test/automation/extension_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698