Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 7548024: Refactor: Make PyAuto InstallExtension() take a string. Delete dead code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixup per kkania. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 457
458 bool DidExtensionHostsStopLoading(ExtensionProcessManager* manager) { 458 bool DidExtensionHostsStopLoading(ExtensionProcessManager* manager) {
459 for (ExtensionProcessManager::const_iterator iter = manager->begin(); 459 for (ExtensionProcessManager::const_iterator iter = manager->begin();
460 iter != manager->end(); ++iter) { 460 iter != manager->end(); ++iter) {
461 if (!(*iter)->did_stop_loading()) 461 if (!(*iter)->did_stop_loading())
462 return false; 462 return false;
463 } 463 }
464 return true; 464 return true;
465 } 465 }
466 466
467 ExtensionInstallNotificationObserver::ExtensionInstallNotificationObserver(
468 AutomationProvider* automation, int id, IPC::Message* reply_message)
469 : automation_(automation->AsWeakPtr()),
470 id_(id),
471 reply_message_(reply_message) {
472 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
473 NotificationService::AllSources());
474 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR,
475 NotificationService::AllSources());
476 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
477 NotificationService::AllSources());
478 }
479
480 ExtensionInstallNotificationObserver::~ExtensionInstallNotificationObserver() {
481 }
482
483 void ExtensionInstallNotificationObserver::Observe(
484 int type, const NotificationSource& source,
485 const NotificationDetails& details) {
486 switch (type) {
487 case chrome::NOTIFICATION_EXTENSION_LOADED:
488 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED);
489 break;
490 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR:
491 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED:
492 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_FAILED);
493 break;
494 default:
495 NOTREACHED();
496 break;
497 }
498
499 delete this;
500 }
501
502 void ExtensionInstallNotificationObserver::SendResponse(
503 AutomationMsg_ExtensionResponseValues response) {
504 if (!automation_ || !reply_message_.get()) {
505 delete this;
506 return;
507 }
508
509 switch (id_) {
510 case AutomationMsg_InstallExtension::ID:
511 AutomationMsg_InstallExtension::WriteReplyParams(reply_message_.get(),
512 response);
513 break;
514 default:
515 NOTREACHED();
516 break;
517 }
518
519 automation_->Send(reply_message_.release());
520 }
521
522 ExtensionUninstallObserver::ExtensionUninstallObserver( 467 ExtensionUninstallObserver::ExtensionUninstallObserver(
523 AutomationProvider* automation, 468 AutomationProvider* automation,
524 IPC::Message* reply_message, 469 IPC::Message* reply_message,
525 const std::string& id) 470 const std::string& id)
526 : automation_(automation->AsWeakPtr()), 471 : automation_(automation->AsWeakPtr()),
527 reply_message_(reply_message), 472 reply_message_(reply_message),
528 id_(id) { 473 id_(id) {
529 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 474 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
530 NotificationService::AllSources()); 475 NotificationService::AllSources());
531 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, 476 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 return; 564 return;
620 break; 565 break;
621 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: 566 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR:
622 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: 567 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED:
623 break; 568 break;
624 default: 569 default:
625 NOTREACHED(); 570 NOTREACHED();
626 break; 571 break;
627 } 572 }
628 573
629 if (id_ == AutomationMsg_InstallExtensionAndGetHandle::ID) { 574 if (id_ == AutomationMsg_InstallExtension::ID) {
630 // A handle of zero indicates an error. 575 // A handle of zero indicates an error.
631 int extension_handle = 0; 576 int extension_handle = 0;
632 if (extension_) 577 if (extension_)
633 extension_handle = automation_->AddExtension(extension_); 578 extension_handle = automation_->AddExtension(extension_);
634 AutomationMsg_InstallExtensionAndGetHandle::WriteReplyParams( 579 AutomationMsg_InstallExtension::WriteReplyParams(
635 reply_message_.get(), extension_handle); 580 reply_message_.get(), extension_handle);
636 } else if (id_ == AutomationMsg_EnableExtension::ID) { 581 } else if (id_ == AutomationMsg_EnableExtension::ID) {
637 AutomationMsg_EnableExtension::WriteReplyParams(reply_message_.get(), true); 582 AutomationMsg_EnableExtension::WriteReplyParams(reply_message_.get(), true);
638 } else { 583 } else {
639 NOTREACHED(); 584 NOTREACHED();
640 LOG(ERROR) << "Cannot write reply params for unknown message id."; 585 LOG(ERROR) << "Cannot write reply params for unknown message id.";
641 } 586 }
642 587
643 automation_->Send(reply_message_.release()); 588 automation_->Send(reply_message_.release());
644 delete this; 589 delete this;
(...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after
2650 void DragTargetDropAckNotificationObserver::Observe( 2595 void DragTargetDropAckNotificationObserver::Observe(
2651 int type, 2596 int type,
2652 const NotificationSource& source, 2597 const NotificationSource& source,
2653 const NotificationDetails& details) { 2598 const NotificationDetails& details) {
2654 if (automation_) { 2599 if (automation_) {
2655 AutomationJSONReply(automation_, 2600 AutomationJSONReply(automation_,
2656 reply_message_.release()).SendSuccess(NULL); 2601 reply_message_.release()).SendSuccess(NULL);
2657 } 2602 }
2658 delete this; 2603 delete this;
2659 } 2604 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.h ('k') | chrome/common/automation_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698