Commit bef0893a authored by shuchen's avatar shuchen Committed by Commit bot

Don't awake suspended IME extension's background except for onActivate.

For suspended IME extension (e.g. XKB extension), don't awake it by IME
 events except onActivate. The IME extension should be awake by other
events (e.g. runtime.onMessage) from its other pages. This is to save
memory for steady state Chrome OS on which the users don't want any
IME features.

BUG=451627
TEST=Verified on linux_chromeos.

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

Cr-Commit-Position: refs/heads/master@{#314100}
parent dca0c18e
......@@ -19,6 +19,7 @@
#include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "ui/base/ime/chromeos/component_extension_ime_manager.h"
#include "ui/base/ime/chromeos/extension_ime_util.h"
......@@ -81,6 +82,27 @@ static void DispatchEventToExtension(const std::string& extension_id,
const std::string& event_name,
scoped_ptr<base::ListValue> args) {
Profile* profile = ProfileManager::GetActiveUserProfile();
if (event_name != input_ime::OnActivate::kEventName) {
// For suspended IME extension (e.g. XKB extension), don't awake it by IME
// events except onActivate. The IME extension should be awake by other
// events (e.g. runtime.onMessage) from its other pages.
// This is to save memory for steady state Chrome OS on which the users
// don't want any IME features.
extensions::ExtensionSystem* extension_system =
extensions::ExtensionSystem::Get(profile);
if (extension_system) {
const extensions::Extension* extension =
extension_system->extension_service()->GetExtensionById(
extension_id, false /* include_disabled */);
extensions::ProcessManager* process_manager =
extensions::ProcessManager::Get(profile);
if (extensions::BackgroundInfo::HasBackgroundPage(extension) &&
!process_manager->GetBackgroundHostForExtension(extension_id)) {
return;
}
}
}
scoped_ptr<extensions::Event> event(new extensions::Event(
event_name, args.Pass()));
event->restrict_to_browser_context = profile;
......
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