Commit dccffbfd authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Remove NOTIFICATION_PROFILE_* from SiteSettingsHandler

Also remove obsolete NotificationService includes from
//chrome/browser/ui/webui/settings/

Bug: 268984
Change-Id: I2c5cf6e456965f6d98c844bf8c81c423add00c1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1891737
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714504}
parent 2755ff97
...@@ -453,9 +453,9 @@ class Profile : public content::BrowserContext { ...@@ -453,9 +453,9 @@ class Profile : public content::BrowserContext {
static PrefStore* CreateExtensionPrefStore(Profile*, static PrefStore* CreateExtensionPrefStore(Profile*,
bool incognito_pref_store); bool incognito_pref_store);
private:
void NotifyOffTheRecordProfileCreated(Profile* off_the_record); void NotifyOffTheRecordProfileCreated(Profile* off_the_record);
private:
bool restored_last_session_; bool restored_last_session_;
// Used to prevent the notification that this Profile is destroyed from // Used to prevent the notification that this Profile is destroyed from
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/camera_presence_notifier.h" #include "chrome/browser/chromeos/camera_presence_notifier.h"
#include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h"
...@@ -39,7 +38,6 @@ ...@@ -39,7 +38,6 @@
#include "components/user_manager/user_image/user_image.h" #include "components/user_manager/user_image/user_image.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "net/base/data_url.h" #include "net/base/data_url.h"
......
...@@ -14,12 +14,10 @@ ...@@ -14,12 +14,10 @@
#include "ui/base/webui/web_ui_util.h" #include "ui/base/webui/web_ui_util.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/ui/webui/chromeos/user_image_source.h" #include "chrome/browser/ui/webui/chromeos/user_image_source.h"
#include "components/account_id/account_id.h" #include "components/account_id/account_id.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_service.h"
#else #else
#include "chrome/browser/profiles/profile_avatar_icon_util.h" #include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_statistics.h" #include "chrome/browser/profiles/profile_statistics.h"
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "base/value_conversions.h" #include "base/value_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/gaia_info_update_service.h" #include "chrome/browser/profiles/gaia_info_update_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_entry.h"
...@@ -31,7 +30,6 @@ ...@@ -31,7 +30,6 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h" #include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "google_apis/gaia/gaia_auth_util.h" #include "google_apis/gaia/gaia_auth_util.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/content_settings/web_site_settings_uma_util.h" #include "chrome/browser/content_settings/web_site_settings_uma_util.h"
#include "chrome/browser/engagement/site_engagement_service.h" #include "chrome/browser/engagement/site_engagement_service.h"
...@@ -28,7 +27,6 @@ ...@@ -28,7 +27,6 @@
#include "chrome/browser/permissions/permission_manager.h" #include "chrome/browser/permissions/permission_manager.h"
#include "chrome/browser/permissions/permission_uma_util.h" #include "chrome/browser/permissions/permission_uma_util.h"
#include "chrome/browser/permissions/permission_util.h" #include "chrome/browser/permissions/permission_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/serial/serial_chooser_context.h" #include "chrome/browser/serial/serial_chooser_context.h"
#include "chrome/browser/serial/serial_chooser_context_factory.h" #include "chrome/browser/serial/serial_chooser_context_factory.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -50,7 +48,6 @@ ...@@ -50,7 +48,6 @@
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "content/public/common/origin_util.h" #include "content/public/common/origin_util.h"
...@@ -338,9 +335,7 @@ void LogAllSitesAction(AllSitesAction action) { ...@@ -338,9 +335,7 @@ void LogAllSitesAction(AllSitesAction action) {
SiteSettingsHandler::SiteSettingsHandler(Profile* profile, SiteSettingsHandler::SiteSettingsHandler(Profile* profile,
web_app::AppRegistrar& app_registrar) web_app::AppRegistrar& app_registrar)
: profile_(profile), : profile_(profile), app_registrar_(app_registrar) {}
app_registrar_(app_registrar),
pref_change_registrar_(nullptr) {}
SiteSettingsHandler::~SiteSettingsHandler() { SiteSettingsHandler::~SiteSettingsHandler() {
if (cookies_tree_model_) if (cookies_tree_model_)
...@@ -452,11 +447,6 @@ void SiteSettingsHandler::OnJavascriptAllowed() { ...@@ -452,11 +447,6 @@ void SiteSettingsHandler::OnJavascriptAllowed() {
if (profile_->HasOffTheRecordProfile()) if (profile_->HasOffTheRecordProfile())
ObserveSourcesForProfile(profile_->GetOffTheRecordProfile()); ObserveSourcesForProfile(profile_->GetOffTheRecordProfile());
notification_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED,
content::NotificationService::AllSources());
notification_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
content::NotificationService::AllSources());
// Here we only subscribe to the HostZoomMap for the default storage partition // Here we only subscribe to the HostZoomMap for the default storage partition
// since we don't allow the user to manage the zoom levels for apps. // since we don't allow the user to manage the zoom levels for apps.
// We're only interested in zoom-levels that are persisted, since the user // We're only interested in zoom-levels that are persisted, since the user
...@@ -487,12 +477,12 @@ void SiteSettingsHandler::OnJavascriptAllowed() { ...@@ -487,12 +477,12 @@ void SiteSettingsHandler::OnJavascriptAllowed() {
void SiteSettingsHandler::OnJavascriptDisallowed() { void SiteSettingsHandler::OnJavascriptDisallowed() {
observer_.RemoveAll(); observer_.RemoveAll();
chooser_observer_.RemoveAll(); chooser_observer_.RemoveAll();
notification_registrar_.RemoveAll();
host_zoom_map_subscription_.reset(); host_zoom_map_subscription_.reset();
pref_change_registrar_->Remove(prefs::kBlockAutoplayEnabled); pref_change_registrar_->Remove(prefs::kBlockAutoplayEnabled);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
pref_change_registrar_->Remove(prefs::kEnableDRM); pref_change_registrar_->Remove(prefs::kEnableDRM);
#endif #endif
observed_profiles_.RemoveAll();
} }
void SiteSettingsHandler::OnGetUsageInfo() { void SiteSettingsHandler::OnGetUsageInfo() {
...@@ -558,31 +548,16 @@ void SiteSettingsHandler::OnContentSettingChanged( ...@@ -558,31 +548,16 @@ void SiteSettingsHandler::OnContentSettingChanged(
} }
} }
void SiteSettingsHandler::Observe(int type, void SiteSettingsHandler::OnOffTheRecordProfileCreated(
const content::NotificationSource& source, Profile* off_the_record) {
const content::NotificationDetails& details) { FireWebUIListener("onIncognitoStatusChanged", base::Value(true));
switch (type) { ObserveSourcesForProfile(off_the_record);
case chrome::NOTIFICATION_PROFILE_DESTROYED: { }
Profile* profile = content::Source<Profile>(source).ptr();
if (!profile_->IsSameProfile(profile))
break;
SendIncognitoStatus(profile, /*was_destroyed=*/true);
if (profile->IsOffTheRecord())
StopObservingSourcesForProfile(profile);
break;
}
case chrome::NOTIFICATION_PROFILE_CREATED: {
Profile* profile = content::Source<Profile>(source).ptr();
if (!profile_->IsSameProfile(profile))
break;
SendIncognitoStatus(profile, /*was_destroyed=*/false);
ObserveSourcesForProfile(profile); void SiteSettingsHandler::OnProfileWillBeDestroyed(Profile* profile) {
break; if (profile->IsOffTheRecord())
} FireWebUIListener("onIncognitoStatusChanged", base::Value(false));
} StopObservingSourcesForProfile(profile);
} }
void SiteSettingsHandler::OnChooserObjectPermissionChanged( void SiteSettingsHandler::OnChooserObjectPermissionChanged(
...@@ -1207,22 +1182,8 @@ void SiteSettingsHandler::HandleIsPatternValidForType( ...@@ -1207,22 +1182,8 @@ void SiteSettingsHandler::HandleIsPatternValidForType(
void SiteSettingsHandler::HandleUpdateIncognitoStatus( void SiteSettingsHandler::HandleUpdateIncognitoStatus(
const base::ListValue* args) { const base::ListValue* args) {
AllowJavascript(); AllowJavascript();
SendIncognitoStatus(profile_, /*was_destroyed=*/false); FireWebUIListener("onIncognitoStatusChanged",
} base::Value(profile_->HasOffTheRecordProfile()));
void SiteSettingsHandler::SendIncognitoStatus(Profile* profile,
bool was_destroyed) {
if (!IsJavascriptAllowed())
return;
// When an incognito profile is destroyed, it sends out the destruction
// message before destroying, so HasOffTheRecordProfile for profile_ won't
// return false until after the profile actually been destroyed.
bool incognito_enabled =
profile_->HasOffTheRecordProfile() &&
!(was_destroyed && profile == profile_->GetOffTheRecordProfile());
FireWebUIListener("onIncognitoStatusChanged", base::Value(incognito_enabled));
} }
void SiteSettingsHandler::HandleFetchZoomLevels(const base::ListValue* args) { void SiteSettingsHandler::HandleFetchZoomLevels(const base::ListValue* args) {
...@@ -1390,6 +1351,8 @@ void SiteSettingsHandler::ObserveSourcesForProfile(Profile* profile) { ...@@ -1390,6 +1351,8 @@ void SiteSettingsHandler::ObserveSourcesForProfile(Profile* profile) {
auto* serial_context = SerialChooserContextFactory::GetForProfile(profile); auto* serial_context = SerialChooserContextFactory::GetForProfile(profile);
if (!chooser_observer_.IsObserving(serial_context)) if (!chooser_observer_.IsObserving(serial_context))
chooser_observer_.Add(serial_context); chooser_observer_.Add(serial_context);
observed_profiles_.Add(profile);
} }
void SiteSettingsHandler::StopObservingSourcesForProfile(Profile* profile) { void SiteSettingsHandler::StopObservingSourcesForProfile(Profile* profile) {
...@@ -1404,6 +1367,8 @@ void SiteSettingsHandler::StopObservingSourcesForProfile(Profile* profile) { ...@@ -1404,6 +1367,8 @@ void SiteSettingsHandler::StopObservingSourcesForProfile(Profile* profile) {
auto* serial_context = SerialChooserContextFactory::GetForProfile(profile); auto* serial_context = SerialChooserContextFactory::GetForProfile(profile);
if (chooser_observer_.IsObserving(serial_context)) if (chooser_observer_.IsObserving(serial_context))
chooser_observer_.Remove(serial_context); chooser_observer_.Remove(serial_context);
observed_profiles_.Remove(profile);
} }
void SiteSettingsHandler::TreeNodesAdded(ui::TreeModel* model, void SiteSettingsHandler::TreeNodesAdded(ui::TreeModel* model,
......
...@@ -14,18 +14,16 @@ ...@@ -14,18 +14,16 @@
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "chrome/browser/browsing_data/cookies_tree_model.h" #include "chrome/browser/browsing_data/cookies_tree_model.h"
#include "chrome/browser/permissions/chooser_context_base.h" #include "chrome/browser/permissions/chooser_context_base.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_observer.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chrome/browser/web_applications/components/app_registrar.h" #include "chrome/browser/web_applications/components/app_registrar.h"
#include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_app_registrar.h"
#include "components/content_settings/core/browser/content_settings_observer.h" #include "components/content_settings/core/browser/content_settings_observer.h"
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
#include "content/public/browser/host_zoom_map.h" #include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ppapi/buildflags/buildflags.h" #include "ppapi/buildflags/buildflags.h"
class Profile;
class PrefChangeRegistrar; class PrefChangeRegistrar;
namespace base { namespace base {
...@@ -37,7 +35,7 @@ namespace settings { ...@@ -37,7 +35,7 @@ namespace settings {
// Chrome "ContentSettings" settings page UI handler. // Chrome "ContentSettings" settings page UI handler.
class SiteSettingsHandler : public SettingsPageUIHandler, class SiteSettingsHandler : public SettingsPageUIHandler,
public content_settings::Observer, public content_settings::Observer,
public content::NotificationObserver, public ProfileObserver,
public ChooserContextBase::PermissionObserver, public ChooserContextBase::PermissionObserver,
public CookiesTreeModel::Observer { public CookiesTreeModel::Observer {
public: public:
...@@ -79,10 +77,9 @@ class SiteSettingsHandler : public SettingsPageUIHandler, ...@@ -79,10 +77,9 @@ class SiteSettingsHandler : public SettingsPageUIHandler,
ContentSettingsType content_type, ContentSettingsType content_type,
const std::string& resource_identifier) override; const std::string& resource_identifier) override;
// content::NotificationObserver: // ProfileObserver:
void Observe(int type, void OnOffTheRecordProfileCreated(Profile* off_the_record) override;
const content::NotificationSource& source, void OnProfileWillBeDestroyed(Profile* profile) override;
const content::NotificationDetails& details) override;
// ChooserContextBase::PermissionObserver implementation: // ChooserContextBase::PermissionObserver implementation:
void OnChooserObjectPermissionChanged( void OnChooserObjectPermissionChanged(
...@@ -246,7 +243,7 @@ class SiteSettingsHandler : public SettingsPageUIHandler, ...@@ -246,7 +243,7 @@ class SiteSettingsHandler : public SettingsPageUIHandler,
Profile* profile_; Profile* profile_;
web_app::AppRegistrar& app_registrar_; web_app::AppRegistrar& app_registrar_;
content::NotificationRegistrar notification_registrar_; ScopedObserver<Profile, ProfileObserver> observed_profiles_{this};
// Keeps track of events related to zooming. // Keeps track of events related to zooming.
std::unique_ptr<content::HostZoomMap::Subscription> std::unique_ptr<content::HostZoomMap::Subscription>
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h"
#include "chrome/browser/browsing_data/mock_browsing_data_cookie_helper.h" #include "chrome/browser/browsing_data/mock_browsing_data_cookie_helper.h"
#include "chrome/browser/browsing_data/mock_browsing_data_local_storage_helper.h" #include "chrome/browser/browsing_data/mock_browsing_data_local_storage_helper.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/test_extension_system.h" #include "chrome/browser/extensions/test_extension_system.h"
...@@ -48,7 +47,6 @@ ...@@ -48,7 +47,6 @@
#include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/ukm/test_ukm_recorder.h" #include "components/ukm/test_ukm_recorder.h"
#include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_controller.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_web_ui.h" #include "content/public/test/test_web_ui.h"
...@@ -396,10 +394,6 @@ class SiteSettingsHandlerTest : public testing::Test { ...@@ -396,10 +394,6 @@ class SiteSettingsHandlerTest : public testing::Test {
} }
virtual void DestroyIncognitoProfile() { virtual void DestroyIncognitoProfile() {
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PROFILE_DESTROYED,
content::Source<Profile>(static_cast<Profile*>(incognito_profile_)),
content::NotificationService::NoDetails());
profile_.SetOffTheRecordProfile(nullptr); profile_.SetOffTheRecordProfile(nullptr);
ASSERT_FALSE(profile_.HasOffTheRecordProfile()); ASSERT_FALSE(profile_.HasOffTheRecordProfile());
incognito_profile_ = nullptr; incognito_profile_ = nullptr;
......
...@@ -545,6 +545,9 @@ void TestingProfile::FinishInit() { ...@@ -545,6 +545,9 @@ void TestingProfile::FinishInit() {
// must be initialized when the testing profile finishes its initialization. // must be initialized when the testing profile finishes its initialization.
signin_util::EnsureUserSignoutAllowedIsInitializedForProfile(this); signin_util::EnsureUserSignoutAllowedIsInitializedForProfile(this);
} }
if (original_profile_)
original_profile_->NotifyOffTheRecordProfileCreated(this);
} }
TestingProfile::~TestingProfile() { TestingProfile::~TestingProfile() {
......
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