Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: chrome/browser/ui/webui/policy_ui_handler.h

Issue 1395073002: Policy Ui sends correct translations for risk tags. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactoring: New file for PolicyMaterialDesignUi and PolicyUiHandler. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_POLICY_UI_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_POLICY_UI_HANDLER_H_
Dan Beam 2015/11/03 18:34:11 #include <string>
fhorschig 2015/11/04 18:51:18 Done.
7
8 #include "base/macros.h"
Dan Beam 2015/11/03 18:34:11 #include "base/memory/scoped_ptr.h" #include "base
fhorschig 2015/11/04 18:51:18 Done.
9 #include "components/policy/core/browser/policy_error_map.h"
10 #include "components/policy/core/common/policy_map.h"
11 #include "components/policy/core/common/policy_namespace.h"
12 #include "components/policy/core/common/policy_service.h"
13 #include "components/policy/core/common/schema_registry.h"
14 #include "content/public/browser/web_ui.h"
15 #include "content/public/browser/web_ui_data_source.h"
16 #include "content/public/browser/web_ui_message_handler.h"
17
18 #if defined(ENABLE_EXTENSIONS)
19 #include "extensions/browser/extension_registry_observer.h"
20 #endif
21
22 struct PolicyStringMap {
23 const char* key;
24 int string_id;
25 };
26
27 class CloudPolicyStatusProvider;
28
29 // The JavaScript message handler for the chrome://policy page.
30 class PolicyUIHandler : public content::WebUIMessageHandler,
31 #if defined(ENABLE_EXTENSIONS)
32 public extensions::ExtensionRegistryObserver,
33 #endif
34 public policy::PolicyService::Observer,
35 public policy::SchemaRegistry::Observer {
36 public:
37 PolicyUIHandler();
38 ~PolicyUIHandler() override;
39
40
41 static void AddLocalizedPolicyStrings(content::WebUIDataSource* source,
42 const PolicyStringMap* strings,
43 size_t count);
44
45 static void AddCommonLocalizedStringsToSource(
46 content::WebUIDataSource* source);
47
48 // content::WebUIMessageHandler implementation.
49 void RegisterMessages() override;
50
51 #if defined(ENABLE_EXTENSIONS)
52 // extensions::ExtensionRegistryObserver implementation.
53 void OnExtensionLoaded(content::BrowserContext* browser_context,
54 const extensions::Extension* extension) override;
55 void OnExtensionUnloaded(
56 content::BrowserContext* browser_context,
57 const extensions::Extension* extension,
58 extensions::UnloadedExtensionInfo::Reason reason) override;
59 #endif
60
61 // policy::PolicyService::Observer implementation.
62 void OnPolicyUpdated(const policy::PolicyNamespace& ns,
63 const policy::PolicyMap& previous,
64 const policy::PolicyMap& current) override;
65
66 // policy::SchemaRegistry::Observer implementation.
67 void OnSchemaRegistryUpdated(bool has_new_schemas) override;
68
69 protected:
70 virtual void AddPolicyName(const std::string& name,
71 base::DictionaryValue* names) const;
72
73 // Send a dictionary containing the names of all known policies to the UI.
74 virtual void SendPolicyNames() const;
75
76 private:
77 // Send information about the current policy values to the UI. For each policy
78 // whose value has been set, a dictionary containing the value and additional
79 // metadata is sent.
80 void SendPolicyValues() const;
81
82 // Send the status of cloud policy to the UI. For each scope that has cloud
83 // policy enabled (device and/or user), a dictionary containing status
84 // information is sent.
85 void SendStatus() const;
86
87 // Inserts a description of each policy in |policy_map| into |values|, using
88 // the optional errors in |errors| to determine the status of each policy.
89 void GetPolicyValues(const policy::PolicyMap& policy_map,
90 policy::PolicyErrorMap* errors,
91 base::DictionaryValue* values) const;
92
93 void GetChromePolicyValues(base::DictionaryValue* values) const;
94
95 void HandleInitialized(const base::ListValue* args);
96 void HandleReloadPolicies(const base::ListValue* args);
97
98 void OnRefreshPoliciesDone() const;
99
100 policy::PolicyService* GetPolicyService() const;
101
102 std::string device_domain_;
103
104 // Providers that supply status dictionaries for user and device policy,
105 // respectively. These are created on initialization time as appropriate for
106 // the platform (Chrome OS / desktop) and type of policy that is in effect.
107 scoped_ptr<CloudPolicyStatusProvider> user_status_provider_;
108 scoped_ptr<CloudPolicyStatusProvider> device_status_provider_;
109
110 base::WeakPtrFactory<PolicyUIHandler> weak_factory_;
111
112 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler);
113 };
114
115 #endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698