OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 982 } |
983 | 983 |
984 void TestingAutomationProvider::GetTabTitle(int handle, | 984 void TestingAutomationProvider::GetTabTitle(int handle, |
985 int* title_string_size, | 985 int* title_string_size, |
986 std::wstring* title) { | 986 std::wstring* title) { |
987 *title_string_size = -1; // -1 is the error code | 987 *title_string_size = -1; // -1 is the error code |
988 if (tab_tracker_->ContainsHandle(handle)) { | 988 if (tab_tracker_->ContainsHandle(handle)) { |
989 NavigationController* tab = tab_tracker_->GetResource(handle); | 989 NavigationController* tab = tab_tracker_->GetResource(handle); |
990 NavigationEntry* entry = tab->GetActiveEntry(); | 990 NavigationEntry* entry = tab->GetActiveEntry(); |
991 if (entry != NULL) { | 991 if (entry != NULL) { |
992 *title = UTF16ToWideHack(entry->GetTitleForDisplay("")); | 992 *title = base::UTF16ToWideHack(entry->GetTitleForDisplay("")); |
993 } else { | 993 } else { |
994 *title = std::wstring(); | 994 *title = std::wstring(); |
995 } | 995 } |
996 *title_string_size = static_cast<int>(title->size()); | 996 *title_string_size = static_cast<int>(title->size()); |
997 } | 997 } |
998 } | 998 } |
999 | 999 |
1000 void TestingAutomationProvider::GetTabIndex(int handle, int* tabstrip_index) { | 1000 void TestingAutomationProvider::GetTabIndex(int handle, int* tabstrip_index) { |
1001 *tabstrip_index = -1; // -1 is the error code | 1001 *tabstrip_index = -1; // -1 is the error code |
1002 | 1002 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 const std::wstring& script, | 1043 const std::wstring& script, |
1044 IPC::Message* reply_message) { | 1044 IPC::Message* reply_message) { |
1045 WebContents* web_contents = GetWebContentsForHandle(handle, NULL); | 1045 WebContents* web_contents = GetWebContentsForHandle(handle, NULL); |
1046 if (!web_contents) { | 1046 if (!web_contents) { |
1047 AutomationMsg_DomOperation::WriteReplyParams(reply_message, std::string()); | 1047 AutomationMsg_DomOperation::WriteReplyParams(reply_message, std::string()); |
1048 Send(reply_message); | 1048 Send(reply_message); |
1049 return; | 1049 return; |
1050 } | 1050 } |
1051 | 1051 |
1052 new DomOperationMessageSender(this, reply_message, false); | 1052 new DomOperationMessageSender(this, reply_message, false); |
1053 ExecuteJavascriptInRenderViewFrame(WideToUTF16Hack(frame_xpath), | 1053 ExecuteJavascriptInRenderViewFrame(base::WideToUTF16Hack(frame_xpath), |
1054 WideToUTF16Hack(script), reply_message, | 1054 base::WideToUTF16Hack(script), |
| 1055 reply_message, |
1055 web_contents->GetRenderViewHost()); | 1056 web_contents->GetRenderViewHost()); |
1056 } | 1057 } |
1057 | 1058 |
1058 // Sample json input: { "command": "OpenNewBrowserWindowWithNewProfile" } | 1059 // Sample json input: { "command": "OpenNewBrowserWindowWithNewProfile" } |
1059 // Sample output: {} | 1060 // Sample output: {} |
1060 void TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile( | 1061 void TestingAutomationProvider::OpenNewBrowserWindowWithNewProfile( |
1061 base::DictionaryValue* args, IPC::Message* reply_message) { | 1062 base::DictionaryValue* args, IPC::Message* reply_message) { |
1062 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1063 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1063 new BrowserOpenedWithNewProfileNotificationObserver(this, reply_message); | 1064 new BrowserOpenedWithNewProfileNotificationObserver(this, reply_message); |
1064 profile_manager->CreateMultiProfileAsync( | 1065 profile_manager->CreateMultiProfileAsync( |
(...skipping 4847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5912 if (g_browser_process) | 5913 if (g_browser_process) |
5913 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 5914 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
5914 } | 5915 } |
5915 | 5916 |
5916 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 5917 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
5917 WebContents* tab) { | 5918 WebContents* tab) { |
5918 TabStripModel* tab_strip = browser->tab_strip_model(); | 5919 TabStripModel* tab_strip = browser->tab_strip_model(); |
5919 if (tab_strip->GetActiveWebContents() != tab) | 5920 if (tab_strip->GetActiveWebContents() != tab) |
5920 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); | 5921 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); |
5921 } | 5922 } |
OLD | NEW |