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
;
40 // Reads component extensions and extract their localized information: name,
41 // description and ime id. This function fills them into |out_imes|.
42 static void ReadComponentExtensionsInfo(
43 std::vector
<ComponentExtensionIME
>* out_imes
);
45 // Parses manifest string to manifest json dictionary value.
46 static scoped_ptr
<base::DictionaryValue
> GetManifest(
47 const std::string
& manifest_string
);
49 // Reads extension information: description, option page. This function
50 // returns true on success, otherwise returns false.
51 static bool ReadExtensionInfo(const base::DictionaryValue
& manifest
,
52 const std::string
& extension_id
,
53 ComponentExtensionIME
* out
);
55 // Reads each engine component in |dict|. |dict| is given by GetList with
56 // kInputComponents key from manifest. This function returns true on success,
57 // otherwise retrun false. This function must be called on FILE thread.
58 static bool ReadEngineComponent(
59 const ComponentExtensionIME
& component_extension
,
60 const base::DictionaryValue
& dict
,
61 ComponentExtensionEngine
* out
);
63 // The list of component extension IME.
64 std::vector
<ComponentExtensionIME
> component_extension_list_
;
66 DISALLOW_COPY_AND_ASSIGN(ComponentExtensionIMEManagerImpl
);
69 } // namespace chromeos
71 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_COMPONENT_EXTENSION_IME_MANAGER_IMPL_H_