| 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 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 active_match_ordinal_, find_details->number_of_matches()); | 1187 active_match_ordinal_, find_details->number_of_matches()); |
| 1188 automation_->Send(reply_message_.release()); | 1188 automation_->Send(reply_message_.release()); |
| 1189 } | 1189 } |
| 1190 } | 1190 } |
| 1191 } | 1191 } |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 // static | 1194 // static |
| 1195 const int FindInPageNotificationObserver::kFindInPageRequestId = -1; | 1195 const int FindInPageNotificationObserver::kFindInPageRequestId = -1; |
| 1196 | 1196 |
| 1197 DomOperationObserver::DomOperationObserver() { | 1197 DomOperationObserver::DomOperationObserver(int automation_id) |
| 1198 : automation_id_(automation_id) { |
| 1198 registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, | 1199 registrar_.Add(this, content::NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 1199 content::NotificationService::AllSources()); | 1200 content::NotificationService::AllSources()); |
| 1200 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | 1201 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, |
| 1201 content::NotificationService::AllSources()); | 1202 content::NotificationService::AllSources()); |
| 1202 registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 1203 registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 1203 content::NotificationService::AllSources()); | 1204 content::NotificationService::AllSources()); |
| 1204 } | 1205 } |
| 1205 | 1206 |
| 1206 DomOperationObserver::~DomOperationObserver() {} | 1207 DomOperationObserver::~DomOperationObserver() {} |
| 1207 | 1208 |
| 1208 void DomOperationObserver::Observe( | 1209 void DomOperationObserver::Observe( |
| 1209 int type, const content::NotificationSource& source, | 1210 int type, const content::NotificationSource& source, |
| 1210 const content::NotificationDetails& details) { | 1211 const content::NotificationDetails& details) { |
| 1211 if (type == content::NOTIFICATION_DOM_OPERATION_RESPONSE) { | 1212 if (type == content::NOTIFICATION_DOM_OPERATION_RESPONSE) { |
| 1212 content::Details<DomOperationNotificationDetails> dom_op_details(details); | 1213 content::Details<DomOperationNotificationDetails> dom_op_details(details); |
| 1213 OnDomOperationCompleted(dom_op_details->json); | 1214 if (dom_op_details->automation_id == automation_id_) |
| 1215 OnDomOperationCompleted(dom_op_details->json); |
| 1214 } else if (type == chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN) { | 1216 } else if (type == chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN) { |
| 1215 OnModalDialogShown(); | 1217 OnModalDialogShown(); |
| 1216 } else if (type == chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED) { | 1218 } else if (type == chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED) { |
| 1217 WebContents* web_contents = content::Source<WebContents>(source).ptr(); | 1219 WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
| 1218 if (web_contents) { | 1220 if (web_contents) { |
| 1219 TabContentsWrapper* wrapper = | 1221 TabContentsWrapper* wrapper = |
| 1220 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); | 1222 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); |
| 1221 if (wrapper && | 1223 if (wrapper && |
| 1222 wrapper->content_settings() && | 1224 wrapper->content_settings() && |
| 1223 wrapper->content_settings()->IsContentBlocked( | 1225 wrapper->content_settings()->IsContentBlocked( |
| 1224 CONTENT_SETTINGS_TYPE_JAVASCRIPT)) { | 1226 CONTENT_SETTINGS_TYPE_JAVASCRIPT)) { |
| 1225 OnJavascriptBlocked(); | 1227 OnJavascriptBlocked(); |
| 1226 } | 1228 } |
| 1227 } | 1229 } |
| 1228 } | 1230 } |
| 1229 } | 1231 } |
| 1230 | 1232 |
| 1231 DomOperationMessageSender::DomOperationMessageSender( | 1233 DomOperationMessageSender::DomOperationMessageSender( |
| 1232 AutomationProvider* automation, | 1234 AutomationProvider* automation, |
| 1233 IPC::Message* reply_message, | 1235 IPC::Message* reply_message, |
| 1234 bool use_json_interface) | 1236 bool use_json_interface) |
| 1235 : automation_(automation->AsWeakPtr()), | 1237 : DomOperationObserver(0), |
| 1238 automation_(automation->AsWeakPtr()), |
| 1236 reply_message_(reply_message), | 1239 reply_message_(reply_message), |
| 1237 use_json_interface_(use_json_interface) { | 1240 use_json_interface_(use_json_interface) { |
| 1238 } | 1241 } |
| 1239 | 1242 |
| 1240 DomOperationMessageSender::~DomOperationMessageSender() {} | 1243 DomOperationMessageSender::~DomOperationMessageSender() {} |
| 1241 | 1244 |
| 1242 void DomOperationMessageSender::OnDomOperationCompleted( | 1245 void DomOperationMessageSender::OnDomOperationCompleted( |
| 1243 const std::string& json) { | 1246 const std::string& json) { |
| 1244 if (automation_) { | 1247 if (automation_) { |
| 1245 if (use_json_interface_) { | 1248 if (use_json_interface_) { |
| (...skipping 1884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3130 } | 3133 } |
| 3131 | 3134 |
| 3132 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); | 3135 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); |
| 3133 if (host->extension_id() == extension_id_ && | 3136 if (host->extension_id() == extension_id_ && |
| 3134 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { | 3137 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { |
| 3135 AutomationJSONReply(automation_, reply_message_.release()) | 3138 AutomationJSONReply(automation_, reply_message_.release()) |
| 3136 .SendSuccess(NULL); | 3139 .SendSuccess(NULL); |
| 3137 delete this; | 3140 delete this; |
| 3138 } | 3141 } |
| 3139 } | 3142 } |
| OLD | NEW |