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/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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 bool result = false; | 238 bool result = false; |
239 | 239 |
240 sender_->Send(new AutomationMsg_WindowExecuteCommand(handle_, | 240 sender_->Send(new AutomationMsg_WindowExecuteCommand(handle_, |
241 browser_command, | 241 browser_command, |
242 &result)); | 242 &result)); |
243 | 243 |
244 return result; | 244 return result; |
245 } | 245 } |
246 | 246 |
247 bool BrowserProxy::GetBookmarkBarVisibility(bool* is_visible, | |
248 bool* is_animating, | |
249 bool* is_detached) { | |
250 if (!is_valid()) | |
251 return false; | |
252 | |
253 if (!is_visible || !is_animating) { | |
254 NOTREACHED(); | |
255 return false; | |
256 } | |
257 | |
258 return sender_->Send(new AutomationMsg_BookmarkBarVisibility( | |
259 handle_, is_visible, is_animating, is_detached)); | |
260 } | |
261 | |
262 bool BrowserProxy::GetBookmarksAsJSON(std::string *json_string) { | |
263 if (!is_valid()) | |
264 return false; | |
265 | |
266 if (!WaitForBookmarkModelToLoad()) | |
267 return false; | |
268 | |
269 bool result = false; | |
270 sender_->Send(new AutomationMsg_GetBookmarksAsJSON(handle_, | |
271 json_string, | |
272 &result)); | |
273 return result; | |
274 } | |
275 | |
276 bool BrowserProxy::WaitForBookmarkModelToLoad() { | |
277 if (!is_valid()) | |
278 return false; | |
279 | |
280 bool result = false; | |
281 sender_->Send(new AutomationMsg_WaitForBookmarkModelToLoad(handle_, &result)); | |
282 return result; | |
283 } | |
284 | |
285 bool BrowserProxy::AddBookmarkGroup(int64 parent_id, int index, | |
286 std::wstring& title) { | |
287 if (!is_valid()) | |
288 return false; | |
289 bool result = false; | |
290 sender_->Send(new AutomationMsg_AddBookmarkGroup(handle_, | |
291 parent_id, index, | |
292 title, | |
293 &result)); | |
294 return result; | |
295 } | |
296 | |
297 bool BrowserProxy::AddBookmarkURL(int64 parent_id, int index, | |
298 std::wstring& title, const GURL& url) { | |
299 if (!is_valid()) | |
300 return false; | |
301 bool result = false; | |
302 sender_->Send(new AutomationMsg_AddBookmarkURL(handle_, | |
303 parent_id, index, | |
304 title, url, | |
305 &result)); | |
306 return result; | |
307 } | |
308 | |
309 bool BrowserProxy::ReparentBookmark(int64 id, int64 new_parent_id, int index) { | |
310 if (!is_valid()) | |
311 return false; | |
312 bool result = false; | |
313 sender_->Send(new AutomationMsg_ReparentBookmark(handle_, | |
314 id, new_parent_id, | |
315 index, | |
316 &result)); | |
317 return result; | |
318 } | |
319 | |
320 bool BrowserProxy::SetBookmarkTitle(int64 id, const std::wstring& title) { | |
321 if (!is_valid()) | |
322 return false; | |
323 bool result = false; | |
324 sender_->Send(new AutomationMsg_SetBookmarkTitle(handle_, | |
325 id, title, | |
326 &result)); | |
327 return result; | |
328 } | |
329 | |
330 bool BrowserProxy::SetBookmarkURL(int64 id, const GURL& url) { | |
331 if (!is_valid()) | |
332 return false; | |
333 bool result = false; | |
334 sender_->Send(new AutomationMsg_SetBookmarkURL(handle_, | |
335 id, url, | |
336 &result)); | |
337 return result; | |
338 } | |
339 | |
340 bool BrowserProxy::RemoveBookmark(int64 id) { | |
341 if (!is_valid()) | |
342 return false; | |
343 bool result = false; | |
344 sender_->Send(new AutomationMsg_RemoveBookmark(handle_, | |
345 id, | |
346 &result)); | |
347 return result; | |
348 } | |
349 | |
350 bool BrowserProxy::TerminateSession() { | 247 bool BrowserProxy::TerminateSession() { |
351 if (!is_valid()) | 248 if (!is_valid()) |
352 return false; | 249 return false; |
353 | 250 |
354 bool result = false; | 251 bool result = false; |
355 | 252 |
356 sender_->Send(new AutomationMsg_TerminateSession(handle_, &result)); | 253 sender_->Send(new AutomationMsg_TerminateSession(handle_, &result)); |
357 | 254 |
358 return result; | 255 return result; |
359 } | 256 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 if (i == 0) | 350 if (i == 0) |
454 *min_start_time = start_ms; | 351 *min_start_time = start_ms; |
455 | 352 |
456 *min_start_time = std::min(start_ms, *min_start_time); | 353 *min_start_time = std::min(start_ms, *min_start_time); |
457 *max_stop_time = std::max(stop_ms, *max_stop_time); | 354 *max_stop_time = std::max(stop_ms, *max_stop_time); |
458 stop_times->push_back(stop_ms); | 355 stop_times->push_back(stop_ms); |
459 } | 356 } |
460 std::sort(stop_times->begin(), stop_times->end()); | 357 std::sort(stop_times->begin(), stop_times->end()); |
461 return true; | 358 return true; |
462 } | 359 } |
OLD | NEW |