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

Unified Diff: chrome/browser/ui/webui/extensions/extension_settings_handler.cc

Issue 1060993003: [Extensions UI] Use developerPrivate API for profile configuration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/extensions/extension_settings_handler.cc
diff --git a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
index 649ff8dbed53e584cf4c322b924387cb2f1c82c0..bb8ca4e69ffe217f036d148c769746aebb9f1fb8 100644
--- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
+++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
@@ -11,7 +11,6 @@
#include "base/bind_helpers.h"
#include "base/location.h"
#include "base/message_loop/message_loop.h"
-#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -24,11 +23,9 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/extension_ui_util.h"
-#include "chrome/browser/extensions/install_verifier.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/extensions/webstore_reinstaller.h"
#include "chrome/browser/platform_util.h"
-#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/apps/app_info_dialog.h"
#include "chrome/browser/ui/browser.h"
@@ -338,12 +335,6 @@ void ExtensionSettingsHandler::RegisterMessages() {
extension_service_ =
extensions::ExtensionSystem::Get(profile)->extension_service();
- web_ui()->RegisterMessageCallback("extensionSettingsRequestExtensionsData",
- base::Bind(&ExtensionSettingsHandler::HandleRequestExtensionsData,
- AsWeakPtr()));
- web_ui()->RegisterMessageCallback("extensionSettingsToggleDeveloperMode",
- base::Bind(&ExtensionSettingsHandler::HandleToggleDeveloperMode,
- AsWeakPtr()));
web_ui()->RegisterMessageCallback("extensionSettingsLaunch",
base::Bind(&ExtensionSettingsHandler::HandleLaunchMessage,
AsWeakPtr()));
@@ -356,9 +347,6 @@ void ExtensionSettingsHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("extensionSettingsAutoupdate",
base::Bind(&ExtensionSettingsHandler::HandleAutoUpdateMessage,
AsWeakPtr()));
- web_ui()->RegisterMessageCallback("extensionSettingsDismissADTPromo",
- base::Bind(&ExtensionSettingsHandler::HandleDismissADTPromoMessage,
- AsWeakPtr()));
web_ui()->RegisterMessageCallback("extensionSettingsShowPath",
base::Bind(&ExtensionSettingsHandler::HandleShowPath,
AsWeakPtr()));
@@ -446,83 +434,6 @@ void ExtensionSettingsHandler::ReloadUnpackedExtensions() {
}
}
-void ExtensionSettingsHandler::HandleRequestExtensionsData(
- const base::ListValue* args) {
- // The items which are to be written into results are also described in
- // chrome/browser/resources/extensions/extensions.js in @typedef for
- // ExtensionDataResponse. Please update it whenever you add or remove any keys
- // here.
- base::DictionaryValue results;
-
- Profile* profile = Profile::FromWebUI(web_ui());
-
- bool is_supervised = profile->IsSupervised();
- bool incognito_available =
- IncognitoModePrefs::GetAvailability(profile->GetPrefs()) !=
- IncognitoModePrefs::DISABLED;
- bool developer_mode =
- !is_supervised &&
- profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode);
- results.SetBoolean("profileIsSupervised", is_supervised);
- results.SetBoolean("incognitoAvailable", incognito_available);
- results.SetBoolean("developerMode", developer_mode);
- results.SetBoolean("enableAppInfoDialog", CanShowAppInfoDialog());
-
- // Promote the Chrome Apps & Extensions Developer Tools if they are not
- // installed and the user has not previously dismissed the warning.
- ExtensionRegistry* registry = ExtensionRegistry::Get(profile);
- bool promote_apps_dev_tools = false;
- if (!registry->GetExtensionById(kAppsDeveloperToolsExtensionId,
- ExtensionRegistry::EVERYTHING) &&
- !profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDismissedADTPromo)) {
- promote_apps_dev_tools = true;
- }
- results.SetBoolean("promoteAppsDevTools", promote_apps_dev_tools);
-
- const bool load_unpacked_disabled =
- ExtensionManagementFactory::GetForBrowserContext(profile)
- ->BlacklistedByDefault();
- results.SetBoolean("loadUnpackedDisabled", load_unpacked_disabled);
-
- web_ui()->CallJavascriptFunction(
- "extensions.ExtensionSettings.returnExtensionsData", results);
-
- MaybeRegisterForNotifications();
-
- scoped_ptr<ExtensionSet> extensions =
- registry->GenerateInstalledExtensionsSet(ExtensionRegistry::ENABLED |
- ExtensionRegistry::DISABLED |
- ExtensionRegistry::TERMINATED);
- ExtensionPrefs* prefs = ExtensionPrefs::Get(profile);
- bool should_do_verification_check = false;
- for (const scoped_refptr<const Extension>& extension : *extensions) {
- if (ui_util::ShouldDisplayInExtensionSettings(extension.get(), profile)) {
- int disable_reasons = prefs->GetDisableReasons(extension->id());
- if ((disable_reasons & Extension::DISABLE_NOT_VERIFIED)) {
- should_do_verification_check = true;
- break;
- }
- }
- }
-
- UMA_HISTOGRAM_BOOLEAN("ExtensionSettings.ShouldDoVerificationCheck",
- should_do_verification_check);
- if (should_do_verification_check)
- ExtensionSystem::Get(profile)->install_verifier()->VerifyAllExtensions();
-}
-
-void ExtensionSettingsHandler::HandleToggleDeveloperMode(
- const base::ListValue* args) {
- Profile* profile = Profile::FromWebUI(web_ui());
- if (profile->IsSupervised())
- return;
-
- bool developer_mode_on;
- CHECK(args->GetBoolean(0, &developer_mode_on));
- profile->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode,
- developer_mode_on);
-}
-
void ExtensionSettingsHandler::HandleLaunchMessage(
const base::ListValue* args) {
CHECK_EQ(1U, args->GetSize());
@@ -567,13 +478,6 @@ void ExtensionSettingsHandler::HandleAutoUpdateMessage(
}
}
-void ExtensionSettingsHandler::HandleDismissADTPromoMessage(
- const base::ListValue* args) {
- DCHECK(args->empty());
- Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(
- prefs::kExtensionsUIDismissedADTPromo, true);
-}
-
void ExtensionSettingsHandler::HandleShowPath(const base::ListValue* args) {
DCHECK(!args->empty());
std::string extension_id = base::UTF16ToUTF8(ExtractStringValue(args));
@@ -599,8 +503,10 @@ const Extension* ExtensionSettingsHandler::GetActiveExtension(
void ExtensionSettingsHandler::MaybeUpdateAfterNotification() {
content::WebContents* contents = web_ui()->GetWebContents();
- if (!ignore_notifications_ && contents && contents->GetRenderViewHost())
- HandleRequestExtensionsData(NULL);
+ if (!ignore_notifications_ && contents && contents->GetRenderViewHost()) {
+ web_ui()->CallJavascriptFunction(
+ "extensions.ExtensionSettings.onExtensionsChanged");
+ }
deleting_rvh_ = NULL;
}

Powered by Google App Engine
This is Rietveld 408576698