Chromium Code Reviews| Index: chrome/browser/extensions/api/developer_private/developer_private_api.cc |
| diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc |
| index df72337f423cc0bc1e7bcbbb566f66b5bcb3e837..3c0dc1e6c03cd18e3e79fe1fc4c720c6ae09b5a5 100644 |
| --- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc |
| +++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc |
| @@ -155,6 +155,23 @@ void PerformVerificationCheck(content::BrowserContext* context) { |
| InstallVerifier::Get(context)->VerifyAllExtensions(); |
| } |
| +scoped_ptr<developer::ProfileInfo> CreateProfileInfo(Profile* profile) { |
| + scoped_ptr<developer::ProfileInfo> info(new developer::ProfileInfo()); |
| + info->is_supervised = profile->IsSupervised(); |
| + PrefService* prefs = profile->GetPrefs(); |
| + info->is_incognito_available = |
| + IncognitoModePrefs::GetAvailability(prefs) != |
| + IncognitoModePrefs::DISABLED; |
| + info->in_developer_mode = |
| + !info->is_supervised && |
|
not at google - send to devlin
2015/05/19 20:35:04
I wonder why supervised users are called out here.
Devlin
2015/05/19 22:01:08
(Since this isn't a behavior change, I'll commit n
Marc Treib
2015/05/20 08:07:27
This is from before my time, so I might be missing
not at google - send to devlin
2015/05/20 21:32:32
Yeah seems like a perfectly reasonable thing for s
|
| + prefs->GetBoolean(prefs::kExtensionsUIDeveloperMode); |
| + info->app_info_dialog_enabled = CanShowAppInfoDialog(); |
| + info->can_load_unpacked = |
| + !ExtensionManagementFactory::GetForBrowserContext(profile) |
| + ->BlacklistedByDefault(); |
| + return info.Pass(); |
| +} |
| + |
| } // namespace |
| namespace ChoosePath = api::developer_private::ChoosePath; |
| @@ -188,6 +205,9 @@ DeveloperPrivateEventRouter::DeveloperPrivateEventRouter(Profile* profile) |
| process_manager_observer_(this), |
| app_window_registry_observer_(this), |
| extension_action_api_observer_(this), |
| + warning_service_observer_(this), |
| + extension_prefs_observer_(this), |
| + extension_management_observer_(this), |
| profile_(profile), |
| event_router_(EventRouter::Get(profile_)), |
| weak_factory_(this) { |
| @@ -196,6 +216,10 @@ DeveloperPrivateEventRouter::DeveloperPrivateEventRouter(Profile* profile) |
| process_manager_observer_.Add(ProcessManager::Get(profile)); |
| app_window_registry_observer_.Add(AppWindowRegistry::Get(profile)); |
| extension_action_api_observer_.Add(ExtensionActionAPI::Get(profile)); |
| + warning_service_observer_.Add(WarningService::Get(profile)); |
| + extension_prefs_observer_.Add(ExtensionPrefs::Get(profile)); |
| + extension_management_observer_.Add( |
| + ExtensionManagementFactory::GetForBrowserContext(profile)); |
| } |
| DeveloperPrivateEventRouter::~DeveloperPrivateEventRouter() { |
| @@ -291,6 +315,27 @@ void DeveloperPrivateEventRouter::OnExtensionActionVisibilityChanged( |
| BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id); |
| } |
| +void DeveloperPrivateEventRouter::OnExtensionDisableReasonsChanged( |
| + const std::string& extension_id, int disable_reasons) { |
| + BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id); |
| +} |
| + |
| +void DeveloperPrivateEventRouter::OnExtensionManagementSettingsChanged() { |
| + scoped_ptr<base::DictionaryValue> dict = |
| + CreateProfileInfo(profile_)->ToValue(); |
| + scoped_ptr<base::ListValue> args(new base::ListValue()); |
| + args->Append(dict.release()); |
|
not at google - send to devlin
2015/05/19 20:35:04
I'd prefer inlining |dict| as just CreateProfileIn
Devlin
2015/05/19 22:01:07
I'm not sure I buy your safety argument, but I lik
|
| + scoped_ptr<Event> event(new Event( |
| + developer::OnProfileStateChanged::kEventName, args.Pass())); |
| + event_router_->BroadcastEvent(event.Pass()); |
| +} |
| + |
| +void DeveloperPrivateEventRouter::ExtensionWarningsChanged( |
| + const std::set<std::string>& affected_extensions) { |
| + for (const std::string& id : affected_extensions) |
| + BroadcastItemStateChanged(developer::EVENT_TYPE_WARNINGS_CHANGED, id); |
|
not at google - send to devlin
2015/05/19 20:35:04
These event broadcasts in loops make me sad. We sh
Devlin
2015/05/19 22:01:07
We should be, but that's a much larger change. An
|
| +} |
| + |
| void DeveloperPrivateEventRouter::BroadcastItemStateChanged( |
| developer::EventType event_type, |
| const std::string& extension_id) { |
| @@ -499,18 +544,7 @@ DeveloperPrivateGetProfileConfigurationFunction:: |
| ExtensionFunction::ResponseAction |
| DeveloperPrivateGetProfileConfigurationFunction::Run() { |
| - developer::ProfileInfo info; |
| - info.is_supervised = GetProfile()->IsSupervised(); |
| - info.is_incognito_available = |
| - IncognitoModePrefs::GetAvailability(GetProfile()->GetPrefs()) != |
| - IncognitoModePrefs::DISABLED; |
| - info.in_developer_mode = |
| - !info.is_supervised && |
| - GetProfile()->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); |
| - info.app_info_dialog_enabled = CanShowAppInfoDialog(); |
| - info.can_load_unpacked = |
| - !ExtensionManagementFactory::GetForBrowserContext(browser_context()) |
| - ->BlacklistedByDefault(); |
| + scoped_ptr<developer::ProfileInfo> info = CreateProfileInfo(GetProfile()); |
| // If this is called from the chrome://extensions page, we use this as a |
| // heuristic that it's a good time to verify installs. We do this on startup, |
| @@ -519,7 +553,7 @@ DeveloperPrivateGetProfileConfigurationFunction::Run() { |
| if (source_context_type() == Feature::WEBUI_CONTEXT) |
| PerformVerificationCheck(browser_context()); |
| - return RespondNow(OneArgument(info.ToValue())); |
| + return RespondNow(OneArgument(info->ToValue())); |
| } |
| DeveloperPrivateUpdateProfileConfigurationFunction:: |