| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" | 5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/common/extensions/api/input_ime.h" | 9 #include "chrome/common/extensions/api/input_ime.h" |
| 10 #include "content/public/browser/notification_registrar.h" | 10 #include "content/public/browser/notification_registrar.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 router = new InputImeEventRouter(profile); | 257 router = new InputImeEventRouter(profile); |
| 258 router_map_[profile] = router; | 258 router_map_[profile] = router; |
| 259 } | 259 } |
| 260 return router; | 260 return router; |
| 261 } | 261 } |
| 262 | 262 |
| 263 void InputImeEventRouterFactory::RemoveProfile(Profile* profile) { | 263 void InputImeEventRouterFactory::RemoveProfile(Profile* profile) { |
| 264 if (!profile || router_map_.empty()) | 264 if (!profile || router_map_.empty()) |
| 265 return; | 265 return; |
| 266 auto it = router_map_.find(profile); | 266 auto it = router_map_.find(profile); |
| 267 if (it != router_map_.end()) { | 267 if (it != router_map_.end() && it->first == profile) { |
| 268 delete it->second; | 268 delete it->second; |
| 269 router_map_.erase(it); | 269 router_map_.erase(it); |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 | 272 |
| 273 ExtensionFunction::ResponseAction InputImeKeyEventHandledFunction::Run() { | 273 ExtensionFunction::ResponseAction InputImeKeyEventHandledFunction::Run() { |
| 274 std::unique_ptr<KeyEventHandled::Params> params( | 274 std::unique_ptr<KeyEventHandled::Params> params( |
| 275 KeyEventHandled::Params::Create(*args_)); | 275 KeyEventHandled::Params::Create(*args_)); |
| 276 InputImeEventRouter* event_router = | 276 InputImeEventRouter* event_router = |
| 277 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); | 277 GetInputImeEventRouter(Profile::FromBrowserContext(browser_context())); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) { | 413 InputImeEventRouter* GetInputImeEventRouter(Profile* profile) { |
| 414 if (!profile) | 414 if (!profile) |
| 415 return nullptr; | 415 return nullptr; |
| 416 if (profile->HasOffTheRecordProfile()) | 416 if (profile->HasOffTheRecordProfile()) |
| 417 profile = profile->GetOffTheRecordProfile(); | 417 profile = profile->GetOffTheRecordProfile(); |
| 418 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter( | 418 return extensions::InputImeEventRouterFactory::GetInstance()->GetRouter( |
| 419 profile); | 419 profile); |
| 420 } | 420 } |
| 421 | 421 |
| 422 } // namespace extensions | 422 } // namespace extensions |
| OLD | NEW |