Commit 2d855c52 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

MediaRouter: move incognito shutdown code to //chrome

This is necessary for Chrome because a normal profile and an incognito
profile use the same MediaRouter. That object should be notified when
the incognito profile shuts down.

This is not necessary for WebLayer because OTR contexts have their
own MediaRouter (the OTR context is not linked to a normal/base
context).

Bug: 1057100
Change-Id: I9c4426a4219bd971c6690b4d2712e5d39ec3f91e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438946Reviewed-by: default avatarTakumi Fujimoto <takumif@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812250}
parent e274ab4b
......@@ -80,4 +80,17 @@ KeyedService* ChromeMediaRouterFactory::BuildServiceInstanceFor(
return media_router;
}
void ChromeMediaRouterFactory::BrowserContextShutdown(
content::BrowserContext* context) {
// Notify the MediaRouter (which uses the normal/base proflie) of incognito
// profile shutdown.
if (context->IsOffTheRecord()) {
MediaRouter* router =
static_cast<MediaRouter*>(GetServiceForBrowserContext(context, false));
if (router)
router->OnIncognitoProfileShutdown();
}
BrowserContextKeyedServiceFactory::BrowserContextShutdown(context);
}
} // namespace media_router
......@@ -40,6 +40,7 @@ class ChromeMediaRouterFactory : public MediaRouterFactory {
content::BrowserContext* context) const override;
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
void BrowserContextShutdown(content::BrowserContext* context) override;
};
} // namespace media_router
......
......@@ -35,17 +35,6 @@ MediaRouterFactory* MediaRouterFactory::GetInstance() {
return g_instance;
}
void MediaRouterFactory::BrowserContextShutdown(
content::BrowserContext* context) {
if (context->IsOffTheRecord()) {
MediaRouter* router =
static_cast<MediaRouter*>(GetServiceForBrowserContext(context, false));
if (router)
router->OnIncognitoProfileShutdown();
}
BrowserContextKeyedServiceFactory::BrowserContextShutdown(context);
}
MediaRouterFactory::MediaRouterFactory()
: BrowserContextKeyedServiceFactory(
"MediaRouter",
......
......@@ -27,10 +27,6 @@ class MediaRouterFactory : public BrowserContextKeyedServiceFactory {
static MediaRouterFactory* GetInstance();
protected:
// We override the shutdown method for the factory to give the Media Router a
// chance to remove incognito media routes.
void BrowserContextShutdown(content::BrowserContext* context) override;
MediaRouterFactory();
~MediaRouterFactory() override;
};
......
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