diff options
4 files changed, 43 insertions, 4 deletions
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 13b8e3a..190170d 100644 --- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc +++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc @@ -223,6 +223,13 @@ DeveloperPrivateEventRouter::DeveloperPrivateEventRouter(Profile* profile) extension_management_observer_.Add( ExtensionManagementFactory::GetForBrowserContext(profile)); command_service_observer_.Add(CommandService::Get(profile)); + pref_change_registrar_.Init(profile->GetPrefs()); + // The unretained is safe, since the PrefChangeRegistrar unregisters the + // callback on destruction. + pref_change_registrar_.Add( + prefs::kExtensionsUIDeveloperMode, + base::Bind(&DeveloperPrivateEventRouter::OnProfilePrefChanged, + base::Unretained(this))); } DeveloperPrivateEventRouter::~DeveloperPrivateEventRouter() { @@ -352,6 +359,15 @@ void DeveloperPrivateEventRouter::ExtensionWarningsChanged( BroadcastItemStateChanged(developer::EVENT_TYPE_WARNINGS_CHANGED, id); } +void DeveloperPrivateEventRouter::OnProfilePrefChanged() { + scoped_ptr<base::ListValue> args(new base::ListValue()); + args->Append(CreateProfileInfo(profile_)->ToValue()); + scoped_ptr<Event> event( + new Event(events::DEVELOPER_PRIVATE_ON_PROFILE_STATE_CHANGED, + developer::OnProfileStateChanged::kEventName, args.Pass())); + event_router_->BroadcastEvent(event.Pass()); +} + void DeveloperPrivateEventRouter::BroadcastItemStateChanged( developer::EventType event_type, const std::string& extension_id) { diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.h b/chrome/browser/extensions/api/developer_private/developer_private_api.h index 27b5e5c..41fe433 100644 --- a/chrome/browser/extensions/api/developer_private/developer_private_api.h +++ b/chrome/browser/extensions/api/developer_private/developer_private_api.h @@ -9,6 +9,7 @@ #include "base/files/file.h" #include "base/memory/weak_ptr.h" +#include "base/prefs/pref_change_registrar.h" #include "base/scoped_observer.h" #include "chrome/browser/extensions/api/commands/command_service.h" #include "chrome/browser/extensions/api/developer_private/entry_picker.h" @@ -120,6 +121,9 @@ class DeveloperPrivateEventRouter : public ExtensionRegistryObserver, void ExtensionWarningsChanged( const ExtensionIdSet& affected_extensions) override; + // Handles a profile preferance change. + void OnProfilePrefChanged(); + // Broadcasts an event to all listeners. void BroadcastItemStateChanged(api::developer_private::EventType event_type, const std::string& id); @@ -160,6 +164,8 @@ class DeveloperPrivateEventRouter : public ExtensionRegistryObserver, // when, e.g., the Apps Developer Tool throws an error. std::set<std::string> extension_ids_; + PrefChangeRegistrar pref_change_registrar_; + base::WeakPtrFactory<DeveloperPrivateEventRouter> weak_factory_; DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateEventRouter); diff --git a/chrome/browser/extensions/api/developer_private/extension_info_generator.cc b/chrome/browser/extensions/api/developer_private/extension_info_generator.cc index b88bdbc..316997c 100644 --- a/chrome/browser/extensions/api/developer_private/extension_info_generator.cc +++ b/chrome/browser/extensions/api/developer_private/extension_info_generator.cc @@ -22,6 +22,7 @@ #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" #include "chrome/common/extensions/command.h" #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" +#include "chrome/common/pref_names.h" #include "chrome/grit/generated_resources.h" #include "content/public/browser/render_frame_host.h" #include "extensions/browser/extension_error.h" @@ -403,9 +404,12 @@ void ExtensionInfoGenerator::CreateExtensionInfoHelper( info->incognito_access.is_active = util::IsIncognitoEnabled(extension.id(), browser_context_); - // Install warnings (only if unpacked and no error console). + // Install warnings, but only if unpacked, the error console isn't enabled + // (otherwise it shows these), and we're in developer mode (normal users don't + // need to see these). if (!error_console_enabled && - Manifest::IsUnpackedLocation(extension.location())) { + Manifest::IsUnpackedLocation(extension.location()) && + profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode)) { const std::vector<InstallWarning>& install_warnings = extension.install_warnings(); for (const InstallWarning& warning : install_warnings) diff --git a/chrome/browser/resources/extensions/extensions.js b/chrome/browser/resources/extensions/extensions.js index 3be5ca2..90e512c 100644 --- a/chrome/browser/resources/extensions/extensions.js +++ b/chrome/browser/resources/extensions/extensions.js @@ -126,6 +126,12 @@ cr.define('extensions', function() { dragEnabled_: false, /** + * True if the page has finished the initial load. + * @private {boolean} + */ + hasLoaded_: false, + + /** * Perform initial setup. */ initialize: function() { @@ -241,7 +247,11 @@ cr.define('extensions', function() { * @private */ update_: function(profileInfo) { - this.setLoading_(true); + // We only set the page to be loading if we haven't already finished an + // initial load, because otherwise the updates are all incremental and + // don't need to display the interstitial spinner. + if (!this.hasLoaded_) + this.setLoading_(true); webuiResponded = true; /** @const */ @@ -260,7 +270,10 @@ cr.define('extensions', function() { extensionList.updateExtensionsData( profileInfo.isIncognitoAvailable, profileInfo.appInfoDialogEnabled).then(function() { - this.setLoading_(false); + if (!this.hasLoaded_) { + this.hasLoaded_ = true; + this.setLoading_(false); + } this.onExtensionCountChanged(); }.bind(this)); }, |