| OLD | NEW |
| 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/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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 const GURL& url, | 498 const GURL& url, |
| 499 IPC::Message* reply_message) { | 499 IPC::Message* reply_message) { |
| 500 int append_tab_response = -1; // -1 is the error code | 500 int append_tab_response = -1; // -1 is the error code |
| 501 NotificationObserver* observer = NULL; | 501 NotificationObserver* observer = NULL; |
| 502 | 502 |
| 503 if (browser_tracker_->ContainsHandle(handle)) { | 503 if (browser_tracker_->ContainsHandle(handle)) { |
| 504 Browser* browser = browser_tracker_->GetResource(handle); | 504 Browser* browser = browser_tracker_->GetResource(handle); |
| 505 observer = new TabAppendedNotificationObserver(browser, this, | 505 observer = new TabAppendedNotificationObserver(browser, this, |
| 506 reply_message); | 506 reply_message); |
| 507 TabContentsWrapper* contents = | 507 TabContentsWrapper* contents = |
| 508 browser->AddSelectedTabWithURL(url, PageTransition::TYPED); | 508 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); |
| 509 if (contents) { | 509 if (contents) { |
| 510 append_tab_response = | 510 append_tab_response = |
| 511 GetIndexForNavigationController(&contents->controller(), browser); | 511 GetIndexForNavigationController(&contents->controller(), browser); |
| 512 } | 512 } |
| 513 } | 513 } |
| 514 | 514 |
| 515 if (append_tab_response < 0) { | 515 if (append_tab_response < 0) { |
| 516 // Appending tab failed. Clean up and send failure response. | 516 // Appending tab failed. Clean up and send failure response. |
| 517 | 517 |
| 518 if (observer) | 518 if (observer) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 596 |
| 597 // Simulate what a user would do. Activate the tab and then navigate. | 597 // Simulate what a user would do. Activate the tab and then navigate. |
| 598 // We could allow navigating in a background tab in future. | 598 // We could allow navigating in a background tab in future. |
| 599 Browser* browser = FindAndActivateTab(tab); | 599 Browser* browser = FindAndActivateTab(tab); |
| 600 | 600 |
| 601 if (browser) { | 601 if (browser) { |
| 602 new NavigationNotificationObserver(tab, this, reply_message, | 602 new NavigationNotificationObserver(tab, this, reply_message, |
| 603 number_of_navigations, false, false); | 603 number_of_navigations, false, false); |
| 604 | 604 |
| 605 // TODO(darin): avoid conversion to GURL. | 605 // TODO(darin): avoid conversion to GURL. |
| 606 browser->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 606 browser->OpenURL( |
| 607 url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
| 607 return; | 608 return; |
| 608 } | 609 } |
| 609 } | 610 } |
| 610 | 611 |
| 611 AutomationMsg_NavigateToURLBlockUntilNavigationsComplete::WriteReplyParams( | 612 AutomationMsg_NavigateToURLBlockUntilNavigationsComplete::WriteReplyParams( |
| 612 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); | 613 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); |
| 613 Send(reply_message); | 614 Send(reply_message); |
| 614 } | 615 } |
| 615 | 616 |
| 616 void TestingAutomationProvider::NavigationAsync(int handle, | 617 void TestingAutomationProvider::NavigationAsync(int handle, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 629 if (tab_tracker_->ContainsHandle(handle)) { | 630 if (tab_tracker_->ContainsHandle(handle)) { |
| 630 NavigationController* tab = tab_tracker_->GetResource(handle); | 631 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 631 | 632 |
| 632 // Simulate what a user would do. Activate the tab and then navigate. | 633 // Simulate what a user would do. Activate the tab and then navigate. |
| 633 // We could allow navigating in a background tab in future. | 634 // We could allow navigating in a background tab in future. |
| 634 Browser* browser = FindAndActivateTab(tab); | 635 Browser* browser = FindAndActivateTab(tab); |
| 635 | 636 |
| 636 if (browser) { | 637 if (browser) { |
| 637 // Don't add any listener unless a callback mechanism is desired. | 638 // Don't add any listener unless a callback mechanism is desired. |
| 638 // TODO(vibhor): Do this if such a requirement arises in future. | 639 // TODO(vibhor): Do this if such a requirement arises in future. |
| 639 browser->OpenURL(url, GURL(), disposition, PageTransition::TYPED); | 640 browser->OpenURL( |
| 641 url, GURL(), disposition, content::PAGE_TRANSITION_TYPED); |
| 640 *status = true; | 642 *status = true; |
| 641 } | 643 } |
| 642 } | 644 } |
| 643 } | 645 } |
| 644 | 646 |
| 645 void TestingAutomationProvider::Reload(int handle, | 647 void TestingAutomationProvider::Reload(int handle, |
| 646 IPC::Message* reply_message) { | 648 IPC::Message* reply_message) { |
| 647 if (tab_tracker_->ContainsHandle(handle)) { | 649 if (tab_tracker_->ContainsHandle(handle)) { |
| 648 NavigationController* tab = tab_tracker_->GetResource(handle); | 650 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 649 Browser* browser = FindAndActivateTab(tab); | 651 Browser* browser = FindAndActivateTab(tab); |
| (...skipping 2413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3063 | 3065 |
| 3064 // Ideas for "dummy" values (e.g. id_scope) came from | 3066 // Ideas for "dummy" values (e.g. id_scope) came from |
| 3065 // chrome/browser/autocomplete/history_contents_provider_unittest.cc | 3067 // chrome/browser/autocomplete/history_contents_provider_unittest.cc |
| 3066 HistoryService* hs = browser->profile()->GetHistoryService( | 3068 HistoryService* hs = browser->profile()->GetHistoryService( |
| 3067 Profile::EXPLICIT_ACCESS); | 3069 Profile::EXPLICIT_ACCESS); |
| 3068 const void* id_scope = reinterpret_cast<void*>(1); | 3070 const void* id_scope = reinterpret_cast<void*>(1); |
| 3069 hs->AddPage(gurl, time, | 3071 hs->AddPage(gurl, time, |
| 3070 id_scope, | 3072 id_scope, |
| 3071 0, | 3073 0, |
| 3072 GURL(), | 3074 GURL(), |
| 3073 PageTransition::LINK, | 3075 content::PAGE_TRANSITION_LINK, |
| 3074 history::RedirectList(), | 3076 history::RedirectList(), |
| 3075 history::SOURCE_BROWSED, | 3077 history::SOURCE_BROWSED, |
| 3076 false); | 3078 false); |
| 3077 if (title.length()) | 3079 if (title.length()) |
| 3078 hs->SetPageTitle(gurl, title); | 3080 hs->SetPageTitle(gurl, title); |
| 3079 reply.SendSuccess(NULL); | 3081 reply.SendSuccess(NULL); |
| 3080 } | 3082 } |
| 3081 | 3083 |
| 3082 // Sample json input: { "command": "GetDownloadsInfo" } | 3084 // Sample json input: { "command": "GetDownloadsInfo" } |
| 3083 // Refer chrome/test/pyautolib/download_info.py for sample json output. | 3085 // Refer chrome/test/pyautolib/download_info.py for sample json output. |
| (...skipping 2919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6003 } | 6005 } |
| 6004 if (!args->GetInteger("navigation_count", &navigation_count)) { | 6006 if (!args->GetInteger("navigation_count", &navigation_count)) { |
| 6005 AutomationJSONReply(this, reply_message) | 6007 AutomationJSONReply(this, reply_message) |
| 6006 .SendError("'navigation_count' missing or invalid"); | 6008 .SendError("'navigation_count' missing or invalid"); |
| 6007 return; | 6009 return; |
| 6008 } | 6010 } |
| 6009 new NavigationNotificationObserver( | 6011 new NavigationNotificationObserver( |
| 6010 &tab_contents->controller(), this, reply_message, | 6012 &tab_contents->controller(), this, reply_message, |
| 6011 navigation_count, false, true); | 6013 navigation_count, false, true); |
| 6012 browser->OpenURLFromTab( | 6014 browser->OpenURLFromTab( |
| 6013 tab_contents, GURL(url), GURL(), CURRENT_TAB, PageTransition::TYPED); | 6015 tab_contents, GURL(url), GURL(), CURRENT_TAB, |
| 6016 content::PAGE_TRANSITION_TYPED); |
| 6014 } | 6017 } |
| 6015 | 6018 |
| 6016 void TestingAutomationProvider::ExecuteJavascriptJSON( | 6019 void TestingAutomationProvider::ExecuteJavascriptJSON( |
| 6017 DictionaryValue* args, | 6020 DictionaryValue* args, |
| 6018 IPC::Message* reply_message) { | 6021 IPC::Message* reply_message) { |
| 6019 if (SendErrorIfModalDialogActive(this, reply_message)) | 6022 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 6020 return; | 6023 return; |
| 6021 | 6024 |
| 6022 string16 frame_xpath, javascript; | 6025 string16 frame_xpath, javascript; |
| 6023 std::string error; | 6026 std::string error; |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6523 | 6526 |
| 6524 Send(reply_message_); | 6527 Send(reply_message_); |
| 6525 redirect_query_ = 0; | 6528 redirect_query_ = 0; |
| 6526 reply_message_ = NULL; | 6529 reply_message_ = NULL; |
| 6527 } | 6530 } |
| 6528 | 6531 |
| 6529 void TestingAutomationProvider::OnRemoveProvider() { | 6532 void TestingAutomationProvider::OnRemoveProvider() { |
| 6530 if (g_browser_process) | 6533 if (g_browser_process) |
| 6531 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6534 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6532 } | 6535 } |
| OLD | NEW |