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 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 AutomationJSONReply(this, reply_message).SendError( | 1222 AutomationJSONReply(this, reply_message).SendError( |
1223 StringPrintf("Invalid profile path: %s", path.c_str())); | 1223 StringPrintf("Invalid profile path: %s", path.c_str())); |
1224 return; | 1224 return; |
1225 } | 1225 } |
1226 int num_loads; | 1226 int num_loads; |
1227 if (!args->GetInteger("num_loads", &num_loads)) { | 1227 if (!args->GetInteger("num_loads", &num_loads)) { |
1228 AutomationJSONReply(this, reply_message).SendError( | 1228 AutomationJSONReply(this, reply_message).SendError( |
1229 "Invalid or missing arg: 'num_loads'"); | 1229 "Invalid or missing arg: 'num_loads'"); |
1230 return; | 1230 return; |
1231 } | 1231 } |
1232 Browser* browser = browser::FindTabbedBrowser(profile, false); | 1232 new BrowserOpenedWithExistingProfileNotificationObserver( |
1233 if (browser) { | 1233 this, reply_message, num_loads); |
1234 // Already have browser. Need to just activate. | 1234 ProfileManager::FindOrCreateNewWindowForProfile( |
1235 ProfileManager::FindOrCreateNewWindowForProfile( | 1235 profile, |
1236 profile, | 1236 chrome::startup::IS_NOT_PROCESS_STARTUP, |
1237 chrome::startup::IS_NOT_PROCESS_STARTUP, | 1237 chrome::startup::IS_NOT_FIRST_RUN, |
1238 chrome::startup::IS_NOT_FIRST_RUN, | 1238 0); |
1239 0); | |
1240 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | |
1241 } else { | |
1242 new BrowserOpenedWithExistingProfileNotificationObserver( | |
1243 this, reply_message, num_loads); | |
1244 ProfileManager::FindOrCreateNewWindowForProfile( | |
1245 profile, | |
1246 chrome::startup::IS_NOT_PROCESS_STARTUP, | |
1247 chrome::startup::IS_NOT_FIRST_RUN, | |
1248 0); | |
1249 } | |
1250 } | 1239 } |
1251 | 1240 |
1252 void TestingAutomationProvider::GetWindowForBrowser(int browser_handle, | 1241 void TestingAutomationProvider::GetWindowForBrowser(int browser_handle, |
1253 bool* success, | 1242 bool* success, |
1254 int* handle) { | 1243 int* handle) { |
1255 *success = false; | 1244 *success = false; |
1256 *handle = 0; | 1245 *handle = 0; |
1257 | 1246 |
1258 if (browser_tracker_->ContainsHandle(browser_handle)) { | 1247 if (browser_tracker_->ContainsHandle(browser_handle)) { |
1259 Browser* browser = browser_tracker_->GetResource(browser_handle); | 1248 Browser* browser = browser_tracker_->GetResource(browser_handle); |
(...skipping 5510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6770 void TestingAutomationProvider::OnRemoveProvider() { | 6759 void TestingAutomationProvider::OnRemoveProvider() { |
6771 if (g_browser_process) | 6760 if (g_browser_process) |
6772 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6761 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
6773 } | 6762 } |
6774 | 6763 |
6775 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6764 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
6776 WebContents* tab) { | 6765 WebContents* tab) { |
6777 if (chrome::GetActiveWebContents(browser) != tab) | 6766 if (chrome::GetActiveWebContents(browser) != tab) |
6778 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 6767 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
6779 } | 6768 } |
OLD | NEW |