[email protected] | 3e5dd57 | 2012-03-28 06:58:33 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 55604d7 | 2010-09-15 14:41:48 | [diff] [blame] | 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_FRAME_POLICY_SETTINGS_H_ | ||||
6 | #define CHROME_FRAME_POLICY_SETTINGS_H_ | ||||
7 | |||||
8 | #include <string> | ||||
9 | #include <vector> | ||||
10 | |||||
[email protected] | 6ae3d49 | 2010-10-20 14:01:21 | [diff] [blame] | 11 | #include "base/basictypes.h" |
[email protected] | 3e5dd57 | 2012-03-28 06:58:33 | [diff] [blame] | 12 | #include "base/command_line.h" |
13 | #include "base/memory/singleton.h" | ||||
[email protected] | 6ae3d49 | 2010-10-20 14:01:21 | [diff] [blame] | 14 | |
[email protected] | 55604d7 | 2010-09-15 14:41:48 | [diff] [blame] | 15 | // A simple class that reads and caches policy settings for Chrome Frame. |
16 | // TODO(tommi): Support refreshing when new settings are pushed. | ||||
17 | // TODO(tommi): Use Chrome's classes for this (and the notification service). | ||||
18 | class PolicySettings { | ||||
19 | public: | ||||
20 | typedef enum RendererForUrl { | ||||
21 | RENDERER_NOT_SPECIFIED = -1, | ||||
22 | RENDER_IN_HOST, | ||||
23 | RENDER_IN_CHROME_FRAME, | ||||
24 | }; | ||||
25 | |||||
[email protected] | 687b960 | 2010-12-08 10:43:08 | [diff] [blame] | 26 | static PolicySettings* GetInstance(); |
[email protected] | 55604d7 | 2010-09-15 14:41:48 | [diff] [blame] | 27 | |
28 | RendererForUrl default_renderer() const { | ||||
29 | return default_renderer_; | ||||
30 | } | ||||
31 | |||||
32 | RendererForUrl GetRendererForUrl(const wchar_t* url); | ||||
33 | |||||
[email protected] | 5ac670a | 2010-10-04 23:07:40 | [diff] [blame] | 34 | RendererForUrl GetRendererForContentType(const wchar_t* content_type); |
35 | |||||
[email protected] | 6ae3d49 | 2010-10-20 14:01:21 | [diff] [blame] | 36 | // Returns the policy-configured Chrome app locale, or an empty string if none |
37 | // is configured. | ||||
38 | const std::wstring& ApplicationLocale() const { | ||||
39 | return application_locale_; | ||||
40 | } | ||||
41 | |||||
[email protected] | 3e5dd57 | 2012-03-28 06:58:33 | [diff] [blame] | 42 | // Contains additional parameters that can optionally be configured for the |
43 | // current user via the policy settings. The program part of this command | ||||
44 | // line object must not be used when appending to another command line. | ||||
45 | const CommandLine& AdditionalLaunchParameters() const; | ||||
46 | |||||
[email protected] | 6ae3d49 | 2010-10-20 14:01:21 | [diff] [blame] | 47 | // Helper functions for reading settings from the registry |
48 | static void ReadUrlSettings(RendererForUrl* default_renderer, | ||||
49 | std::vector<std::wstring>* renderer_exclusion_list); | ||||
50 | static void ReadContentTypeSetting( | ||||
51 | std::vector<std::wstring>* content_type_list); | ||||
[email protected] | 3e5dd57 | 2012-03-28 06:58:33 | [diff] [blame] | 52 | static void ReadStringSetting(const char* value_name, std::wstring* value); |
[email protected] | 6ae3d49 | 2010-10-20 14:01:21 | [diff] [blame] | 53 | |
[email protected] | 55604d7 | 2010-09-15 14:41:48 | [diff] [blame] | 54 | protected: |
[email protected] | 3e5dd57 | 2012-03-28 06:58:33 | [diff] [blame] | 55 | PolicySettings() |
56 | : default_renderer_(RENDERER_NOT_SPECIFIED), | ||||
57 | additional_launch_parameters_(CommandLine::NO_PROGRAM) { | ||||
[email protected] | 687b960 | 2010-12-08 10:43:08 | [diff] [blame] | 58 | RefreshFromRegistry(); |
59 | } | ||||
60 | |||||
61 | ~PolicySettings() { | ||||
62 | } | ||||
63 | |||||
[email protected] | 55604d7 | 2010-09-15 14:41:48 | [diff] [blame] | 64 | // Protected for now since the class is not thread safe. |
65 | void RefreshFromRegistry(); | ||||
66 | |||||
67 | protected: | ||||
68 | RendererForUrl default_renderer_; | ||||
69 | std::vector<std::wstring> renderer_exclusion_list_; | ||||
[email protected] | 5ac670a | 2010-10-04 23:07:40 | [diff] [blame] | 70 | std::vector<std::wstring> content_type_list_; |
[email protected] | 6ae3d49 | 2010-10-20 14:01:21 | [diff] [blame] | 71 | std::wstring application_locale_; |
[email protected] | 3e5dd57 | 2012-03-28 06:58:33 | [diff] [blame] | 72 | CommandLine additional_launch_parameters_; |
[email protected] | 6ae3d49 | 2010-10-20 14:01:21 | [diff] [blame] | 73 | |
74 | private: | ||||
[email protected] | 687b960 | 2010-12-08 10:43:08 | [diff] [blame] | 75 | // This ensures no construction is possible outside of the class itself. |
76 | friend struct DefaultSingletonTraits<PolicySettings>; | ||||
[email protected] | 6ae3d49 | 2010-10-20 14:01:21 | [diff] [blame] | 77 | DISALLOW_COPY_AND_ASSIGN(PolicySettings); |
[email protected] | 55604d7 | 2010-09-15 14:41:48 | [diff] [blame] | 78 | }; |
79 | |||||
[email protected] | 55604d7 | 2010-09-15 14:41:48 | [diff] [blame] | 80 | #endif // CHROME_FRAME_POLICY_SETTINGS_H_ |