Commit a9fb0358 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Use original profile in InputImeEventRouter.

GetInputImeEventRouter uses the incognito profile as a common reference
for an incognito profile and its original profile. But when a profile is
destroyed, it deletes the reference based on the profile itself.

This can cause problems when Chrome starts in incognito mode, then a
regular window is opened, and the incognito window is closed. In this
scenario, the InputImeEventRouter is deleted when the incognito profile
is closed, but it is still referenced by the original profile.

To fix this, the original profile is used as the reference for both
modes as it is always destroyed after the incognito one.

Bug: 856135
Change-Id: Ieb4f006e9cc5c36cd9264fd0b1b4ef490e1f3162
Reviewed-on: https://chromium-review.googlesource.com/c/1288350Reviewed-by: default avatarShu Chen <shuchen@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600727}
parent 630bb026
......@@ -287,6 +287,10 @@ void InputImeEventRouterFactory::RemoveProfile(Profile* profile) {
if (!profile || router_map_.empty())
return;
auto it = router_map_.find(profile);
// The routers are common between an incognito profile and its original
// profile, and are keyed on the original profiles.
// When a profile is removed, exact matching is used to ensure that the router
// is deleted only when the original profile is removed.
if (it != router_map_.end() && it->first == profile) {
delete it->second;
router_map_.erase(it);
......@@ -445,10 +449,8 @@ BrowserContextKeyedAPIFactory<InputImeAPI>* InputImeAPI::GetFactoryInstance() {
InputImeEventRouter* GetInputImeEventRouter(Profile* profile) {
if (!profile)
return nullptr;
if (profile->HasOffTheRecordProfile())
profile = profile->GetOffTheRecordProfile();
return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter(
profile);
profile->GetOriginalProfile());
}
} // namespace extensions
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