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/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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 ExtensionSettingsHandler::~ExtensionSettingsHandler() { | 77 ExtensionSettingsHandler::~ExtensionSettingsHandler() { |
78 // There may be pending file dialogs, we need to tell them that we've gone | 78 // There may be pending file dialogs, we need to tell them that we've gone |
79 // away so they don't try and call back to us. | 79 // away so they don't try and call back to us. |
80 if (load_extension_dialog_.get()) | 80 if (load_extension_dialog_.get()) |
81 load_extension_dialog_->ListenerDestroyed(); | 81 load_extension_dialog_->ListenerDestroyed(); |
82 | 82 |
83 registrar_.RemoveAll(); | 83 registrar_.RemoveAll(); |
84 } | 84 } |
85 | 85 |
| 86 // static |
| 87 void ExtensionSettingsHandler::RegisterUserPrefs(PrefService* prefs) { |
| 88 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, |
| 89 false, |
| 90 PrefService::SYNCABLE_PREF); |
| 91 } |
| 92 |
86 void ExtensionSettingsHandler::RegisterMessages() { | 93 void ExtensionSettingsHandler::RegisterMessages() { |
87 web_ui_->RegisterMessageCallback("extensionSettingsRequestExtensionsData", | 94 web_ui_->RegisterMessageCallback("extensionSettingsRequestExtensionsData", |
88 NewCallback(this, | 95 NewCallback(this, |
89 &ExtensionSettingsHandler::HandleRequestExtensionsData)); | 96 &ExtensionSettingsHandler::HandleRequestExtensionsData)); |
90 web_ui_->RegisterMessageCallback("extensionSettingsToggleDeveloperMode", | 97 web_ui_->RegisterMessageCallback("extensionSettingsToggleDeveloperMode", |
91 NewCallback(this, &ExtensionSettingsHandler::HandleToggleDeveloperMode)); | 98 NewCallback(this, &ExtensionSettingsHandler::HandleToggleDeveloperMode)); |
92 web_ui_->RegisterMessageCallback("extensionSettingsInspect", | 99 web_ui_->RegisterMessageCallback("extensionSettingsInspect", |
93 NewCallback(this, &ExtensionSettingsHandler::HandleInspectMessage)); | 100 NewCallback(this, &ExtensionSettingsHandler::HandleInspectMessage)); |
94 web_ui_->RegisterMessageCallback("extensionSettingsReload", | 101 web_ui_->RegisterMessageCallback("extensionSettingsReload", |
95 NewCallback(this, &ExtensionSettingsHandler::HandleReloadMessage)); | 102 NewCallback(this, &ExtensionSettingsHandler::HandleReloadMessage)); |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 GURL(extension_urls::GetWebstoreLaunchURL())).spec()) + | 503 GURL(extension_urls::GetWebstoreLaunchURL())).spec()) + |
497 ASCIIToUTF16("'>") + | 504 ASCIIToUTF16("'>") + |
498 l10n_util::GetStringUTF16(IDS_GET_MORE_EXTENSIONS) + | 505 l10n_util::GetStringUTF16(IDS_GET_MORE_EXTENSIONS) + |
499 ASCIIToUTF16("</a>")); | 506 ASCIIToUTF16("</a>")); |
500 localized_strings->SetString("extensionSettingsExtensionId", | 507 localized_strings->SetString("extensionSettingsExtensionId", |
501 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ID)); | 508 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ID)); |
502 localized_strings->SetString("extensionSettingsExtensionPath", | 509 localized_strings->SetString("extensionSettingsExtensionPath", |
503 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PATH)); | 510 l10n_util::GetStringUTF16(IDS_EXTENSIONS_PATH)); |
504 localized_strings->SetString("extensionSettingsInspectViews", | 511 localized_strings->SetString("extensionSettingsInspectViews", |
505 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSPECT_VIEWS)); | 512 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSPECT_VIEWS)); |
| 513 localized_strings->SetString("viewIncognito", |
| 514 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VIEW_INCOGNITO)); |
506 localized_strings->SetString("extensionSettingsEnable", | 515 localized_strings->SetString("extensionSettingsEnable", |
507 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLE)); | 516 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLE)); |
508 localized_strings->SetString("extensionSettingsEnabled", | 517 localized_strings->SetString("extensionSettingsEnabled", |
509 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLED)); | 518 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLED)); |
510 localized_strings->SetString("extensionSettingsRemove", | 519 localized_strings->SetString("extensionSettingsRemove", |
511 l10n_util::GetStringUTF16(IDS_EXTENSIONS_REMOVE)); | 520 l10n_util::GetStringUTF16(IDS_EXTENSIONS_REMOVE)); |
512 localized_strings->SetString("extensionSettingsEnableIncognito", | 521 localized_strings->SetString("extensionSettingsEnableIncognito", |
513 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLE_INCOGNITO)); | 522 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLE_INCOGNITO)); |
514 localized_strings->SetString("extensionSettingsAllowFileAccess", | 523 localized_strings->SetString("extensionSettingsAllowFileAccess", |
515 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ALLOW_FILE_ACCESS)); | 524 l10n_util::GetStringUTF16(IDS_EXTENSIONS_ALLOW_FILE_ACCESS)); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 const std::vector<ExtensionPage>& pages, bool enabled, bool terminated) { | 619 const std::vector<ExtensionPage>& pages, bool enabled, bool terminated) { |
611 DictionaryValue* extension_data = new DictionaryValue(); | 620 DictionaryValue* extension_data = new DictionaryValue(); |
612 GURL icon = | 621 GURL icon = |
613 ExtensionIconSource::GetIconURL(extension, | 622 ExtensionIconSource::GetIconURL(extension, |
614 Extension::EXTENSION_ICON_MEDIUM, | 623 Extension::EXTENSION_ICON_MEDIUM, |
615 ExtensionIconSet::MATCH_BIGGER, | 624 ExtensionIconSet::MATCH_BIGGER, |
616 !enabled, NULL); | 625 !enabled, NULL); |
617 extension_data->SetString("id", extension->id()); | 626 extension_data->SetString("id", extension->id()); |
618 extension_data->SetString("name", extension->name()); | 627 extension_data->SetString("name", extension->name()); |
619 extension_data->SetString("description", extension->description()); | 628 extension_data->SetString("description", extension->description()); |
620 extension_data->SetString("path", extension->path().value()); | 629 if (extension->location() == Extension::LOAD) |
| 630 extension_data->SetString("path", extension->path().value()); |
621 extension_data->SetString("version", extension->version()->GetString()); | 631 extension_data->SetString("version", extension->version()->GetString()); |
622 extension_data->SetString("icon", icon.spec()); | 632 extension_data->SetString("icon", icon.spec()); |
623 extension_data->SetBoolean("isUnpacked", | 633 extension_data->SetBoolean("isUnpacked", |
624 extension->location() == Extension::LOAD); | 634 extension->location() == Extension::LOAD); |
625 extension_data->SetBoolean("mayDisable", | 635 extension_data->SetBoolean("mayDisable", |
626 Extension::UserMayDisable(extension->location())); | 636 Extension::UserMayDisable(extension->location())); |
627 extension_data->SetBoolean("enabled", enabled); | 637 extension_data->SetBoolean("enabled", enabled); |
628 extension_data->SetBoolean("terminated", terminated); | 638 extension_data->SetBoolean("terminated", terminated); |
629 extension_data->SetBoolean("enabledIncognito", | 639 extension_data->SetBoolean("enabledIncognito", |
630 service ? service->IsIncognitoEnabled(extension->id()) : false); | 640 service ? service->IsIncognitoEnabled(extension->id()) : false); |
631 extension_data->SetBoolean("wantsFileAccess", extension->wants_file_access()); | 641 extension_data->SetBoolean("wantsFileAccess", extension->wants_file_access()); |
632 extension_data->SetBoolean("allowFileAccess", | 642 extension_data->SetBoolean("allowFileAccess", |
633 service ? service->AllowFileAccess(extension) : false); | 643 service ? service->AllowFileAccess(extension) : false); |
634 extension_data->SetBoolean("allow_reload", | 644 extension_data->SetBoolean("allow_reload", |
635 extension->location() == Extension::LOAD); | 645 extension->location() == Extension::LOAD); |
636 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); | 646 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 continue; | 734 continue; |
725 } else if (!extension->web_extent().MatchesURL(url)) { | 735 } else if (!extension->web_extent().MatchesURL(url)) { |
726 continue; | 736 continue; |
727 } | 737 } |
728 | 738 |
729 result->push_back( | 739 result->push_back( |
730 ExtensionPage(url, process->id(), host->routing_id(), | 740 ExtensionPage(url, process->id(), host->routing_id(), |
731 process->browser_context()->IsOffTheRecord())); | 741 process->browser_context()->IsOffTheRecord())); |
732 } | 742 } |
733 } | 743 } |
OLD | NEW |