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

Side by Side Diff: chrome/browser/extensions/extensions_ui.cc

Issue 7920023: Fix crashes related to the extension uninstall dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make Show() pure virtual Created 9 years, 3 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/extensions/extensions_ui.h" 5 #include "chrome/browser/extensions/extensions_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, 275 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED,
276 NotificationService::AllSources()); 276 NotificationService::AllSources());
277 registrar_.Add(this, 277 registrar_.Add(this,
278 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, 278 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED,
279 NotificationService::AllSources()); 279 NotificationService::AllSources());
280 } 280 }
281 281
282 ExtensionUninstallDialog* ExtensionsDOMHandler::GetExtensionUninstallDialog() { 282 ExtensionUninstallDialog* ExtensionsDOMHandler::GetExtensionUninstallDialog() {
283 if (!extension_uninstall_dialog_.get()) { 283 if (!extension_uninstall_dialog_.get()) {
284 extension_uninstall_dialog_.reset( 284 extension_uninstall_dialog_.reset(
285 new ExtensionUninstallDialog(Profile::FromWebUI(web_ui_))); 285 ExtensionUninstallDialog::Create(Profile::FromWebUI(web_ui_), this));
286 } 286 }
287 return extension_uninstall_dialog_.get(); 287 return extension_uninstall_dialog_.get();
288 } 288 }
289 289
290 void ExtensionsDOMHandler::HandleToggleDeveloperMode(const ListValue* args) { 290 void ExtensionsDOMHandler::HandleToggleDeveloperMode(const ListValue* args) {
291 Profile* profile = Profile::FromWebUI(web_ui_); 291 Profile* profile = Profile::FromWebUI(web_ui_);
292 bool developer_mode = 292 bool developer_mode =
293 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); 293 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode);
294 profile->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode, 294 profile->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode,
295 !developer_mode); 295 !developer_mode);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable " 406 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable "
407 << "was made. Extension id : " << extension->id(); 407 << "was made. Extension id : " << extension->id();
408 return; 408 return;
409 } 409 }
410 410
411 if (!extension_id_prompting_.empty()) 411 if (!extension_id_prompting_.empty())
412 return; // Only one prompt at a time. 412 return; // Only one prompt at a time.
413 413
414 extension_id_prompting_ = extension_id; 414 extension_id_prompting_ = extension_id;
415 415
416 GetExtensionUninstallDialog()->ConfirmUninstall(this, extension); 416 GetExtensionUninstallDialog()->ConfirmUninstall(extension);
417 } 417 }
418 418
419 void ExtensionsDOMHandler::ExtensionDialogAccepted() { 419 void ExtensionsDOMHandler::ExtensionUninstallAccepted() {
420 DCHECK(!extension_id_prompting_.empty()); 420 DCHECK(!extension_id_prompting_.empty());
421 421
422 bool was_terminated = false; 422 bool was_terminated = false;
423 423
424 // The extension can be uninstalled in another window while the UI was 424 // The extension can be uninstalled in another window while the UI was
425 // showing. Do nothing in that case. 425 // showing. Do nothing in that case.
426 const Extension* extension = 426 const Extension* extension =
427 extension_service_->GetExtensionById(extension_id_prompting_, true); 427 extension_service_->GetExtensionById(extension_id_prompting_, true);
428 if (!extension) { 428 if (!extension) {
429 extension = extension_service_->GetTerminatedExtension( 429 extension = extension_service_->GetTerminatedExtension(
430 extension_id_prompting_); 430 extension_id_prompting_);
431 was_terminated = true; 431 was_terminated = true;
432 } 432 }
433 if (!extension) 433 if (!extension)
434 return; 434 return;
435 435
436 extension_service_->UninstallExtension(extension_id_prompting_, 436 extension_service_->UninstallExtension(extension_id_prompting_,
437 false /* external_uninstall */, NULL); 437 false /* external_uninstall */, NULL);
438 extension_id_prompting_ = ""; 438 extension_id_prompting_ = "";
439 439
440 // There will be no EXTENSION_UNLOADED notification for terminated 440 // There will be no EXTENSION_UNLOADED notification for terminated
441 // extensions as they were already unloaded. 441 // extensions as they were already unloaded.
442 if (was_terminated) 442 if (was_terminated)
443 HandleRequestExtensionsData(NULL); 443 HandleRequestExtensionsData(NULL);
444 } 444 }
445 445
446 void ExtensionsDOMHandler::ExtensionDialogCanceled() { 446 void ExtensionsDOMHandler::ExtensionUninstallCanceled() {
447 extension_id_prompting_ = ""; 447 extension_id_prompting_ = "";
448 } 448 }
449 449
450 void ExtensionsDOMHandler::HandleOptionsMessage(const ListValue* args) { 450 void ExtensionsDOMHandler::HandleOptionsMessage(const ListValue* args) {
451 const Extension* extension = GetExtension(args); 451 const Extension* extension = GetExtension(args);
452 if (!extension || extension->options_url().is_empty()) 452 if (!extension || extension->options_url().is_empty())
453 return; 453 return;
454 Profile::FromWebUI(web_ui_)->GetExtensionProcessManager()->OpenOptionsPage( 454 Profile::FromWebUI(web_ui_)->GetExtensionProcessManager()->OpenOptionsPage(
455 extension, NULL); 455 extension, NULL);
456 } 456 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 return ResourceBundle::GetSharedInstance(). 797 return ResourceBundle::GetSharedInstance().
798 LoadDataResourceBytes(IDR_PLUGIN); 798 LoadDataResourceBytes(IDR_PLUGIN);
799 } 799 }
800 800
801 // static 801 // static
802 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { 802 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) {
803 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, 803 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode,
804 false, 804 false,
805 PrefService::SYNCABLE_PREF); 805 PrefService::SYNCABLE_PREF);
806 } 806 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_ui.h ('k') | chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698