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 #ifndef CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
10 #include "chrome/browser/extensions/event_router.h" | 10 #include "chrome/browser/extensions/event_router.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 ExtensionService* service(); | 27 ExtensionService* service(); |
28 }; | 28 }; |
29 | 29 |
30 class AsyncManagementFunction : public AsyncExtensionFunction { | 30 class AsyncManagementFunction : public AsyncExtensionFunction { |
31 protected: | 31 protected: |
32 virtual ~AsyncManagementFunction() {} | 32 virtual ~AsyncManagementFunction() {} |
33 | 33 |
34 ExtensionService* service(); | 34 ExtensionService* service(); |
35 }; | 35 }; |
36 | 36 |
37 class ManagementGetAllFunction : public ManagementFunction { | 37 class GetAllExtensionsFunction : public ManagementFunction { |
38 public: | 38 public: |
39 DECLARE_EXTENSION_FUNCTION_NAME("management.getAll"); | 39 DECLARE_EXTENSION_FUNCTION_NAME("management.getAll"); |
40 | 40 |
41 protected: | 41 protected: |
42 virtual ~ManagementGetAllFunction() {} | 42 virtual ~GetAllExtensionsFunction() {} |
43 | 43 |
44 // ExtensionFunction: | 44 // ExtensionFunction: |
45 virtual bool RunImpl() OVERRIDE; | 45 virtual bool RunImpl() OVERRIDE; |
46 }; | 46 }; |
47 | 47 |
48 class ManagementGetFunction : public ManagementFunction { | 48 class GetExtensionByIdFunction : public ManagementFunction { |
49 public: | 49 public: |
50 DECLARE_EXTENSION_FUNCTION_NAME("management.get"); | 50 DECLARE_EXTENSION_FUNCTION_NAME("management.get"); |
51 | 51 |
52 protected: | 52 protected: |
53 virtual ~ManagementGetFunction() {} | 53 virtual ~GetExtensionByIdFunction() {} |
54 | 54 |
55 // ExtensionFunction: | 55 // ExtensionFunction: |
56 virtual bool RunImpl() OVERRIDE; | 56 virtual bool RunImpl() OVERRIDE; |
57 }; | 57 }; |
58 | 58 |
59 class ManagementGetPermissionWarningsByIdFunction : public ManagementFunction { | 59 class GetPermissionWarningsByIdFunction : public ManagementFunction { |
60 public: | 60 public: |
61 DECLARE_EXTENSION_FUNCTION_NAME("management.getPermissionWarningsById"); | 61 DECLARE_EXTENSION_FUNCTION_NAME("management.getPermissionWarningsById"); |
62 | 62 |
63 protected: | 63 protected: |
64 virtual ~ManagementGetPermissionWarningsByIdFunction() {} | 64 virtual ~GetPermissionWarningsByIdFunction() {} |
65 | 65 |
66 // ExtensionFunction: | 66 // ExtensionFunction: |
67 virtual bool RunImpl() OVERRIDE; | 67 virtual bool RunImpl() OVERRIDE; |
68 }; | 68 }; |
69 | 69 |
70 class ManagementGetPermissionWarningsByManifestFunction | 70 class GetPermissionWarningsByManifestFunction : public AsyncExtensionFunction { |
71 : public AsyncExtensionFunction { | |
72 public: | 71 public: |
73 DECLARE_EXTENSION_FUNCTION_NAME( | 72 DECLARE_EXTENSION_FUNCTION_NAME( |
74 "management.getPermissionWarningsByManifest"); | 73 "management.getPermissionWarningsByManifest"); |
75 | 74 |
76 // Called when utility process finishes. | 75 // Called when utility process finishes. |
77 void OnParseSuccess(base::DictionaryValue* parsed_manifest); | 76 void OnParseSuccess(base::DictionaryValue* parsed_manifest); |
78 void OnParseFailure(const std::string& error); | 77 void OnParseFailure(const std::string& error); |
79 | 78 |
80 protected: | 79 protected: |
81 virtual ~ManagementGetPermissionWarningsByManifestFunction() {} | 80 virtual ~GetPermissionWarningsByManifestFunction() {} |
82 | 81 |
83 // ExtensionFunction: | 82 // ExtensionFunction: |
84 virtual bool RunImpl() OVERRIDE; | 83 virtual bool RunImpl() OVERRIDE; |
85 }; | 84 }; |
86 | 85 |
87 class ManagementLaunchAppFunction : public ManagementFunction { | 86 class LaunchAppFunction : public ManagementFunction { |
88 public: | 87 public: |
89 DECLARE_EXTENSION_FUNCTION_NAME("management.launchApp"); | 88 DECLARE_EXTENSION_FUNCTION_NAME("management.launchApp"); |
90 | 89 |
91 protected: | 90 protected: |
92 virtual ~ManagementLaunchAppFunction() {} | 91 virtual ~LaunchAppFunction() {} |
93 | 92 |
94 // ExtensionFunction: | 93 // ExtensionFunction: |
95 virtual bool RunImpl() OVERRIDE; | 94 virtual bool RunImpl() OVERRIDE; |
96 }; | 95 }; |
97 | 96 |
98 class ManagementSetEnabledFunction : public AsyncManagementFunction, | 97 class SetEnabledFunction : public AsyncManagementFunction, |
99 public ExtensionInstallPrompt::Delegate { | 98 public ExtensionInstallPrompt::Delegate { |
100 public: | 99 public: |
101 DECLARE_EXTENSION_FUNCTION_NAME("management.setEnabled"); | 100 DECLARE_EXTENSION_FUNCTION_NAME("management.setEnabled"); |
102 | 101 |
103 ManagementSetEnabledFunction(); | 102 SetEnabledFunction(); |
104 | 103 |
105 protected: | 104 protected: |
106 virtual ~ManagementSetEnabledFunction(); | 105 virtual ~SetEnabledFunction(); |
107 | 106 |
108 // ExtensionFunction: | 107 // ExtensionFunction: |
109 virtual bool RunImpl() OVERRIDE; | 108 virtual bool RunImpl() OVERRIDE; |
110 | 109 |
111 // ExtensionInstallPrompt::Delegate. | 110 // ExtensionInstallPrompt::Delegate. |
112 virtual void InstallUIProceed() OVERRIDE; | 111 virtual void InstallUIProceed() OVERRIDE; |
113 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; | 112 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; |
114 | 113 |
115 private: | 114 private: |
116 std::string extension_id_; | 115 std::string extension_id_; |
117 | 116 |
118 // Used for prompting to re-enable items with permissions escalation updates. | 117 // Used for prompting to re-enable items with permissions escalation updates. |
119 scoped_ptr<ExtensionInstallPrompt> install_prompt_; | 118 scoped_ptr<ExtensionInstallPrompt> install_prompt_; |
120 }; | 119 }; |
121 | 120 |
122 class ManagementUninstallFunction : public AsyncManagementFunction, | 121 class UninstallFunction : public AsyncManagementFunction, |
123 public ExtensionUninstallDialog::Delegate { | 122 public ExtensionUninstallDialog::Delegate { |
124 public: | 123 public: |
125 DECLARE_EXTENSION_FUNCTION_NAME("management.uninstall"); | 124 DECLARE_EXTENSION_FUNCTION_NAME("management.uninstall"); |
126 | 125 |
127 ManagementUninstallFunction(); | 126 UninstallFunction(); |
128 static void SetAutoConfirmForTest(bool should_proceed); | 127 static void SetAutoConfirmForTest(bool should_proceed); |
129 | 128 |
130 // ExtensionUninstallDialog::Delegate implementation. | 129 // ExtensionUninstallDialog::Delegate implementation. |
131 virtual void ExtensionUninstallAccepted() OVERRIDE; | 130 virtual void ExtensionUninstallAccepted() OVERRIDE; |
132 virtual void ExtensionUninstallCanceled() OVERRIDE; | 131 virtual void ExtensionUninstallCanceled() OVERRIDE; |
133 | 132 |
134 private: | 133 private: |
135 virtual ~ManagementUninstallFunction(); | 134 virtual ~UninstallFunction(); |
136 | 135 |
137 virtual bool RunImpl() OVERRIDE; | 136 virtual bool RunImpl() OVERRIDE; |
138 | 137 |
139 // If should_uninstall is true, this method does the actual uninstall. | 138 // If should_uninstall is true, this method does the actual uninstall. |
140 // If |show_uninstall_dialog|, then this function will be called by one of the | 139 // If |show_uninstall_dialog|, then this function will be called by one of the |
141 // Accepted/Canceled callbacks. Otherwise, it's called directly from RunImpl. | 140 // Accepted/Canceled callbacks. Otherwise, it's called directly from RunImpl. |
142 void Finish(bool should_uninstall); | 141 void Finish(bool should_uninstall); |
143 | 142 |
144 std::string extension_id_; | 143 std::string extension_id_; |
145 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; | 144 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 191 |
193 // Created lazily upon OnListenerAdded. | 192 // Created lazily upon OnListenerAdded. |
194 scoped_ptr<ManagementEventRouter> management_event_router_; | 193 scoped_ptr<ManagementEventRouter> management_event_router_; |
195 | 194 |
196 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); | 195 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); |
197 }; | 196 }; |
198 | 197 |
199 } // namespace extensions | 198 } // namespace extensions |
200 | 199 |
201 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ | 200 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ |
OLD | NEW |