1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_COMPONENT_EXTENSION_IME_MANAGER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_COMPONENT_EXTENSION_IME_MANAGER_IMPL_H_
11 #include "base/bind.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/sequenced_task_runner.h"
14 #include "base/threading/thread_checker.h"
15 #include "base/values.h"
16 #include "ui/base/ime/chromeos/component_extension_ime_manager.h"
22 // The implementation class of ComponentExtensionIMEManagerDelegate.
23 class ComponentExtensionIMEManagerImpl
24 : public ComponentExtensionIMEManagerDelegate
{
26 ComponentExtensionIMEManagerImpl();
27 ~ComponentExtensionIMEManagerImpl() override
;
29 // ComponentExtensionIMEManagerDelegate overrides:
30 std::vector
<ComponentExtensionIME
> ListIME() override
;
31 void Load(Profile
* profile
,
32 const std::string
& extension_id
,
33 const std::string
& manifest
,
34 const base::FilePath
& file_path
) override
;
35 void Unload(Profile
* profile
,
36 const std::string
& extension_id
,
37 const base::FilePath
& file_path
) override
;
39 static bool IsIMEExtensionID(const std::string
& id
);
42 // Reads component extensions and extract their localized information: name,
43 // description and ime id. This function fills them into |out_imes|.
44 static void ReadComponentExtensionsInfo(
45 std::vector
<ComponentExtensionIME
>* out_imes
);
47 // Parses manifest string to manifest json dictionary value.
48 static scoped_ptr
<base::DictionaryValue
> GetManifest(
49 const std::string
& manifest_string
);
51 // Reads extension information: description, option page. This function
52 // returns true on success, otherwise returns false.
53 static bool ReadExtensionInfo(const base::DictionaryValue
& manifest
,
54 const std::string
& extension_id
,
55 ComponentExtensionIME
* out
);
57 // Reads each engine component in |dict|. |dict| is given by GetList with
58 // kInputComponents key from manifest. This function returns true on success,
59 // otherwise retrun false. This function must be called on FILE thread.
60 static bool ReadEngineComponent(
61 const ComponentExtensionIME
& component_extension
,
62 const base::DictionaryValue
& dict
,
63 ComponentExtensionEngine
* out
);
65 // The list of component extension IME.
66 std::vector
<ComponentExtensionIME
> component_extension_list_
;
68 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManagerImpl
);
71 } // namespace chromeos
73 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_COMPONENT_EXTENSION_IME_MANAGER_IMPL_H_