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

Side by Side Diff: chrome/browser/extensions/api/developer_private/developer_private_api.cc

Issue 2529083002: Make extensions developer mode adhere to policy (Closed)
Patch Set: Guard against Preference not being found Created 4 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/api/developer_private/developer_private_api. h" 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 UMA_HISTOGRAM_BOOLEAN("ExtensionSettings.ShouldDoVerificationCheck", 157 UMA_HISTOGRAM_BOOLEAN("ExtensionSettings.ShouldDoVerificationCheck",
158 should_do_verification_check); 158 should_do_verification_check);
159 if (should_do_verification_check) 159 if (should_do_verification_check)
160 InstallVerifier::Get(context)->VerifyAllExtensions(); 160 InstallVerifier::Get(context)->VerifyAllExtensions();
161 } 161 }
162 162
163 std::unique_ptr<developer::ProfileInfo> CreateProfileInfo(Profile* profile) { 163 std::unique_ptr<developer::ProfileInfo> CreateProfileInfo(Profile* profile) {
164 std::unique_ptr<developer::ProfileInfo> info(new developer::ProfileInfo()); 164 std::unique_ptr<developer::ProfileInfo> info(new developer::ProfileInfo());
165 info->is_supervised = profile->IsSupervised(); 165 info->is_supervised = profile->IsSupervised();
166 PrefService* prefs = profile->GetPrefs(); 166 PrefService* prefs = profile->GetPrefs();
167 const PrefService::Preference* pref =
168 prefs->FindPreference(prefs::kExtensionsUIDeveloperMode);
167 info->is_incognito_available = 169 info->is_incognito_available =
168 IncognitoModePrefs::GetAvailability(prefs) != 170 IncognitoModePrefs::GetAvailability(prefs) !=
169 IncognitoModePrefs::DISABLED; 171 IncognitoModePrefs::DISABLED;
172 info->is_developer_mode_disabled_by_policy = pref && pref->IsManaged();
Bernhard Bauer 2016/11/28 17:11:03 When would the preference not be found? Usually we
pmarko 2016/11/29 12:40:21 Good point, tests were working fine, this was just
170 info->in_developer_mode = 173 info->in_developer_mode =
171 !info->is_supervised && 174 !info->is_supervised &&
172 prefs->GetBoolean(prefs::kExtensionsUIDeveloperMode); 175 prefs->GetBoolean(prefs::kExtensionsUIDeveloperMode);
173 info->app_info_dialog_enabled = CanShowAppInfoDialog(); 176 info->app_info_dialog_enabled = CanShowAppInfoDialog();
174 info->can_load_unpacked = 177 info->can_load_unpacked =
175 !ExtensionManagementFactory::GetForBrowserContext(profile) 178 !ExtensionManagementFactory::GetForBrowserContext(profile)
176 ->BlacklistedByDefault(); 179 ->BlacklistedByDefault();
177 return info; 180 return info;
178 } 181 }
179 182
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 594
592 ExtensionFunction::ResponseAction 595 ExtensionFunction::ResponseAction
593 DeveloperPrivateUpdateProfileConfigurationFunction::Run() { 596 DeveloperPrivateUpdateProfileConfigurationFunction::Run() {
594 std::unique_ptr<developer::UpdateProfileConfiguration::Params> params( 597 std::unique_ptr<developer::UpdateProfileConfiguration::Params> params(
595 developer::UpdateProfileConfiguration::Params::Create(*args_)); 598 developer::UpdateProfileConfiguration::Params::Create(*args_));
596 EXTENSION_FUNCTION_VALIDATE(params); 599 EXTENSION_FUNCTION_VALIDATE(params);
597 600
598 const developer::ProfileConfigurationUpdate& update = params->update; 601 const developer::ProfileConfigurationUpdate& update = params->update;
599 PrefService* prefs = GetProfile()->GetPrefs(); 602 PrefService* prefs = GetProfile()->GetPrefs();
600 if (update.in_developer_mode) { 603 if (update.in_developer_mode) {
601 if (GetProfile()->IsSupervised()) 604 if (GetProfile()->IsSupervised())
Devlin 2016/11/28 17:34:01 We should add a check here. Otherwise, the only g
pmarko 2016/11/29 12:40:21 I'm not sure it's necessary -- I had a check here
Devlin 2016/11/30 19:19:50 I'll trust you and bauerb - my pref knowledge is l
pmarko 2016/12/02 00:20:07 Sorry, I almost forgot -- added.
602 return RespondNow(Error(kCannotUpdateSupervisedProfileSettingsError)); 605 return RespondNow(Error(kCannotUpdateSupervisedProfileSettingsError));
603 prefs->SetBoolean(prefs::kExtensionsUIDeveloperMode, 606 prefs->SetBoolean(prefs::kExtensionsUIDeveloperMode,
604 *update.in_developer_mode); 607 *update.in_developer_mode);
605 } 608 }
606 609
607 return RespondNow(NoArguments()); 610 return RespondNow(NoArguments());
608 } 611 }
609 612
610 DeveloperPrivateUpdateExtensionConfigurationFunction:: 613 DeveloperPrivateUpdateExtensionConfigurationFunction::
611 ~DeveloperPrivateUpdateExtensionConfigurationFunction() {} 614 ~DeveloperPrivateUpdateExtensionConfigurationFunction() {}
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 update.extension_id, update.command_name, *update.keybinding); 1456 update.extension_id, update.command_name, *update.keybinding);
1454 } 1457 }
1455 1458
1456 return RespondNow(NoArguments()); 1459 return RespondNow(NoArguments());
1457 } 1460 }
1458 1461
1459 1462
1460 } // namespace api 1463 } // namespace api
1461 1464
1462 } // namespace extensions 1465 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698