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

Side by Side Diff: chrome/browser/extensions/api/management/management_api.cc

Issue 282133008: Don't crash when two extension uninstall prompts are shown at the same time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: error msg Created 6 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/extensions/api/management/management_api.h" 5 #include "chrome/browser/extensions/api/management/management_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 } 573 }
574 574
575 // static 575 // static
576 void ManagementUninstallFunctionBase::SetAutoConfirmForTest( 576 void ManagementUninstallFunctionBase::SetAutoConfirmForTest(
577 bool should_proceed) { 577 bool should_proceed) {
578 auto_confirm_for_test = should_proceed ? PROCEED : ABORT; 578 auto_confirm_for_test = should_proceed ? PROCEED : ABORT;
579 } 579 }
580 580
581 void ManagementUninstallFunctionBase::Finish(bool should_uninstall) { 581 void ManagementUninstallFunctionBase::Finish(bool should_uninstall) {
582 if (should_uninstall) { 582 if (should_uninstall) {
583 bool success = service()->UninstallExtension( 583 // The extension can be uninstalled in another window while the UI was
584 extension_id_, 584 // showing. Do nothing in that case.
585 false, /* external uninstall */ 585 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile());
586 NULL); 586 const Extension* extension = registry->GetExtensionById(
587 extension_id_, ExtensionRegistry::EVERYTHING);
588 if (!extension) {
589 error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
590 extension_id_);
591 SendResponse(false);
592 } else {
593 bool success =
594 service()->UninstallExtension(extension_id_,
595 false, /* external uninstall */
596 NULL);
587 597
588 // TODO set error_ if !success 598 // TODO set error_ if !success
589 SendResponse(success); 599 SendResponse(success);
600 }
590 } else { 601 } else {
591 error_ = ErrorUtils::FormatErrorMessage( 602 error_ = ErrorUtils::FormatErrorMessage(
592 keys::kUninstallCanceledError, extension_id_); 603 keys::kUninstallCanceledError, extension_id_);
593 SendResponse(false); 604 SendResponse(false);
594 } 605 }
595 606
596 } 607 }
597 608
598 void ManagementUninstallFunctionBase::ExtensionUninstallAccepted() { 609 void ManagementUninstallFunctionBase::ExtensionUninstallAccepted() {
599 Finish(true); 610 Finish(true);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 return g_factory.Pointer(); 825 return g_factory.Pointer();
815 } 826 }
816 827
817 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { 828 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) {
818 management_event_router_.reset( 829 management_event_router_.reset(
819 new ManagementEventRouter(Profile::FromBrowserContext(browser_context_))); 830 new ManagementEventRouter(Profile::FromBrowserContext(browser_context_)));
820 EventRouter::Get(browser_context_)->UnregisterObserver(this); 831 EventRouter::Get(browser_context_)->UnregisterObserver(this);
821 } 832 }
822 833
823 } // namespace extensions 834 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698