OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 298 |
299 ExtensionInstallNotificationObserver::ExtensionInstallNotificationObserver( | 299 ExtensionInstallNotificationObserver::ExtensionInstallNotificationObserver( |
300 AutomationProvider* automation, int id, IPC::Message* reply_message) | 300 AutomationProvider* automation, int id, IPC::Message* reply_message) |
301 : automation_(automation), | 301 : automation_(automation), |
302 id_(id), | 302 id_(id), |
303 reply_message_(reply_message) { | 303 reply_message_(reply_message) { |
304 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 304 registrar_.Add(this, NotificationType::EXTENSION_LOADED, |
305 NotificationService::AllSources()); | 305 NotificationService::AllSources()); |
306 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, | 306 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, |
307 NotificationService::AllSources()); | 307 NotificationService::AllSources()); |
308 registrar_.Add(this, NotificationType::EXTENSION_OVERINSTALL_ERROR, | |
309 NotificationService::AllSources()); | |
310 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, | 308 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, |
311 NotificationService::AllSources()); | 309 NotificationService::AllSources()); |
312 } | 310 } |
313 | 311 |
314 ExtensionInstallNotificationObserver::~ExtensionInstallNotificationObserver() { | 312 ExtensionInstallNotificationObserver::~ExtensionInstallNotificationObserver() { |
315 } | 313 } |
316 | 314 |
317 void ExtensionInstallNotificationObserver::Observe( | 315 void ExtensionInstallNotificationObserver::Observe( |
318 NotificationType type, const NotificationSource& source, | 316 NotificationType type, const NotificationSource& source, |
319 const NotificationDetails& details) { | 317 const NotificationDetails& details) { |
320 switch (type.value) { | 318 switch (type.value) { |
321 case NotificationType::EXTENSION_LOADED: | 319 case NotificationType::EXTENSION_LOADED: |
322 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED); | 320 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED); |
323 break; | 321 break; |
324 case NotificationType::EXTENSION_INSTALL_ERROR: | 322 case NotificationType::EXTENSION_INSTALL_ERROR: |
325 case NotificationType::EXTENSION_UPDATE_DISABLED: | 323 case NotificationType::EXTENSION_UPDATE_DISABLED: |
326 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); | 324 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); |
327 break; | 325 break; |
328 case NotificationType::EXTENSION_OVERINSTALL_ERROR: | |
329 SendResponse(AUTOMATION_MSG_EXTENSION_ALREADY_INSTALLED); | |
330 break; | |
331 default: | 326 default: |
332 NOTREACHED(); | 327 NOTREACHED(); |
333 break; | 328 break; |
334 } | 329 } |
335 | 330 |
336 delete this; | 331 delete this; |
337 } | 332 } |
338 | 333 |
339 void ExtensionInstallNotificationObserver::SendResponse( | 334 void ExtensionInstallNotificationObserver::SendResponse( |
340 AutomationMsg_ExtensionResponseValues response) { | 335 AutomationMsg_ExtensionResponseValues response) { |
(...skipping 24 matching lines...) Expand all Loading... |
365 automation_(automation), | 360 automation_(automation), |
366 id_(id), | 361 id_(id), |
367 reply_message_(reply_message), | 362 reply_message_(reply_message), |
368 extension_(NULL) { | 363 extension_(NULL) { |
369 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, | 364 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, |
370 NotificationService::AllSources()); | 365 NotificationService::AllSources()); |
371 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 366 registrar_.Add(this, NotificationType::EXTENSION_LOADED, |
372 NotificationService::AllSources()); | 367 NotificationService::AllSources()); |
373 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, | 368 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, |
374 NotificationService::AllSources()); | 369 NotificationService::AllSources()); |
375 registrar_.Add(this, NotificationType::EXTENSION_OVERINSTALL_ERROR, | |
376 NotificationService::AllSources()); | |
377 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, | 370 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, |
378 NotificationService::AllSources()); | 371 NotificationService::AllSources()); |
379 } | 372 } |
380 | 373 |
381 ExtensionReadyNotificationObserver::~ExtensionReadyNotificationObserver() { | 374 ExtensionReadyNotificationObserver::~ExtensionReadyNotificationObserver() { |
382 } | 375 } |
383 | 376 |
384 void ExtensionReadyNotificationObserver::Observe( | 377 void ExtensionReadyNotificationObserver::Observe( |
385 NotificationType type, const NotificationSource& source, | 378 NotificationType type, const NotificationSource& source, |
386 const NotificationDetails& details) { | 379 const NotificationDetails& details) { |
387 bool success = false; | 380 bool success = false; |
388 switch (type.value) { | 381 switch (type.value) { |
389 case NotificationType::EXTENSION_HOST_DID_STOP_LOADING: | 382 case NotificationType::EXTENSION_HOST_DID_STOP_LOADING: |
390 // Only continue on with this method if our extension has been loaded | 383 // Only continue on with this method if our extension has been loaded |
391 // and all the extension hosts have stopped loading. | 384 // and all the extension hosts have stopped loading. |
392 if (!extension_ || !DidExtensionHostsStopLoading(manager_)) | 385 if (!extension_ || !DidExtensionHostsStopLoading(manager_)) |
393 return; | 386 return; |
394 success = true; | 387 success = true; |
395 break; | 388 break; |
396 case NotificationType::EXTENSION_LOADED: | 389 case NotificationType::EXTENSION_LOADED: |
397 extension_ = Details<Extension>(details).ptr(); | 390 extension_ = Details<Extension>(details).ptr(); |
398 if (!DidExtensionHostsStopLoading(manager_)) | 391 if (!DidExtensionHostsStopLoading(manager_)) |
399 return; | 392 return; |
400 success = true; | 393 success = true; |
401 break; | 394 break; |
402 case NotificationType::EXTENSION_INSTALL_ERROR: | 395 case NotificationType::EXTENSION_INSTALL_ERROR: |
403 case NotificationType::EXTENSION_UPDATE_DISABLED: | 396 case NotificationType::EXTENSION_UPDATE_DISABLED: |
404 case NotificationType::EXTENSION_OVERINSTALL_ERROR: | |
405 success = false; | 397 success = false; |
406 break; | 398 break; |
407 default: | 399 default: |
408 NOTREACHED(); | 400 NOTREACHED(); |
409 break; | 401 break; |
410 } | 402 } |
411 | 403 |
412 if (id_ == AutomationMsg_InstallExtensionAndGetHandle::ID) { | 404 if (id_ == AutomationMsg_InstallExtensionAndGetHandle::ID) { |
413 // A handle of zero indicates an error. | 405 // A handle of zero indicates an error. |
414 int extension_handle = 0; | 406 int extension_handle = 0; |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 type == NotificationType::AUTH_NEEDED) { | 987 type == NotificationType::AUTH_NEEDED) { |
996 AutomationMsg_SendJSONRequest::WriteReplyParams( | 988 AutomationMsg_SendJSONRequest::WriteReplyParams( |
997 reply_message_, std::string("{}"), false); | 989 reply_message_, std::string("{}"), false); |
998 automation_->Send(reply_message_); | 990 automation_->Send(reply_message_); |
999 delete this; | 991 delete this; |
1000 } else { | 992 } else { |
1001 NOTREACHED(); | 993 NOTREACHED(); |
1002 } | 994 } |
1003 } | 995 } |
1004 | 996 |
OLD | NEW |