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

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

Issue 6507015: Implement the target locator commands for ChromeDriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address Pawel's concerns Created 9 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/string16.h"
11 #include "base/threading/platform_thread.h" 11 #include "base/threading/platform_thread.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/common/automation_messages.h" 13 #include "chrome/common/automation_messages.h"
14 #include "chrome/common/json_value_serializer.h" 14 #include "chrome/common/json_value_serializer.h"
15 #include "chrome/test/automation/automation_proxy.h" 15 #include "chrome/test/automation/automation_proxy.h"
16 #include "chrome/test/automation/browser_proxy.h"
16 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
17 18
18 TabProxy::TabProxy(AutomationMessageSender* sender, 19 TabProxy::TabProxy(AutomationMessageSender* sender,
19 AutomationHandleTracker* tracker, 20 AutomationHandleTracker* tracker,
20 int handle) 21 int handle)
21 : AutomationResourceProxy(tracker, sender, handle) { 22 : AutomationResourceProxy(tracker, sender, handle) {
22 } 23 }
23 24
25 scoped_refptr<BrowserProxy> TabProxy::GetParentBrowser() const {
26 if (!is_valid())
27 return NULL;
28
29 int browser_handle = 0;
30 sender_->Send(
31 new AutomationMsg_GetParentBrowserOfTab(handle_, &browser_handle));
32 if (!browser_handle)
33 return NULL;
34
35 BrowserProxy* browser = static_cast<BrowserProxy*>(
36 tracker_->GetResource(browser_handle));
37 if (!browser) {
38 browser = new BrowserProxy(sender_, tracker_, browser_handle);
39 browser->AddRef();
40 }
41
42 // Since there is no scoped_refptr::attach.
43 scoped_refptr<BrowserProxy> result;
44 result.swap(&browser);
45 return result;
46 }
24 47
25 bool TabProxy::GetTabTitle(std::wstring* title) const { 48 bool TabProxy::GetTabTitle(std::wstring* title) const {
26 if (!is_valid()) 49 if (!is_valid())
27 return false; 50 return false;
28 51
29 if (!title) { 52 if (!title) {
30 NOTREACHED(); 53 NOTREACHED();
31 return false; 54 return false;
32 } 55 }
33 56
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 json)); 852 json));
830 } 853 }
831 854
832 void TabProxy::FirstObjectAdded() { 855 void TabProxy::FirstObjectAdded() {
833 AddRef(); 856 AddRef();
834 } 857 }
835 858
836 void TabProxy::LastObjectRemoved() { 859 void TabProxy::LastObjectRemoved() {
837 Release(); 860 Release();
838 } 861 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698