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

Side by Side Diff: chrome/browser/ui/webui/options/extension_settings_handler.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/ui/webui/options/extension_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/extension_settings_handler.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 NotificationService::AllSources()); 203 NotificationService::AllSources());
204 registrar_.Add(this, 204 registrar_.Add(this,
205 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, 205 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED,
206 NotificationService::AllSources()); 206 NotificationService::AllSources());
207 } 207 }
208 208
209 ExtensionUninstallDialog* 209 ExtensionUninstallDialog*
210 ExtensionSettingsHandler::GetExtensionUninstallDialog() { 210 ExtensionSettingsHandler::GetExtensionUninstallDialog() {
211 if (!extension_uninstall_dialog_.get()) { 211 if (!extension_uninstall_dialog_.get()) {
212 extension_uninstall_dialog_.reset( 212 extension_uninstall_dialog_.reset(
213 new ExtensionUninstallDialog(Profile::FromWebUI(web_ui_))); 213 ExtensionUninstallDialog::Create(Profile::FromWebUI(web_ui_), this));
214 } 214 }
215 return extension_uninstall_dialog_.get(); 215 return extension_uninstall_dialog_.get();
216 } 216 }
217 217
218 void ExtensionSettingsHandler::HandleToggleDeveloperMode( 218 void ExtensionSettingsHandler::HandleToggleDeveloperMode(
219 const ListValue* args) { 219 const ListValue* args) {
220 Profile* profile = Profile::FromWebUI(web_ui_); 220 Profile* profile = Profile::FromWebUI(web_ui_);
221 bool developer_mode = 221 bool developer_mode =
222 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); 222 profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode);
223 profile->GetPrefs()->SetBoolean( 223 profile->GetPrefs()->SetBoolean(
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable " 338 LOG(ERROR) << "Attempt to uninstall an extension that is non-usermanagable "
339 << "was made. Extension id : " << extension->id(); 339 << "was made. Extension id : " << extension->id();
340 return; 340 return;
341 } 341 }
342 342
343 if (!extension_id_prompting_.empty()) 343 if (!extension_id_prompting_.empty())
344 return; // Only one prompt at a time. 344 return; // Only one prompt at a time.
345 345
346 extension_id_prompting_ = extension_id; 346 extension_id_prompting_ = extension_id;
347 347
348 GetExtensionUninstallDialog()->ConfirmUninstall(this, extension); 348 GetExtensionUninstallDialog()->ConfirmUninstall(extension);
349 } 349 }
350 350
351 void ExtensionSettingsHandler::ExtensionDialogAccepted() { 351 void ExtensionSettingsHandler::ExtensionUninstallAccepted() {
352 DCHECK(!extension_id_prompting_.empty()); 352 DCHECK(!extension_id_prompting_.empty());
353 353
354 bool was_terminated = false; 354 bool was_terminated = false;
355 355
356 // The extension can be uninstalled in another window while the UI was 356 // The extension can be uninstalled in another window while the UI was
357 // showing. Do nothing in that case. 357 // showing. Do nothing in that case.
358 const Extension* extension = 358 const Extension* extension =
359 extension_service_->GetExtensionById(extension_id_prompting_, true); 359 extension_service_->GetExtensionById(extension_id_prompting_, true);
360 if (!extension) { 360 if (!extension) {
361 extension = extension_service_->GetTerminatedExtension( 361 extension = extension_service_->GetTerminatedExtension(
362 extension_id_prompting_); 362 extension_id_prompting_);
363 was_terminated = true; 363 was_terminated = true;
364 } 364 }
365 if (!extension) 365 if (!extension)
366 return; 366 return;
367 367
368 extension_service_->UninstallExtension(extension_id_prompting_, 368 extension_service_->UninstallExtension(extension_id_prompting_,
369 false, // External uninstall. 369 false, // External uninstall.
370 NULL); // Error. 370 NULL); // Error.
371 extension_id_prompting_ = ""; 371 extension_id_prompting_ = "";
372 372
373 // There will be no EXTENSION_UNLOADED notification for terminated 373 // There will be no EXTENSION_UNLOADED notification for terminated
374 // extensions as they were already unloaded. 374 // extensions as they were already unloaded.
375 if (was_terminated) 375 if (was_terminated)
376 HandleRequestExtensionsData(NULL); 376 HandleRequestExtensionsData(NULL);
377 } 377 }
378 378
379 void ExtensionSettingsHandler::ExtensionDialogCanceled() { 379 void ExtensionSettingsHandler::ExtensionUninstallCanceled() {
380 extension_id_prompting_ = ""; 380 extension_id_prompting_ = "";
381 } 381 }
382 382
383 void ExtensionSettingsHandler::HandleOptionsMessage(const ListValue* args) { 383 void ExtensionSettingsHandler::HandleOptionsMessage(const ListValue* args) {
384 const Extension* extension = GetExtension(args); 384 const Extension* extension = GetExtension(args);
385 if (!extension || extension->options_url().is_empty()) 385 if (!extension || extension->options_url().is_empty())
386 return; 386 return;
387 Profile::FromWebUI(web_ui_)->GetExtensionProcessManager()->OpenOptionsPage( 387 Profile::FromWebUI(web_ui_)->GetExtensionProcessManager()->OpenOptionsPage(
388 extension, NULL); 388 extension, NULL);
389 } 389 }
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 continue; 724 continue;
725 } else if (!extension->web_extent().MatchesURL(url)) { 725 } else if (!extension->web_extent().MatchesURL(url)) {
726 continue; 726 continue;
727 } 727 }
728 728
729 result->push_back( 729 result->push_back(
730 ExtensionPage(url, process->id(), host->routing_id(), 730 ExtensionPage(url, process->id(), host->routing_id(),
731 process->browser_context()->IsOffTheRecord())); 731 process->browser_context()->IsOffTheRecord()));
732 } 732 }
733 } 733 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/extension_settings_handler.h ('k') | views/window/dialog_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698