OLD | NEW |
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 NotificationType::BACKGROUND_CONTENTS_NAVIGATED, | 311 NotificationType::BACKGROUND_CONTENTS_NAVIGATED, |
312 NotificationService::AllSources()); | 312 NotificationService::AllSources()); |
313 registrar_.Add(this, | 313 registrar_.Add(this, |
314 NotificationType::BACKGROUND_CONTENTS_DELETED, | 314 NotificationType::BACKGROUND_CONTENTS_DELETED, |
315 NotificationService::AllSources()); | 315 NotificationService::AllSources()); |
316 registrar_.Add(this, | 316 registrar_.Add(this, |
317 NotificationType::EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, | 317 NotificationType::EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |
318 NotificationService::AllSources()); | 318 NotificationService::AllSources()); |
319 } | 319 } |
320 | 320 |
321 ExtensionInstallUI* ExtensionsDOMHandler::GetExtensionInstallUI() { | 321 ExtensionGenericDialog* ExtensionsDOMHandler::GetExtensionGenericDialog() { |
322 if (!install_ui_.get()) | 322 if (!extension_generic_dialog_.get()) { |
323 install_ui_.reset(new ExtensionInstallUI(web_ui_->GetProfile())); | 323 extension_generic_dialog_.reset( |
324 return install_ui_.get(); | 324 new ExtensionGenericDialog(web_ui_->GetProfile())); |
| 325 } |
| 326 return extension_generic_dialog_.get(); |
325 } | 327 } |
326 | 328 |
327 void ExtensionsDOMHandler::HandleToggleDeveloperMode(const ListValue* args) { | 329 void ExtensionsDOMHandler::HandleToggleDeveloperMode(const ListValue* args) { |
328 bool developer_mode = web_ui_->GetProfile()->GetPrefs() | 330 bool developer_mode = web_ui_->GetProfile()->GetPrefs() |
329 ->GetBoolean(prefs::kExtensionsUIDeveloperMode); | 331 ->GetBoolean(prefs::kExtensionsUIDeveloperMode); |
330 web_ui_->GetProfile()->GetPrefs()->SetBoolean( | 332 web_ui_->GetProfile()->GetPrefs()->SetBoolean( |
331 prefs::kExtensionsUIDeveloperMode, !developer_mode); | 333 prefs::kExtensionsUIDeveloperMode, !developer_mode); |
332 } | 334 } |
333 | 335 |
334 void ExtensionsDOMHandler::HandleInspectMessage(const ListValue* args) { | 336 void ExtensionsDOMHandler::HandleInspectMessage(const ListValue* args) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 if (!extension) | 424 if (!extension) |
423 extension = extensions_service_->GetTerminatedExtension(extension_id); | 425 extension = extensions_service_->GetTerminatedExtension(extension_id); |
424 if (!extension) | 426 if (!extension) |
425 return; | 427 return; |
426 | 428 |
427 if (!extension_id_prompting_.empty()) | 429 if (!extension_id_prompting_.empty()) |
428 return; // Only one prompt at a time. | 430 return; // Only one prompt at a time. |
429 | 431 |
430 extension_id_prompting_ = extension_id; | 432 extension_id_prompting_ = extension_id; |
431 | 433 |
432 GetExtensionInstallUI()->ConfirmUninstall(this, extension); | 434 GetExtensionGenericDialog()->ConfirmUninstall(this, extension); |
433 } | 435 } |
434 | 436 |
435 void ExtensionsDOMHandler::InstallUIProceed() { | 437 void ExtensionsDOMHandler::ExtensionDialogAccepted() { |
436 DCHECK(!extension_id_prompting_.empty()); | 438 DCHECK(!extension_id_prompting_.empty()); |
437 | 439 |
438 bool was_terminated = false; | 440 bool was_terminated = false; |
439 | 441 |
440 // The extension can be uninstalled in another window while the UI was | 442 // The extension can be uninstalled in another window while the UI was |
441 // showing. Do nothing in that case. | 443 // showing. Do nothing in that case. |
442 const Extension* extension = | 444 const Extension* extension = |
443 extensions_service_->GetExtensionById(extension_id_prompting_, true); | 445 extensions_service_->GetExtensionById(extension_id_prompting_, true); |
444 if (!extension) { | 446 if (!extension) { |
445 extension = extensions_service_->GetTerminatedExtension( | 447 extension = extensions_service_->GetTerminatedExtension( |
446 extension_id_prompting_); | 448 extension_id_prompting_); |
447 was_terminated = true; | 449 was_terminated = true; |
448 } | 450 } |
449 if (!extension) | 451 if (!extension) |
450 return; | 452 return; |
451 | 453 |
452 extensions_service_->UninstallExtension(extension_id_prompting_, | 454 extensions_service_->UninstallExtension(extension_id_prompting_, |
453 false /* external_uninstall */); | 455 false /* external_uninstall */); |
454 extension_id_prompting_ = ""; | 456 extension_id_prompting_ = ""; |
455 | 457 |
456 // There will be no EXTENSION_UNLOADED notification for terminated | 458 // There will be no EXTENSION_UNLOADED notification for terminated |
457 // extensions as they were already unloaded. | 459 // extensions as they were already unloaded. |
458 if (was_terminated) | 460 if (was_terminated) |
459 HandleRequestExtensionsData(NULL); | 461 HandleRequestExtensionsData(NULL); |
460 } | 462 } |
461 | 463 |
462 void ExtensionsDOMHandler::InstallUIAbort() { | 464 void ExtensionsDOMHandler::ExtensionDialogCanceled() { |
463 extension_id_prompting_ = ""; | 465 extension_id_prompting_ = ""; |
464 } | 466 } |
465 | 467 |
466 void ExtensionsDOMHandler::HandleOptionsMessage(const ListValue* args) { | 468 void ExtensionsDOMHandler::HandleOptionsMessage(const ListValue* args) { |
467 const Extension* extension = GetExtension(args); | 469 const Extension* extension = GetExtension(args); |
468 if (!extension || extension->options_url().is_empty()) | 470 if (!extension || extension->options_url().is_empty()) |
469 return; | 471 return; |
470 web_ui_->GetProfile()->GetExtensionProcessManager()->OpenOptionsPage( | 472 web_ui_->GetProfile()->GetExtensionProcessManager()->OpenOptionsPage( |
471 extension, NULL); | 473 extension, NULL); |
472 } | 474 } |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 // static | 874 // static |
873 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { | 875 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { |
874 return ResourceBundle::GetSharedInstance(). | 876 return ResourceBundle::GetSharedInstance(). |
875 LoadDataResourceBytes(IDR_PLUGIN); | 877 LoadDataResourceBytes(IDR_PLUGIN); |
876 } | 878 } |
877 | 879 |
878 // static | 880 // static |
879 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { | 881 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { |
880 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); | 882 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); |
881 } | 883 } |
OLD | NEW |