Commit 7dd05290 authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

[Extensions] Move remaining notifications out of ExtensionSettingsHandler

Move the remaining notifications from ExtensionSettingsHandler to the
DeveloperPrivate API.
Also adjust the WarningService observer method to include a set of modified
extensions.

BUG=461039

Review URL: https://codereview.chromium.org/1146693004

Cr-Commit-Position: refs/heads/master@{#330633}
parent 14769fd8
......@@ -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 &&
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,25 @@ 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::ListValue> args(new base::ListValue());
args->Append(CreateProfileInfo(profile_)->ToValue());
scoped_ptr<Event> event(new Event(
developer::OnProfileStateChanged::kEventName, args.Pass()));
event_router_->BroadcastEvent(event.Pass());
}
void DeveloperPrivateEventRouter::ExtensionWarningsChanged(
const ExtensionIdSet& affected_extensions) {
for (const ExtensionId& id : affected_extensions)
BroadcastItemStateChanged(developer::EVENT_TYPE_WARNINGS_CHANGED, id);
}
void DeveloperPrivateEventRouter::BroadcastItemStateChanged(
developer::EventType event_type,
const std::string& extension_id) {
......@@ -499,18 +542,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 +551,7 @@ DeveloperPrivateGetProfileConfigurationFunction::Run() {
if (source_context_type() == Feature::WEBUI_CONTEXT)
PerformVerificationCheck(browser_context());
return RespondNow(OneArgument(info.ToValue()));
return RespondNow(OneArgument(info->ToValue()));
}
DeveloperPrivateUpdateProfileConfigurationFunction::
......
......@@ -15,6 +15,7 @@
#include "chrome/browser/extensions/api/file_system/file_system_api.h"
#include "chrome/browser/extensions/chrome_extension_function.h"
#include "chrome/browser/extensions/error_console/error_console.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/extension_uninstall_dialog.h"
#include "chrome/browser/extensions/pack_extension_job.h"
#include "chrome/common/extensions/api/developer_private.h"
......@@ -22,8 +23,10 @@
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_prefs_observer.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/process_manager_observer.h"
#include "extensions/browser/warning_service.h"
#include "storage/browser/fileapi/file_system_context.h"
#include "storage/browser/fileapi/file_system_operation.h"
#include "ui/shell_dialogs/select_file_dialog.h"
......@@ -52,7 +55,10 @@ class DeveloperPrivateEventRouter : public ExtensionRegistryObserver,
public ErrorConsole::Observer,
public ProcessManagerObserver,
public AppWindowRegistry::Observer,
public ExtensionActionAPI::Observer {
public ExtensionActionAPI::Observer,
public ExtensionPrefsObserver,
public ExtensionManagement::Observer,
public WarningService::Observer {
public:
explicit DeveloperPrivateEventRouter(Profile* profile);
~DeveloperPrivateEventRouter() override;
......@@ -95,6 +101,17 @@ class DeveloperPrivateEventRouter : public ExtensionRegistryObserver,
void OnExtensionActionVisibilityChanged(const std::string& extension_id,
bool is_now_visible) override;
// ExtensionPrefsObserver:
void OnExtensionDisableReasonsChanged(const std::string& extension_id,
int disable_reasons) override;
// ExtensionManagement::Observer:
void OnExtensionManagementSettingsChanged() override;
// WarningService::Observer:
void ExtensionWarningsChanged(
const ExtensionIdSet& affected_extensions) override;
// Broadcasts an event to all listeners.
void BroadcastItemStateChanged(api::developer_private::EventType event_type,
const std::string& id);
......@@ -114,6 +131,12 @@ class DeveloperPrivateEventRouter : public ExtensionRegistryObserver,
app_window_registry_observer_;
ScopedObserver<ExtensionActionAPI, ExtensionActionAPI::Observer>
extension_action_api_observer_;
ScopedObserver<WarningService, WarningService::Observer>
warning_service_observer_;
ScopedObserver<ExtensionPrefs, ExtensionPrefsObserver>
extension_prefs_observer_;
ScopedObserver<ExtensionManagement, ExtensionManagement::Observer>
extension_management_observer_;
Profile* profile_;
......
......@@ -125,7 +125,8 @@ const WarningSet& WarningBadgeService::GetCurrentWarnings() const {
return WarningService::Get(profile_)->warnings();
}
void WarningBadgeService::ExtensionWarningsChanged() {
void WarningBadgeService::ExtensionWarningsChanged(
const ExtensionIdSet& affected_extensions) {
DCHECK(CalledOnValidThread());
UpdateBadgeStatus();
}
......
......@@ -36,7 +36,8 @@ class WarningBadgeService : public KeyedService,
private:
// Implementation of WarningService::Observer.
void ExtensionWarningsChanged() override;
void ExtensionWarningsChanged(
const ExtensionIdSet& affected_extensions) override;
void UpdateBadgeStatus();
virtual void ShowBadge(bool show);
......
......@@ -148,10 +148,12 @@ cr.define('extensions', function() {
var wrapper = $('extension-list-wrapper');
wrapper.insertBefore(extensionList, wrapper.firstChild);
this.update_();
// TODO(devlin): Remove this once all notifications are moved to events on
// the developerPrivate api.
chrome.send('extensionSettingsRegister');
// Get the initial profile state, and register to be notified of any
// future changes.
chrome.developerPrivate.getProfileConfiguration(
this.update_.bind(this));
chrome.developerPrivate.onProfileStateChanged.addListener(
this.update_.bind(this));
var extensionLoader = extensions.ExtensionLoader.getInstance();
......@@ -239,24 +241,15 @@ cr.define('extensions', function() {
}
},
/**
* Updates the extensions page to the latest profile and extensions
* configuration.
* @private
*/
update_: function() {
chrome.developerPrivate.getProfileConfiguration(
this.returnProfileConfiguration_.bind(this));
},
/**
* [Re]-Populates the page with data representing the current state of
* installed extensions.
* @param {ProfileInfo} profileInfo
* @private
*/
returnProfileConfiguration_: function(profileInfo) {
update_: function(profileInfo) {
webuiResponded = true;
/** @const */
var supervised = profileInfo.isSupervised;
......@@ -366,14 +359,6 @@ cr.define('extensions', function() {
},
};
/**
* Called by the WebUI when something has changed and the extensions UI needs
* to be updated.
*/
ExtensionSettings.onExtensionsChanged = function() {
ExtensionSettings.getInstance().update_();
};
/**
* Returns the current overlay or null if one does not exist.
* @return {Element} The overlay element.
......
......@@ -6,57 +6,29 @@
#include <vector>
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/location.h"
#include "base/message_loop/message_loop.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "base/version.h"
#include "chrome/browser/background/background_contents.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_ui_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/apps/app_info_dialog.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/app_launch_params.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/webui/extensions/extension_basic_info.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/google/core/browser/google_util.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "extensions/browser/api/device_permissions_manager.h"
#include "extensions/browser/blacklist_state.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/management_policy.h"
#include "extensions/browser/notification_types.h"
#include "extensions/browser/pref_names.h"
#include "extensions/browser/warning_set.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_icon_set.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/manifest.h"
#include "extensions/common/permissions/permissions_data.h"
#include "grit/browser_resources.h"
#include "grit/components_strings.h"
#include "grit/theme_resources.h"
......@@ -65,17 +37,8 @@
namespace extensions {
///////////////////////////////////////////////////////////////////////////////
//
// ExtensionSettingsHandler
//
///////////////////////////////////////////////////////////////////////////////
ExtensionSettingsHandler::ExtensionSettingsHandler()
: extension_service_(NULL),
warning_service_observer_(this),
extension_prefs_observer_(this),
extension_management_observer_(this) {
: extension_service_(nullptr) {
}
ExtensionSettingsHandler::~ExtensionSettingsHandler() {
......@@ -277,15 +240,6 @@ void ExtensionSettingsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_NO_CODE_TO_DISPLAY));
}
void ExtensionSettingsHandler::RenderViewDeleted(
content::RenderViewHost* render_view_host) {
Profile* source_profile = Profile::FromBrowserContext(
render_view_host->GetSiteInstance()->GetBrowserContext());
if (!Profile::FromWebUI(web_ui())->IsSameProfile(source_profile))
return;
MaybeUpdateAfterNotification();
}
void ExtensionSettingsHandler::DidStartNavigationToPendingEntry(
const GURL& url,
content::NavigationController::ReloadType reload_type) {
......@@ -297,23 +251,10 @@ void ExtensionSettingsHandler::RegisterMessages() {
Profile* profile = Profile::FromWebUI(web_ui())->GetOriginalProfile();
extension_service_ =
extensions::ExtensionSystem::Get(profile)->extension_service();
web_ui()->RegisterMessageCallback("extensionSettingsRegister",
base::Bind(&ExtensionSettingsHandler::HandleRegisterMessage,
AsWeakPtr()));
}
void ExtensionSettingsHandler::OnExtensionDisableReasonsChanged(
const std::string& extension_id, int disable_reasons) {
MaybeUpdateAfterNotification();
}
void ExtensionSettingsHandler::OnExtensionManagementSettingsChanged() {
MaybeUpdateAfterNotification();
}
void ExtensionSettingsHandler::ExtensionWarningsChanged() {
MaybeUpdateAfterNotification();
// Clear the preference for the ADT Promo before fully removing it.
// TODO(devlin): Take this out when everyone's been updated.
Profile::FromWebUI(web_ui())->GetPrefs()->ClearPref(
prefs::kExtensionsUIDismissedADTPromo);
}
void ExtensionSettingsHandler::ReloadUnpackedExtensions() {
......@@ -332,29 +273,4 @@ void ExtensionSettingsHandler::ReloadUnpackedExtensions() {
}
}
void ExtensionSettingsHandler::HandleRegisterMessage(
const base::ListValue* args) {
if (content::WebContentsObserver::web_contents())
return; // Only register once.
content::WebContentsObserver::Observe(web_ui()->GetWebContents());
Profile* profile = Profile::FromWebUI(web_ui());
warning_service_observer_.Add(WarningService::Get(profile));
extension_management_observer_.Add(
ExtensionManagementFactory::GetForBrowserContext(profile));
// Clear the preference for the ADT Promo before fully removing it.
// TODO(devlin): Take this out when everyone's been updated.
profile->GetPrefs()->ClearPref(prefs::kExtensionsUIDismissedADTPromo);
}
void ExtensionSettingsHandler::MaybeUpdateAfterNotification() {
content::WebContents* contents = web_ui()->GetWebContents();
if (contents && contents->GetRenderViewHost()) {
web_ui()->CallJavascriptFunction(
"extensions.ExtensionSettings.onExtensionsChanged");
}
}
} // namespace extensions
......@@ -5,25 +5,13 @@
#ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_
#include <string>
#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "chrome/browser/extensions/extension_management.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "extensions/browser/extension_prefs_observer.h"
#include "extensions/browser/warning_service.h"
class ExtensionService;
class GURL;
namespace base {
class FilePath;
class ListValue;
}
namespace content {
class WebUIDataSource;
}
......@@ -33,17 +21,10 @@ class PrefRegistrySyncable;
}
namespace extensions {
class Extension;
class ExtensionPrefs;
// Extension Settings UI handler.
class ExtensionSettingsHandler
: public content::WebUIMessageHandler,
public content::WebContentsObserver,
public ExtensionManagement::Observer,
public ExtensionPrefsObserver,
public WarningService::Observer,
public base::SupportsWeakPtr<ExtensionSettingsHandler> {
class ExtensionSettingsHandler : public content::WebUIMessageHandler,
public content::WebContentsObserver {
public:
ExtensionSettingsHandler();
~ExtensionSettingsHandler() override;
......@@ -53,8 +34,7 @@ class ExtensionSettingsHandler
void GetLocalizedValues(content::WebUIDataSource* source);
private:
// content::WebContentsObserver implementation.
void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
// WebContentsObserver implementation.
void DidStartNavigationToPendingEntry(
const GURL& url,
content::NavigationController::ReloadType reload_type) override;
......@@ -62,39 +42,12 @@ class ExtensionSettingsHandler
// WebUIMessageHandler implementation.
void RegisterMessages() override;
// ExtensionPrefsObserver implementation.
void OnExtensionDisableReasonsChanged(const std::string& extension_id,
int disable_reasons) override;
// ExtensionManagement::Observer implementation.
void OnExtensionManagementSettingsChanged() override;
// WarningService::Observer implementation.
void ExtensionWarningsChanged() override;
// Helper method that reloads all unpacked extensions.
void ReloadUnpackedExtensions();
// Callback for the "extensionSettingsRegister" message.
void HandleRegisterMessage(const base::ListValue* args);
// Forces a UI update if appropriate after a notification is received.
void MaybeUpdateAfterNotification();
// Our model. Outlives us since it's owned by our containing profile.
ExtensionService* extension_service_;
ScopedObserver<WarningService, WarningService::Observer>
warning_service_observer_;
// An observer to listen for notable changes in the ExtensionPrefs, like
// a change in Disable Reasons.
ScopedObserver<ExtensionPrefs, ExtensionPrefsObserver>
extension_prefs_observer_;
ScopedObserver<ExtensionManagement, ExtensionManagement::Observer>
extension_management_observer_;
DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler);
};
......
......@@ -288,7 +288,8 @@ namespace developerPrivate {
VIEW_UNREGISTERED,
ERROR_ADDED,
ERRORS_REMOVED,
PREFS_CHANGED
PREFS_CHANGED,
WARNINGS_CHANGED
};
dictionary PackDirectoryResponse {
......@@ -536,6 +537,9 @@ namespace developerPrivate {
interface Events {
// Fired when a item state is changed.
static void onItemStateChanged(EventData response);
// Fired when the profile's state has changed.
static void onProfileStateChanged(ProfileInfo info);
};
};
......@@ -33,19 +33,19 @@ WarningService* WarningService::Get(content::BrowserContext* browser_context) {
void WarningService::ClearWarnings(
const std::set<Warning::WarningType>& types) {
DCHECK(CalledOnValidThread());
bool deleted_anything = false;
ExtensionIdSet affected_extensions;
for (WarningSet::iterator i = warnings_.begin();
i != warnings_.end();) {
if (types.find(i->warning_type()) != types.end()) {
deleted_anything = true;
affected_extensions.insert(i->extension_id());
warnings_.erase(i++);
} else {
++i;
}
}
if (deleted_anything)
NotifyWarningsChanged();
if (!affected_extensions.empty())
NotifyWarningsChanged(affected_extensions);
}
std::set<Warning::WarningType> WarningService::
......@@ -78,12 +78,14 @@ std::vector<std::string> WarningService::GetWarningMessagesForExtension(
void WarningService::AddWarnings(const WarningSet& warnings) {
DCHECK(CalledOnValidThread());
size_t old_size = warnings_.size();
warnings_.insert(warnings.begin(), warnings.end());
if (old_size != warnings_.size())
NotifyWarningsChanged();
ExtensionIdSet affected_extensions;
for (const Warning& warning : warnings) {
if (warnings_.insert(warning).second)
affected_extensions.insert(warning.extension_id());
}
if (!affected_extensions.empty())
NotifyWarningsChanged(affected_extensions);
}
// static
......@@ -113,8 +115,10 @@ void WarningService::RemoveObserver(Observer* observer) {
observer_list_.RemoveObserver(observer);
}
void WarningService::NotifyWarningsChanged() {
FOR_EACH_OBSERVER(Observer, observer_list_, ExtensionWarningsChanged());
void WarningService::NotifyWarningsChanged(
const ExtensionIdSet& affected_extensions) {
FOR_EACH_OBSERVER(Observer, observer_list_,
ExtensionWarningsChanged(affected_extensions));
}
void WarningService::OnExtensionUnloaded(
......
......@@ -38,7 +38,8 @@ class WarningService : public KeyedService,
public:
class Observer {
public:
virtual void ExtensionWarningsChanged() = 0;
virtual void ExtensionWarningsChanged(
const ExtensionIdSet& affected_extensions) = 0;
};
// |browser_context| may be NULL for testing. In this case, be sure to not
......@@ -75,7 +76,7 @@ class WarningService : public KeyedService,
void RemoveObserver(Observer* observer);
private:
void NotifyWarningsChanged();
void NotifyWarningsChanged(const ExtensionIdSet& affected_extensions);
// ExtensionRegistryObserver implementation.
void OnExtensionUnloaded(content::BrowserContext* browser_context,
......
......@@ -30,17 +30,15 @@ class TestWarningService : public WarningService {
class MockObserver : public WarningService::Observer {
public:
virtual ~MockObserver() {}
MOCK_METHOD0(ExtensionWarningsChanged, void());
MOCK_METHOD1(ExtensionWarningsChanged, void(const ExtensionIdSet&));
};
typedef ExtensionsTest WarningServiceTest;
const char* ext1_id = "extension1";
const char* ext2_id = "extension2";
const Warning::WarningType warning_1 =
Warning::kNetworkDelay;
const Warning::WarningType warning_2 =
Warning::kNetworkConflict;
const Warning::WarningType warning_1 = Warning::kNetworkDelay;
const Warning::WarningType warning_2 = Warning::kNetworkConflict;
} // namespace
......@@ -52,15 +50,16 @@ TEST_F(WarningServiceTest, SetWarning) {
MockObserver observer;
warning_service.AddObserver(&observer);
ExtensionIdSet affected_extensions;
affected_extensions.insert(ext1_id);
// Insert warning for the first time.
EXPECT_CALL(observer, ExtensionWarningsChanged());
EXPECT_CALL(observer, ExtensionWarningsChanged(affected_extensions));
warning_service.AddWarning(
Warning::CreateNetworkDelayWarning(ext1_id));
testing::Mock::VerifyAndClearExpectations(&warning_service);
// Second insertion of same warning does not trigger anything.
warning_service.AddWarning(
Warning::CreateNetworkDelayWarning(ext1_id));
warning_service.AddWarning(Warning::CreateNetworkDelayWarning(ext1_id));
testing::Mock::VerifyAndClearExpectations(&warning_service);
warning_service.RemoveObserver(&observer);
......@@ -75,7 +74,10 @@ TEST_F(WarningServiceTest, ClearWarnings) {
warning_service.AddObserver(&observer);
// Insert two unique warnings in one batch.
EXPECT_CALL(observer, ExtensionWarningsChanged());
std::set<std::string> affected_extensions;
affected_extensions.insert(ext1_id);
affected_extensions.insert(ext2_id);
EXPECT_CALL(observer, ExtensionWarningsChanged(affected_extensions));
WarningSet warning_set;
warning_set.insert(Warning::CreateNetworkDelayWarning(ext1_id));
warning_set.insert(Warning::CreateNetworkConflictWarning(ext2_id));
......@@ -83,7 +85,9 @@ TEST_F(WarningServiceTest, ClearWarnings) {
testing::Mock::VerifyAndClearExpectations(&warning_service);
// Remove one warning and check that the badge remains.
EXPECT_CALL(observer, ExtensionWarningsChanged());
affected_extensions.clear();
affected_extensions.insert(ext2_id);
EXPECT_CALL(observer, ExtensionWarningsChanged(affected_extensions));
std::set<Warning::WarningType> to_clear;
to_clear.insert(warning_2);
warning_service.ClearWarnings(to_clear);
......@@ -98,12 +102,14 @@ TEST_F(WarningServiceTest, ClearWarnings) {
EXPECT_EQ(0u, existing_warnings.size());
// Remove the other one warning.
EXPECT_CALL(observer, ExtensionWarningsChanged());
affected_extensions.clear();
affected_extensions.insert(ext1_id);
EXPECT_CALL(observer, ExtensionWarningsChanged(affected_extensions));
to_clear.insert(warning_1);
warning_service.ClearWarnings(to_clear);
testing::Mock::VerifyAndClearExpectations(&warning_service);
// Check that not warnings remain.
// Check that no warnings remain.
existing_warnings =
warning_service.GetWarningTypesAffectingExtension(ext1_id);
EXPECT_EQ(0u, existing_warnings.size());
......
......@@ -14,11 +14,11 @@ chrome.developerPrivate = {};
* @see https://developer.chrome.com/extensions/developerPrivate#type-ItemType
*/
chrome.developerPrivate.ItemType = {
hosted_app: 'hosted_app',
packaged_app: 'packaged_app',
legacy_packaged_app: 'legacy_packaged_app',
extension: 'extension',
theme: 'theme',
HOSTED_APP: 'hosted_app',
PACKAGED_APP: 'packaged_app',
LEGACY_PACKAGED_APP: 'legacy_packaged_app',
EXTENSION: 'extension',
THEME: 'theme',
};
/**
......@@ -390,6 +390,7 @@ chrome.developerPrivate.EventType = {
ERROR_ADDED: 'ERROR_ADDED',
ERRORS_REMOVED: 'ERRORS_REMOVED',
PREFS_CHANGED: 'PREFS_CHANGED',
WARNINGS_CHANGED: 'WARNINGS_CHANGED',
};
/**
......@@ -616,7 +617,8 @@ chrome.developerPrivate.openDevTools = function(properties, callback) {};
/**
* Delete reported extension erors.
* @param {DeleteExtensionErrorsProperties} properties
* @param {DeleteExtensionErrorsProperties} properties The properties specifying
* the errors to remove.
* @param {function():void=} callback
* @see https://developer.chrome.com/extensions/developerPrivate#method-deleteExtensionErrors
*/
......@@ -624,7 +626,7 @@ chrome.developerPrivate.deleteExtensionErrors = function(properties, callback) {
/**
* Repairs the extension specified.
* @param {string} extensionId
* @param {string} extensionId The id of the extension to repair.
* @param {function():void=} callback
* @see https://developer.chrome.com/extensions/developerPrivate#method-repairExtension
*/
......@@ -632,7 +634,8 @@ chrome.developerPrivate.repairExtension = function(extensionId, callback) {};
/**
* Shows the options page for the extension specified.
* @param {string} extensionId
* @param {string} extensionId The id of the extension to show the options page
* for.
* @param {function():void=} callback
* @see https://developer.chrome.com/extensions/developerPrivate#method-showOptions
*/
......@@ -640,7 +643,7 @@ chrome.developerPrivate.showOptions = function(extensionId, callback) {};
/**
* Shows the path of the extension specified.
* @param {string} extensionId
* @param {string} extensionId The id of the extension to show the path for.
* @param {function():void=} callback
* @see https://developer.chrome.com/extensions/developerPrivate#method-showPath
*/
......@@ -687,3 +690,10 @@ chrome.developerPrivate.inspect = function(options, callback) {};
* @see https://developer.chrome.com/extensions/developerPrivate#event-onItemStateChanged
*/
chrome.developerPrivate.onItemStateChanged;
/**
* Fired when the profile's state has changed.
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/developerPrivate#event-onProfileStateChanged
*/
chrome.developerPrivate.onProfileStateChanged;
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment