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/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 6910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6921 } | 6921 } |
6922 DictionaryValue dict; | 6922 DictionaryValue dict; |
6923 dict.SetBoolean( | 6923 dict.SetBoolean( |
6924 "does_exist", | 6924 "does_exist", |
6925 automation_util::DoesObjectWithIdExist(id, profile())); | 6925 automation_util::DoesObjectWithIdExist(id, profile())); |
6926 reply.SendSuccess(&dict); | 6926 reply.SendSuccess(&dict); |
6927 } | 6927 } |
6928 | 6928 |
6929 void TestingAutomationProvider::CloseTabJSON( | 6929 void TestingAutomationProvider::CloseTabJSON( |
6930 DictionaryValue* args, IPC::Message* reply_message) { | 6930 DictionaryValue* args, IPC::Message* reply_message) { |
6931 AutomationJSONReply reply(this, reply_message); | |
6932 Browser* browser; | 6931 Browser* browser; |
6933 WebContents* tab; | 6932 WebContents* tab; |
6934 std::string error; | 6933 std::string error; |
6935 bool wait_until_closed = false; // ChromeDriver does not use this. | 6934 bool wait_until_closed = false; // ChromeDriver does not use this. |
6936 args->GetBoolean("wait_until_closed", &wait_until_closed); | 6935 args->GetBoolean("wait_until_closed", &wait_until_closed); |
6937 // Close tabs synchronously. | 6936 // Close tabs synchronously. |
6938 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { | 6937 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { |
6939 if (wait_until_closed) { | 6938 if (wait_until_closed) { |
6940 new TabClosedNotificationObserver(this, wait_until_closed, reply_message, | 6939 new TabClosedNotificationObserver(this, wait_until_closed, reply_message, |
6941 true); | 6940 true); |
6942 } | 6941 } |
6943 chrome::CloseWebContents(browser, tab); | 6942 chrome::CloseWebContents(browser, tab); |
6944 if (!wait_until_closed) | 6943 if (!wait_until_closed) |
6945 reply.SendSuccess(NULL); | 6944 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
6946 return; | 6945 return; |
6947 } | 6946 } |
6948 // Close other types of views asynchronously. | 6947 // Close other types of views asynchronously. |
6949 RenderViewHost* view; | 6948 RenderViewHost* view; |
6950 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { | 6949 if (!GetRenderViewFromJSONArgs(args, profile(), &view, &error)) { |
6951 reply.SendError(error); | 6950 AutomationJSONReply(this, reply_message).SendError(error); |
6952 return; | 6951 return; |
6953 } | 6952 } |
6954 view->ClosePage(); | 6953 view->ClosePage(); |
6955 reply.SendSuccess(NULL); | 6954 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
6956 } | 6955 } |
6957 | 6956 |
6958 void TestingAutomationProvider::SetViewBounds( | 6957 void TestingAutomationProvider::SetViewBounds( |
6959 base::DictionaryValue* args, | 6958 base::DictionaryValue* args, |
6960 IPC::Message* reply_message) { | 6959 IPC::Message* reply_message) { |
6961 AutomationJSONReply reply(this, reply_message); | 6960 AutomationJSONReply reply(this, reply_message); |
6962 int x, y, width, height; | 6961 int x, y, width, height; |
6963 if (!args->GetInteger("bounds.x", &x) || | 6962 if (!args->GetInteger("bounds.x", &x) || |
6964 !args->GetInteger("bounds.y", &y) || | 6963 !args->GetInteger("bounds.y", &y) || |
6965 !args->GetInteger("bounds.width", &width) || | 6964 !args->GetInteger("bounds.width", &width) || |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7165 void TestingAutomationProvider::OnRemoveProvider() { | 7164 void TestingAutomationProvider::OnRemoveProvider() { |
7166 if (g_browser_process) | 7165 if (g_browser_process) |
7167 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 7166 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
7168 } | 7167 } |
7169 | 7168 |
7170 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 7169 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
7171 WebContents* tab) { | 7170 WebContents* tab) { |
7172 if (chrome::GetActiveWebContents(browser) != tab) | 7171 if (chrome::GetActiveWebContents(browser) != tab) |
7173 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 7172 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
7174 } | 7173 } |
OLD | NEW |