| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "app/message_box_flags.h" | 7 #include "app/message_box_flags.h" |
| 8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/stl_util-inl.h" | 11 #include "base/stl_util-inl.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/thread.h" | 13 #include "base/thread.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/app/chrome_dll_resource.h" | 15 #include "chrome/app/chrome_dll_resource.h" |
| 16 #include "chrome/browser/app_modal_dialog.h" | 16 #include "chrome/browser/app_modal_dialog.h" |
| 17 #include "chrome/browser/app_modal_dialog_queue.h" | 17 #include "chrome/browser/app_modal_dialog_queue.h" |
| 18 #include "chrome/browser/automation/automation_extension_function.h" | 18 #include "chrome/browser/automation/automation_extension_function.h" |
| 19 #include "chrome/browser/automation/automation_provider_list.h" | 19 #include "chrome/browser/automation/automation_provider_list.h" |
| 20 #include "chrome/browser/automation/extension_port_container.h" | 20 #include "chrome/browser/automation/extension_port_container.h" |
| 21 #include "chrome/browser/automation/url_request_failed_dns_job.h" | 21 #include "chrome/browser/automation/url_request_failed_dns_job.h" |
| 22 #include "chrome/browser/automation/url_request_mock_http_job.h" | 22 #include "chrome/browser/automation/url_request_mock_http_job.h" |
| 23 #include "chrome/browser/automation/url_request_slow_download_job.h" | 23 #include "chrome/browser/automation/url_request_slow_download_job.h" |
| 24 #include "chrome/browser/blocked_popup_container.h" | 24 #include "chrome/browser/blocked_popup_container.h" |
| 25 #include "chrome/browser/browser_window.h" | 25 #include "chrome/browser/browser_window.h" |
| 26 #include "chrome/browser/dom_operation_notification_details.h" | 26 #include "chrome/browser/dom_operation_notification_details.h" |
| 27 #include "chrome/browser/download/download_manager.h" | 27 #include "chrome/browser/download/download_manager.h" |
| 28 #include "chrome/browser/download/download_shelf.h" |
| 28 #include "chrome/browser/find_bar.h" | 29 #include "chrome/browser/find_bar.h" |
| 29 #include "chrome/browser/find_bar_controller.h" | 30 #include "chrome/browser/find_bar_controller.h" |
| 30 #include "chrome/browser/find_notification_details.h" | 31 #include "chrome/browser/find_notification_details.h" |
| 31 #include "chrome/browser/location_bar.h" | 32 #include "chrome/browser/location_bar.h" |
| 32 #include "chrome/browser/profile_manager.h" | 33 #include "chrome/browser/profile_manager.h" |
| 33 #include "chrome/browser/renderer_host/render_view_host.h" | 34 #include "chrome/browser/renderer_host/render_view_host.h" |
| 34 #include "chrome/browser/ssl/ssl_manager.h" | 35 #include "chrome/browser/ssl/ssl_manager.h" |
| 35 #include "chrome/browser/ssl/ssl_blocking_page.h" | 36 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 36 #include "chrome/browser/tab_contents/tab_contents.h" | 37 #include "chrome/browser/tab_contents/tab_contents.h" |
| 37 #include "chrome/browser/tab_contents/tab_contents_view.h" | 38 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| (...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 SetBooleanPreference) | 1078 SetBooleanPreference) |
| 1078 IPC_MESSAGE_HANDLER(AutomationMsg_GetPageCurrentEncoding, | 1079 IPC_MESSAGE_HANDLER(AutomationMsg_GetPageCurrentEncoding, |
| 1079 GetPageCurrentEncoding) | 1080 GetPageCurrentEncoding) |
| 1080 IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding) | 1081 IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding) |
| 1081 IPC_MESSAGE_HANDLER(AutomationMsg_SavePackageShouldPromptUser, | 1082 IPC_MESSAGE_HANDLER(AutomationMsg_SavePackageShouldPromptUser, |
| 1082 SavePackageShouldPromptUser) | 1083 SavePackageShouldPromptUser) |
| 1083 IPC_MESSAGE_HANDLER(AutomationMsg_WindowTitle, GetWindowTitle) | 1084 IPC_MESSAGE_HANDLER(AutomationMsg_WindowTitle, GetWindowTitle) |
| 1084 IPC_MESSAGE_HANDLER(AutomationMsg_SetEnableExtensionAutomation, | 1085 IPC_MESSAGE_HANDLER(AutomationMsg_SetEnableExtensionAutomation, |
| 1085 SetEnableExtensionAutomation) | 1086 SetEnableExtensionAutomation) |
| 1086 IPC_MESSAGE_HANDLER(AutomationMsg_BlockedPopupCount, GetBlockedPopupCount) | 1087 IPC_MESSAGE_HANDLER(AutomationMsg_BlockedPopupCount, GetBlockedPopupCount) |
| 1088 IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) |
| 1087 IPC_END_MESSAGE_MAP() | 1089 IPC_END_MESSAGE_MAP() |
| 1088 } | 1090 } |
| 1089 | 1091 |
| 1090 void AutomationProvider::ActivateTab(int handle, int at_index, int* status) { | 1092 void AutomationProvider::ActivateTab(int handle, int at_index, int* status) { |
| 1091 *status = -1; | 1093 *status = -1; |
| 1092 if (browser_tracker_->ContainsHandle(handle) && at_index > -1) { | 1094 if (browser_tracker_->ContainsHandle(handle) && at_index > -1) { |
| 1093 Browser* browser = browser_tracker_->GetResource(handle); | 1095 Browser* browser = browser_tracker_->GetResource(handle); |
| 1094 if (at_index >= 0 && at_index < browser->tab_count()) { | 1096 if (at_index >= 0 && at_index < browser->tab_count()) { |
| 1095 browser->SelectTabContentsAt(at_index, true); | 1097 browser->SelectTabContentsAt(at_index, true); |
| 1096 *status = 0; | 1098 *status = 0; |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1951 | 1953 |
| 1952 if (!succeeded) { | 1954 if (!succeeded) { |
| 1953 AutomationMsg_DomOperation::WriteReplyParams(reply_message, std::string()); | 1955 AutomationMsg_DomOperation::WriteReplyParams(reply_message, std::string()); |
| 1954 Send(reply_message); | 1956 Send(reply_message); |
| 1955 } | 1957 } |
| 1956 } | 1958 } |
| 1957 | 1959 |
| 1958 void AutomationProvider::GetShelfVisibility(int handle, bool* visible) { | 1960 void AutomationProvider::GetShelfVisibility(int handle, bool* visible) { |
| 1959 *visible = false; | 1961 *visible = false; |
| 1960 | 1962 |
| 1961 TabContents* tab_contents = GetTabContentsForHandle(handle, NULL); | 1963 if (browser_tracker_->ContainsHandle(handle)) { |
| 1962 if (tab_contents) | 1964 Browser* browser = browser_tracker_->GetResource(handle); |
| 1963 *visible = tab_contents->IsDownloadShelfVisible(); | 1965 if (browser) { |
| 1966 *visible = browser->window()->IsDownloadShelfVisible(); |
| 1967 } |
| 1968 } |
| 1964 } | 1969 } |
| 1965 | 1970 |
| 1971 void AutomationProvider::SetShelfVisibility(int handle, bool visible) { |
| 1972 if (browser_tracker_->ContainsHandle(handle)) { |
| 1973 Browser* browser = browser_tracker_->GetResource(handle); |
| 1974 if (browser) { |
| 1975 if (visible) |
| 1976 browser->window()->GetDownloadShelf()->Show(); |
| 1977 else |
| 1978 browser->window()->GetDownloadShelf()->Close(); |
| 1979 } |
| 1980 } |
| 1981 } |
| 1982 |
| 1983 |
| 1966 void AutomationProvider::GetConstrainedWindowCount(int handle, int* count) { | 1984 void AutomationProvider::GetConstrainedWindowCount(int handle, int* count) { |
| 1967 *count = -1; // -1 is the error code | 1985 *count = -1; // -1 is the error code |
| 1968 if (tab_tracker_->ContainsHandle(handle)) { | 1986 if (tab_tracker_->ContainsHandle(handle)) { |
| 1969 NavigationController* nav_controller = tab_tracker_->GetResource(handle); | 1987 NavigationController* nav_controller = tab_tracker_->GetResource(handle); |
| 1970 TabContents* tab_contents = nav_controller->tab_contents(); | 1988 TabContents* tab_contents = nav_controller->tab_contents(); |
| 1971 if (tab_contents) { | 1989 if (tab_contents) { |
| 1972 *count = static_cast<int>(tab_contents->child_windows_.size()); | 1990 *count = static_cast<int>(tab_contents->child_windows_.size()); |
| 1973 } | 1991 } |
| 1974 } | 1992 } |
| 1975 } | 1993 } |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3000 if (container) { | 3018 if (container) { |
| 3001 *count = static_cast<int>(container->GetBlockedPopupCount()); | 3019 *count = static_cast<int>(container->GetBlockedPopupCount()); |
| 3002 } else { | 3020 } else { |
| 3003 // If we don't have a container, we don't have any blocked popups to | 3021 // If we don't have a container, we don't have any blocked popups to |
| 3004 // contain! | 3022 // contain! |
| 3005 *count = 0; | 3023 *count = 0; |
| 3006 } | 3024 } |
| 3007 } | 3025 } |
| 3008 } | 3026 } |
| 3009 } | 3027 } |
| OLD | NEW |