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 25 matching lines...) Expand all Loading... |
36 script_timeout(0), | 36 script_timeout(0), |
37 capabilities(CreateCapabilities()) { | 37 capabilities(CreateCapabilities()) { |
38 } | 38 } |
39 | 39 |
40 Session::~Session() {} | 40 Session::~Session() {} |
41 | 41 |
42 Status Session::GetTargetWindow(WebView** web_view) { | 42 Status Session::GetTargetWindow(WebView** web_view) { |
43 if (!chrome) | 43 if (!chrome) |
44 return Status(kNoSuchWindow, "no chrome started in this session"); | 44 return Status(kNoSuchWindow, "no chrome started in this session"); |
45 | 45 |
46 std::list<WebView*> web_views; | 46 Status status = chrome->GetWebViewById(window, web_view); |
47 Status status = chrome->GetWebViews(&web_views); | |
48 if (status.IsError()) | 47 if (status.IsError()) |
49 return status; | 48 status = Status(kNoSuchWindow, "target window already closed", status); |
50 | 49 return status; |
51 for (std::list<WebView*>::const_iterator it = web_views.begin(); | |
52 it != web_views.end(); ++it) { | |
53 if ((*it)->GetId() == window) { | |
54 *web_view = *it; | |
55 return Status(kOk); | |
56 } | |
57 } | |
58 return Status(kNoSuchWindow, "target window already closed"); | |
59 } | 50 } |
60 | 51 |
61 void Session::SwitchToTopFrame() { | 52 void Session::SwitchToTopFrame() { |
62 frames.clear(); | 53 frames.clear(); |
63 } | 54 } |
64 | 55 |
65 void Session::SwitchToSubFrame(const std::string& frame_id, | 56 void Session::SwitchToSubFrame(const std::string& frame_id, |
66 const std::string& chromedriver_frame_id) { | 57 const std::string& chromedriver_frame_id) { |
67 std::string parent_frame_id; | 58 std::string parent_frame_id; |
68 if (!frames.empty()) | 59 if (!frames.empty()) |
(...skipping 30 matching lines...) Expand all Loading... |
99 | 90 |
100 SessionAccessorImpl::SessionAccessorImpl(scoped_ptr<Session> session) | 91 SessionAccessorImpl::SessionAccessorImpl(scoped_ptr<Session> session) |
101 : session_(session.Pass()) {} | 92 : session_(session.Pass()) {} |
102 | 93 |
103 Session* SessionAccessorImpl::Access(scoped_ptr<base::AutoLock>* lock) { | 94 Session* SessionAccessorImpl::Access(scoped_ptr<base::AutoLock>* lock) { |
104 lock->reset(new base::AutoLock(session_lock_)); | 95 lock->reset(new base::AutoLock(session_lock_)); |
105 return session_.get(); | 96 return session_.get(); |
106 } | 97 } |
107 | 98 |
108 SessionAccessorImpl::~SessionAccessorImpl() {} | 99 SessionAccessorImpl::~SessionAccessorImpl() {} |
OLD | NEW |