| 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_UI_WEBUI_POLICY_UI_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_POLICY_UI_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_POLICY_UI_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_POLICY_UI_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "components/policy/core/browser/policy_error_map.h" | 15 #include "components/policy/core/browser/policy_error_map.h" |
| 16 #include "components/policy/core/common/policy_map.h" | 16 #include "components/policy/core/common/policy_map.h" |
| 17 #include "components/policy/core/common/policy_namespace.h" | 17 #include "components/policy/core/common/policy_namespace.h" |
| 18 #include "components/policy/core/common/policy_service.h" | 18 #include "components/policy/core/common/policy_service.h" |
| 19 #include "components/policy/core/common/schema_registry.h" | 19 #include "components/policy/core/common/schema_registry.h" |
| 20 #include "content/public/browser/web_ui.h" | 20 #include "content/public/browser/web_ui.h" |
| 21 #include "content/public/browser/web_ui_data_source.h" | 21 #include "content/public/browser/web_ui_data_source.h" |
| 22 #include "content/public/browser/web_ui_message_handler.h" | 22 #include "content/public/browser/web_ui_message_handler.h" |
| 23 #include "extensions/features/features.h" |
| 23 | 24 |
| 24 #if defined(ENABLE_EXTENSIONS) | 25 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 25 #include "extensions/browser/extension_registry_observer.h" | 26 #include "extensions/browser/extension_registry_observer.h" |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 struct PolicyStringMap { | 29 struct PolicyStringMap { |
| 29 const char* key; | 30 const char* key; |
| 30 int string_id; | 31 int string_id; |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 class CloudPolicyStatusProvider; | 34 class CloudPolicyStatusProvider; |
| 34 | 35 |
| 35 // The JavaScript message handler for the chrome://policy page. | 36 // The JavaScript message handler for the chrome://policy page. |
| 36 class PolicyUIHandler : public content::WebUIMessageHandler, | 37 class PolicyUIHandler : public content::WebUIMessageHandler, |
| 37 #if defined(ENABLE_EXTENSIONS) | 38 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 38 public extensions::ExtensionRegistryObserver, | 39 public extensions::ExtensionRegistryObserver, |
| 39 #endif | 40 #endif |
| 40 public policy::PolicyService::Observer, | 41 public policy::PolicyService::Observer, |
| 41 public policy::SchemaRegistry::Observer { | 42 public policy::SchemaRegistry::Observer { |
| 42 public: | 43 public: |
| 43 PolicyUIHandler(); | 44 PolicyUIHandler(); |
| 44 ~PolicyUIHandler() override; | 45 ~PolicyUIHandler() override; |
| 45 | 46 |
| 46 | 47 |
| 47 static void AddLocalizedPolicyStrings(content::WebUIDataSource* source, | 48 static void AddLocalizedPolicyStrings(content::WebUIDataSource* source, |
| 48 const PolicyStringMap* strings, | 49 const PolicyStringMap* strings, |
| 49 size_t count); | 50 size_t count); |
| 50 | 51 |
| 51 static void AddCommonLocalizedStringsToSource( | 52 static void AddCommonLocalizedStringsToSource( |
| 52 content::WebUIDataSource* source); | 53 content::WebUIDataSource* source); |
| 53 | 54 |
| 54 // content::WebUIMessageHandler implementation. | 55 // content::WebUIMessageHandler implementation. |
| 55 void RegisterMessages() override; | 56 void RegisterMessages() override; |
| 56 | 57 |
| 57 #if defined(ENABLE_EXTENSIONS) | 58 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 58 // extensions::ExtensionRegistryObserver implementation. | 59 // extensions::ExtensionRegistryObserver implementation. |
| 59 void OnExtensionLoaded(content::BrowserContext* browser_context, | 60 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 60 const extensions::Extension* extension) override; | 61 const extensions::Extension* extension) override; |
| 61 void OnExtensionUnloaded( | 62 void OnExtensionUnloaded( |
| 62 content::BrowserContext* browser_context, | 63 content::BrowserContext* browser_context, |
| 63 const extensions::Extension* extension, | 64 const extensions::Extension* extension, |
| 64 extensions::UnloadedExtensionInfo::Reason reason) override; | 65 extensions::UnloadedExtensionInfo::Reason reason) override; |
| 65 #endif | 66 #endif |
| 66 | 67 |
| 67 // policy::PolicyService::Observer implementation. | 68 // policy::PolicyService::Observer implementation. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // the platform (Chrome OS / desktop) and type of policy that is in effect. | 113 // the platform (Chrome OS / desktop) and type of policy that is in effect. |
| 113 std::unique_ptr<CloudPolicyStatusProvider> user_status_provider_; | 114 std::unique_ptr<CloudPolicyStatusProvider> user_status_provider_; |
| 114 std::unique_ptr<CloudPolicyStatusProvider> device_status_provider_; | 115 std::unique_ptr<CloudPolicyStatusProvider> device_status_provider_; |
| 115 | 116 |
| 116 base::WeakPtrFactory<PolicyUIHandler> weak_factory_; | 117 base::WeakPtrFactory<PolicyUIHandler> weak_factory_; |
| 117 | 118 |
| 118 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler); | 119 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler); |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 #endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_HANDLER_H_ | 122 #endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_HANDLER_H_ |
| OLD | NEW |