| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
| 6 | 6 |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
| 9 #include "chrome/app/chrome_dll_resource.h" | 9 #include "chrome/app/chrome_dll_resource.h" |
| 10 #include "chrome/browser/automation/automation_provider_list.h" | 10 #include "chrome/browser/automation/automation_provider_list.h" |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 | 817 |
| 818 void AutomationProvider::AppendTab(const IPC::Message& message, | 818 void AutomationProvider::AppendTab(const IPC::Message& message, |
| 819 int handle, const GURL& url) { | 819 int handle, const GURL& url) { |
| 820 int append_tab_response = -1; // -1 is the error code | 820 int append_tab_response = -1; // -1 is the error code |
| 821 NotificationObserver* observer = NULL; | 821 NotificationObserver* observer = NULL; |
| 822 | 822 |
| 823 if (browser_tracker_->ContainsHandle(handle)) { | 823 if (browser_tracker_->ContainsHandle(handle)) { |
| 824 Browser* browser = browser_tracker_->GetResource(handle); | 824 Browser* browser = browser_tracker_->GetResource(handle); |
| 825 observer = AddTabStripObserver(browser, message.routing_id()); | 825 observer = AddTabStripObserver(browser, message.routing_id()); |
| 826 TabContents* tab_contents = | 826 TabContents* tab_contents = |
| 827 browser->AddTabWithURL(url, PageTransition::TYPED, true, NULL); | 827 browser->AddTabWithURL(url, GURL(), PageTransition::TYPED, true, NULL); |
| 828 if (tab_contents) { | 828 if (tab_contents) { |
| 829 append_tab_response = | 829 append_tab_response = |
| 830 GetIndexForNavigationController(tab_contents->controller(), browser); | 830 GetIndexForNavigationController(tab_contents->controller(), browser); |
| 831 } | 831 } |
| 832 } | 832 } |
| 833 | 833 |
| 834 if (append_tab_response < 0) { | 834 if (append_tab_response < 0) { |
| 835 // The append tab failed. Remove the TabStripObserver | 835 // The append tab failed. Remove the TabStripObserver |
| 836 if (observer) { | 836 if (observer) { |
| 837 RemoveTabStripObserver(observer); | 837 RemoveTabStripObserver(observer); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 857 // We could allow navigating in a background tab in future. | 857 // We could allow navigating in a background tab in future. |
| 858 Browser* browser = FindAndActivateTab(tab); | 858 Browser* browser = FindAndActivateTab(tab); |
| 859 | 859 |
| 860 if (browser) { | 860 if (browser) { |
| 861 AddNavigationStatusListener(tab, | 861 AddNavigationStatusListener(tab, |
| 862 new AutomationMsg_NavigateToURLResponse( | 862 new AutomationMsg_NavigateToURLResponse( |
| 863 message.routing_id(), AUTOMATION_MSG_NAVIGATION_SUCCESS), | 863 message.routing_id(), AUTOMATION_MSG_NAVIGATION_SUCCESS), |
| 864 new AutomationMsg_NavigateToURLResponse( | 864 new AutomationMsg_NavigateToURLResponse( |
| 865 message.routing_id(), AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED)); | 865 message.routing_id(), AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED)); |
| 866 // TODO(darin): avoid conversion to GURL | 866 // TODO(darin): avoid conversion to GURL |
| 867 browser->OpenURL(url, CURRENT_TAB, PageTransition::TYPED); | 867 browser->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); |
| 868 return; | 868 return; |
| 869 } | 869 } |
| 870 } | 870 } |
| 871 Send(new AutomationMsg_NavigateToURLResponse( | 871 Send(new AutomationMsg_NavigateToURLResponse( |
| 872 message.routing_id(), AUTOMATION_MSG_NAVIGATION_ERROR)); | 872 message.routing_id(), AUTOMATION_MSG_NAVIGATION_ERROR)); |
| 873 } | 873 } |
| 874 | 874 |
| 875 void AutomationProvider::NavigationAsync(const IPC::Message& message, | 875 void AutomationProvider::NavigationAsync(const IPC::Message& message, |
| 876 int handle, const GURL& url) { | 876 int handle, const GURL& url) { |
| 877 bool status = false; | 877 bool status = false; |
| 878 | 878 |
| 879 if (tab_tracker_->ContainsHandle(handle)) { | 879 if (tab_tracker_->ContainsHandle(handle)) { |
| 880 NavigationController* tab = tab_tracker_->GetResource(handle); | 880 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 881 | 881 |
| 882 // Simulate what a user would do. Activate the tab and then navigate. | 882 // Simulate what a user would do. Activate the tab and then navigate. |
| 883 // We could allow navigating in a background tab in future. | 883 // We could allow navigating in a background tab in future. |
| 884 Browser* browser = FindAndActivateTab(tab); | 884 Browser* browser = FindAndActivateTab(tab); |
| 885 | 885 |
| 886 if (browser) { | 886 if (browser) { |
| 887 // Don't add any listener unless a callback mechanism is desired. | 887 // Don't add any listener unless a callback mechanism is desired. |
| 888 // TODO(vibhor): Do this if such a requirement arises in future. | 888 // TODO(vibhor): Do this if such a requirement arises in future. |
| 889 browser->OpenURL(url, CURRENT_TAB, PageTransition::TYPED); | 889 browser->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); |
| 890 status = true; | 890 status = true; |
| 891 } | 891 } |
| 892 } | 892 } |
| 893 | 893 |
| 894 Send(new AutomationMsg_NavigationAsyncResponse(message.routing_id(), status)); | 894 Send(new AutomationMsg_NavigationAsyncResponse(message.routing_id(), status)); |
| 895 } | 895 } |
| 896 | 896 |
| 897 void AutomationProvider::GoBack(const IPC::Message& message, int handle) { | 897 void AutomationProvider::GoBack(const IPC::Message& message, int handle) { |
| 898 if (tab_tracker_->ContainsHandle(handle)) { | 898 if (tab_tracker_->ContainsHandle(handle)) { |
| 899 NavigationController* tab = tab_tracker_->GetResource(handle); | 899 NavigationController* tab = tab_tracker_->GetResource(handle); |
| (...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 tab_container_window, | 1995 tab_container_window, |
| 1996 tab_handle)); | 1996 tab_handle)); |
| 1997 } | 1997 } |
| 1998 | 1998 |
| 1999 void AutomationProvider::NavigateInExternalTab(const IPC::Message& message, | 1999 void AutomationProvider::NavigateInExternalTab(const IPC::Message& message, |
| 2000 int handle, const GURL& url) { | 2000 int handle, const GURL& url) { |
| 2001 bool status = false; | 2001 bool status = false; |
| 2002 | 2002 |
| 2003 if (tab_tracker_->ContainsHandle(handle)) { | 2003 if (tab_tracker_->ContainsHandle(handle)) { |
| 2004 NavigationController* tab = tab_tracker_->GetResource(handle); | 2004 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 2005 tab->LoadURL(url, PageTransition::TYPED); | 2005 tab->LoadURL(url, GURL(), PageTransition::TYPED); |
| 2006 status = true; | 2006 status = true; |
| 2007 } | 2007 } |
| 2008 | 2008 |
| 2009 Send(new AutomationMsg_NavigateInExternalTabResponse(message.routing_id(), | 2009 Send(new AutomationMsg_NavigateInExternalTabResponse(message.routing_id(), |
| 2010 status)); | 2010 status)); |
| 2011 } | 2011 } |
| 2012 | 2012 |
| 2013 void AutomationProvider::SetAcceleratorsForTab(const IPC::Message& message, | 2013 void AutomationProvider::SetAcceleratorsForTab(const IPC::Message& message, |
| 2014 int handle, | 2014 int handle, |
| 2015 HACCEL accel_table, | 2015 HACCEL accel_table, |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2423 int value) { | 2423 int value) { |
| 2424 bool success = false; | 2424 bool success = false; |
| 2425 if (browser_tracker_->ContainsHandle(handle)) { | 2425 if (browser_tracker_->ContainsHandle(handle)) { |
| 2426 Browser* browser = browser_tracker_->GetResource(handle); | 2426 Browser* browser = browser_tracker_->GetResource(handle); |
| 2427 browser->profile()->GetPrefs()->SetInteger(name.c_str(), value); | 2427 browser->profile()->GetPrefs()->SetInteger(name.c_str(), value); |
| 2428 success = true; | 2428 success = true; |
| 2429 } | 2429 } |
| 2430 Send(new AutomationMsg_SetIntPreferenceResponse(message.routing_id(), | 2430 Send(new AutomationMsg_SetIntPreferenceResponse(message.routing_id(), |
| 2431 success)); | 2431 success)); |
| 2432 } | 2432 } |
| OLD | NEW |