| 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/session.h" | 5 #include "chrome/test/chromedriver/session.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/test/chromedriver/chrome/chrome.h" | 10 #include "chrome/test/chromedriver/chrome/chrome.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 script_timeout(0), | 38 script_timeout(0), |
| 39 capabilities(CreateCapabilities()) { | 39 capabilities(CreateCapabilities()) { |
| 40 } | 40 } |
| 41 | 41 |
| 42 Session::~Session() {} | 42 Session::~Session() {} |
| 43 | 43 |
| 44 Status Session::GetTargetWindow(WebView** web_view) { | 44 Status Session::GetTargetWindow(WebView** web_view) { |
| 45 if (!chrome) | 45 if (!chrome) |
| 46 return Status(kNoSuchWindow, "no chrome started in this session"); | 46 return Status(kNoSuchWindow, "no chrome started in this session"); |
| 47 | 47 |
| 48 std::list<WebView*> web_views; | 48 Status status = chrome->GetWebViewById(window, web_view); |
| 49 Status status = chrome->GetWebViews(&web_views); | |
| 50 if (status.IsError()) | 49 if (status.IsError()) |
| 51 return status; | 50 status = Status(kNoSuchWindow, "target window already closed", status); |
| 52 | 51 return status; |
| 53 for (std::list<WebView*>::const_iterator it = web_views.begin(); | |
| 54 it != web_views.end(); ++it) { | |
| 55 if ((*it)->GetId() == window) { | |
| 56 *web_view = *it; | |
| 57 return Status(kOk); | |
| 58 } | |
| 59 } | |
| 60 return Status(kNoSuchWindow, "target window already closed"); | |
| 61 } | 52 } |
| 62 | 53 |
| 63 void Session::SwitchToTopFrame() { | 54 void Session::SwitchToTopFrame() { |
| 64 frames.clear(); | 55 frames.clear(); |
| 65 } | 56 } |
| 66 | 57 |
| 67 void Session::SwitchToSubFrame(const std::string& frame_id, | 58 void Session::SwitchToSubFrame(const std::string& frame_id, |
| 68 const std::string& chromedriver_frame_id) { | 59 const std::string& chromedriver_frame_id) { |
| 69 std::string parent_frame_id; | 60 std::string parent_frame_id; |
| 70 if (!frames.empty()) | 61 if (!frames.empty()) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 Session* SessionAccessorImpl::Access(scoped_ptr<base::AutoLock>* lock) { | 96 Session* SessionAccessorImpl::Access(scoped_ptr<base::AutoLock>* lock) { |
| 106 lock->reset(new base::AutoLock(session_lock_)); | 97 lock->reset(new base::AutoLock(session_lock_)); |
| 107 return session_.get(); | 98 return session_.get(); |
| 108 } | 99 } |
| 109 | 100 |
| 110 void SessionAccessorImpl::DeleteSession() { | 101 void SessionAccessorImpl::DeleteSession() { |
| 111 session_.reset(); | 102 session_.reset(); |
| 112 } | 103 } |
| 113 | 104 |
| 114 SessionAccessorImpl::~SessionAccessorImpl() {} | 105 SessionAccessorImpl::~SessionAccessorImpl() {} |
| OLD | NEW |