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/automation_provider_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 | 794 |
795 if (type == chrome::NOTIFICATION_BROWSER_OPENED) { | 795 if (type == chrome::NOTIFICATION_BROWSER_OPENED) { |
796 // Store the new browser ID and continue waiting for a new tab within it | 796 // Store the new browser ID and continue waiting for a new tab within it |
797 // to stop loading. | 797 // to stop loading. |
798 new_window_id_ = ExtensionTabUtil::GetWindowId( | 798 new_window_id_ = ExtensionTabUtil::GetWindowId( |
799 content::Source<Browser>(source).ptr()); | 799 content::Source<Browser>(source).ptr()); |
800 } else if (type == content::NOTIFICATION_LOAD_STOP) { | 800 } else if (type == content::NOTIFICATION_LOAD_STOP) { |
801 // Only send the result if the loaded tab is in the new window. | 801 // Only send the result if the loaded tab is in the new window. |
802 NavigationController* controller = | 802 NavigationController* controller = |
803 content::Source<NavigationController>(source).ptr(); | 803 content::Source<NavigationController>(source).ptr(); |
804 TabContents* tab = TabContents::GetOwningTabContentsForWebContents( | 804 TabContents* tab = |
805 controller->GetWebContents()); | 805 TabContents::FromWebContents(controller->GetWebContents()); |
806 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; | 806 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; |
807 if (window_id == new_window_id_) { | 807 if (window_id == new_window_id_) { |
808 if (for_browser_command_) { | 808 if (for_browser_command_) { |
809 AutomationMsg_WindowExecuteCommand::WriteReplyParams( | 809 AutomationMsg_WindowExecuteCommand::WriteReplyParams( |
810 reply_message_.get(), true); | 810 reply_message_.get(), true); |
811 } | 811 } |
812 automation_->Send(reply_message_.release()); | 812 automation_->Send(reply_message_.release()); |
813 delete this; | 813 delete this; |
814 return; | 814 return; |
815 } | 815 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 const content::NotificationDetails& details) { | 1111 const content::NotificationDetails& details) { |
1112 if (type == content::NOTIFICATION_DOM_OPERATION_RESPONSE) { | 1112 if (type == content::NOTIFICATION_DOM_OPERATION_RESPONSE) { |
1113 content::Details<DomOperationNotificationDetails> dom_op_details(details); | 1113 content::Details<DomOperationNotificationDetails> dom_op_details(details); |
1114 if (dom_op_details->automation_id == automation_id_) | 1114 if (dom_op_details->automation_id == automation_id_) |
1115 OnDomOperationCompleted(dom_op_details->json); | 1115 OnDomOperationCompleted(dom_op_details->json); |
1116 } else if (type == chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN) { | 1116 } else if (type == chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN) { |
1117 OnModalDialogShown(); | 1117 OnModalDialogShown(); |
1118 } else if (type == chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED) { | 1118 } else if (type == chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED) { |
1119 WebContents* web_contents = content::Source<WebContents>(source).ptr(); | 1119 WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
1120 if (web_contents) { | 1120 if (web_contents) { |
1121 TabContents* tab_contents = | 1121 TabContents* tab_contents = TabContents::FromWebContents(web_contents); |
1122 TabContents::GetOwningTabContentsForWebContents(web_contents); | |
1123 if (tab_contents && | 1122 if (tab_contents && |
1124 tab_contents->content_settings() && | 1123 tab_contents->content_settings() && |
1125 tab_contents->content_settings()->IsContentBlocked( | 1124 tab_contents->content_settings()->IsContentBlocked( |
1126 CONTENT_SETTINGS_TYPE_JAVASCRIPT)) { | 1125 CONTENT_SETTINGS_TYPE_JAVASCRIPT)) { |
1127 OnJavascriptBlocked(); | 1126 OnJavascriptBlocked(); |
1128 } | 1127 } |
1129 } | 1128 } |
1130 } | 1129 } |
1131 } | 1130 } |
1132 | 1131 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 void TabLanguageDeterminedObserver::Observe( | 1251 void TabLanguageDeterminedObserver::Observe( |
1253 int type, const content::NotificationSource& source, | 1252 int type, const content::NotificationSource& source, |
1254 const content::NotificationDetails& details) { | 1253 const content::NotificationDetails& details) { |
1255 DCHECK(type == chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED); | 1254 DCHECK(type == chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED); |
1256 | 1255 |
1257 if (!automation_) { | 1256 if (!automation_) { |
1258 delete this; | 1257 delete this; |
1259 return; | 1258 return; |
1260 } | 1259 } |
1261 | 1260 |
1262 TranslateTabHelper* helper = TabContents::GetOwningTabContentsForWebContents( | 1261 TranslateTabHelper* helper = |
1263 web_contents_)->translate_tab_helper(); | 1262 TabContents::FromWebContents(web_contents_)->translate_tab_helper(); |
1264 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 1263 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
1265 return_value->SetBoolean("page_translated", | 1264 return_value->SetBoolean("page_translated", |
1266 helper->language_state().IsPageTranslated()); | 1265 helper->language_state().IsPageTranslated()); |
1267 return_value->SetBoolean( | 1266 return_value->SetBoolean( |
1268 "can_translate_page", TranslatePrefs::CanTranslate( | 1267 "can_translate_page", TranslatePrefs::CanTranslate( |
1269 automation_->profile()->GetPrefs(), | 1268 automation_->profile()->GetPrefs(), |
1270 helper->language_state().original_language(), | 1269 helper->language_state().original_language(), |
1271 web_contents_->GetURL())); | 1270 web_contents_->GetURL())); |
1272 return_value->SetString("original_language", | 1271 return_value->SetString("original_language", |
1273 helper->language_state().original_language()); | 1272 helper->language_state().original_language()); |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2144 AutomationJSONReply(automation_, | 2143 AutomationJSONReply(automation_, |
2145 reply_message_.release()).SendSuccess(NULL); | 2144 reply_message_.release()).SendSuccess(NULL); |
2146 } | 2145 } |
2147 delete this; | 2146 delete this; |
2148 return; | 2147 return; |
2149 } else { | 2148 } else { |
2150 // The app has launched only if the loaded tab is in the new window. | 2149 // The app has launched only if the loaded tab is in the new window. |
2151 NavigationController* controller = | 2150 NavigationController* controller = |
2152 content::Source<NavigationController>(source).ptr(); | 2151 content::Source<NavigationController>(source).ptr(); |
2153 TabContents* tab = | 2152 TabContents* tab = |
2154 TabContents::GetOwningTabContentsForWebContents( | 2153 TabContents::FromWebContents(controller->GetWebContents()); |
2155 controller->GetWebContents()); | |
2156 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; | 2154 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; |
2157 if (window_id == new_window_id_) { | 2155 if (window_id == new_window_id_) { |
2158 if (automation_) { | 2156 if (automation_) { |
2159 AutomationJSONReply(automation_, | 2157 AutomationJSONReply(automation_, |
2160 reply_message_.release()).SendSuccess(NULL); | 2158 reply_message_.release()).SendSuccess(NULL); |
2161 } | 2159 } |
2162 delete this; | 2160 delete this; |
2163 return; | 2161 return; |
2164 } | 2162 } |
2165 } | 2163 } |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2971 } | 2969 } |
2972 } else if (type == chrome::NOTIFICATION_BROWSER_OPENED) { | 2970 } else if (type == chrome::NOTIFICATION_BROWSER_OPENED) { |
2973 // Store the new browser ID and continue waiting for a new tab within it | 2971 // Store the new browser ID and continue waiting for a new tab within it |
2974 // to stop loading. | 2972 // to stop loading. |
2975 new_window_id_ = ExtensionTabUtil::GetWindowId( | 2973 new_window_id_ = ExtensionTabUtil::GetWindowId( |
2976 content::Source<Browser>(source).ptr()); | 2974 content::Source<Browser>(source).ptr()); |
2977 } else if (type == content::NOTIFICATION_LOAD_STOP) { | 2975 } else if (type == content::NOTIFICATION_LOAD_STOP) { |
2978 // Only send the result if the loaded tab is in the new window. | 2976 // Only send the result if the loaded tab is in the new window. |
2979 NavigationController* controller = | 2977 NavigationController* controller = |
2980 content::Source<NavigationController>(source).ptr(); | 2978 content::Source<NavigationController>(source).ptr(); |
2981 TabContents* tab = TabContents::GetOwningTabContentsForWebContents( | 2979 TabContents* tab = |
2982 controller->GetWebContents()); | 2980 TabContents::FromWebContents(controller->GetWebContents()); |
2983 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; | 2981 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; |
2984 if (window_id == new_window_id_) { | 2982 if (window_id == new_window_id_) { |
2985 if (automation_) { | 2983 if (automation_) { |
2986 AutomationJSONReply(automation_, reply_message_.release()) | 2984 AutomationJSONReply(automation_, reply_message_.release()) |
2987 .SendSuccess(NULL); | 2985 .SendSuccess(NULL); |
2988 } | 2986 } |
2989 delete this; | 2987 delete this; |
2990 } | 2988 } |
2991 } else { | 2989 } else { |
2992 NOTREACHED(); | 2990 NOTREACHED(); |
(...skipping 24 matching lines...) Expand all Loading... |
3017 } | 3015 } |
3018 | 3016 |
3019 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); | 3017 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); |
3020 if (host->extension_id() == extension_id_ && | 3018 if (host->extension_id() == extension_id_ && |
3021 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { | 3019 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { |
3022 AutomationJSONReply(automation_, reply_message_.release()) | 3020 AutomationJSONReply(automation_, reply_message_.release()) |
3023 .SendSuccess(NULL); | 3021 .SendSuccess(NULL); |
3024 delete this; | 3022 delete this; |
3025 } | 3023 } |
3026 } | 3024 } |
OLD | NEW |