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_FRAME_POLICY_SETTINGS_H_ | 5 #ifndef CHROME_FRAME_POLICY_SETTINGS_H_ |
6 #define CHROME_FRAME_POLICY_SETTINGS_H_ | 6 #define CHROME_FRAME_POLICY_SETTINGS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 | 14 |
15 // A simple class that reads and caches policy settings for Chrome Frame. | 15 // A simple class that reads and caches policy settings for Chrome Frame. |
16 // TODO(tommi): Support refreshing when new settings are pushed. | 16 // TODO(tommi): Support refreshing when new settings are pushed. |
17 // TODO(tommi): Use Chrome's classes for this (and the notification service). | 17 // TODO(tommi): Use Chrome's classes for this (and the notification service). |
18 class PolicySettings { | 18 class PolicySettings { |
19 public: | 19 public: |
20 typedef enum RendererForUrl { | 20 enum RendererForUrl { |
21 RENDERER_NOT_SPECIFIED = -1, | 21 RENDERER_NOT_SPECIFIED = -1, |
22 RENDER_IN_HOST, | 22 RENDER_IN_HOST, |
23 RENDER_IN_CHROME_FRAME, | 23 RENDER_IN_CHROME_FRAME, |
24 }; | 24 }; |
25 | 25 |
26 enum SkipMetadataCheck { | |
27 SKIP_METADATA_CHECK_NOT_SPECIFIED = -1, | |
grt (UTC plus 2)
2013/08/02 01:42:50
two-space indent here rather than four.
| |
28 SKIP_METADATA_CHECK_NO, | |
29 SKIP_METADATA_CHECK_YES, | |
30 }; | |
31 | |
26 static PolicySettings* GetInstance(); | 32 static PolicySettings* GetInstance(); |
27 | 33 |
28 RendererForUrl default_renderer() const { | 34 RendererForUrl default_renderer() const { |
29 return default_renderer_; | 35 return default_renderer_; |
30 } | 36 } |
31 | 37 |
38 SkipMetadataCheck skip_metadata_check() const { | |
39 return skip_metadata_check_; | |
40 } | |
41 | |
32 RendererForUrl GetRendererForUrl(const wchar_t* url); | 42 RendererForUrl GetRendererForUrl(const wchar_t* url); |
33 | 43 |
34 RendererForUrl GetRendererForContentType(const wchar_t* content_type); | 44 RendererForUrl GetRendererForContentType(const wchar_t* content_type); |
35 | 45 |
36 // Returns the policy-configured Chrome app locale, or an empty string if none | 46 // Returns the policy-configured Chrome app locale, or an empty string if none |
37 // is configured. | 47 // is configured. |
38 const std::wstring& ApplicationLocale() const { | 48 const std::wstring& ApplicationLocale() const { |
39 return application_locale_; | 49 return application_locale_; |
40 } | 50 } |
41 | 51 |
42 // Contains additional parameters that can optionally be configured for the | 52 // Contains additional parameters that can optionally be configured for the |
43 // current user via the policy settings. The program part of this command | 53 // 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. | 54 // line object must not be used when appending to another command line. |
45 const CommandLine& AdditionalLaunchParameters() const; | 55 const CommandLine& AdditionalLaunchParameters() const; |
46 | 56 |
47 // Returns true if the Chrome Frame turndown prompt should be suppressed. | 57 // Returns true if the Chrome Frame turndown prompt should be suppressed. |
48 bool suppress_turndown_prompt() const { | 58 bool suppress_turndown_prompt() const { |
49 return suppress_turndown_prompt_; | 59 return suppress_turndown_prompt_; |
50 } | 60 } |
51 | 61 |
52 // Helper functions for reading settings from the registry | 62 // Helper functions for reading settings from the registry |
53 static void ReadUrlSettings(RendererForUrl* default_renderer, | 63 static void ReadUrlSettings(RendererForUrl* default_renderer, |
54 std::vector<std::wstring>* renderer_exclusion_list); | 64 std::vector<std::wstring>* renderer_exclusion_list); |
65 static void ReadMetadataCheckSettings(SkipMetadataCheck* skip_metadata_check); | |
55 static void ReadContentTypeSetting( | 66 static void ReadContentTypeSetting( |
56 std::vector<std::wstring>* content_type_list); | 67 std::vector<std::wstring>* content_type_list); |
57 static void ReadStringSetting(const char* value_name, std::wstring* value); | 68 static void ReadStringSetting(const char* value_name, std::wstring* value); |
58 static void ReadBoolSetting(const char* value_name, bool* value); | 69 static void ReadBoolSetting(const char* value_name, bool* value); |
59 | 70 |
60 protected: | 71 protected: |
61 PolicySettings() | 72 PolicySettings() |
62 : default_renderer_(RENDERER_NOT_SPECIFIED), | 73 : default_renderer_(RENDERER_NOT_SPECIFIED), |
74 skip_metadata_check_(SKIP_METADATA_CHECK_NOT_SPECIFIED), | |
63 additional_launch_parameters_(CommandLine::NO_PROGRAM), | 75 additional_launch_parameters_(CommandLine::NO_PROGRAM), |
64 suppress_turndown_prompt_(false) { | 76 suppress_turndown_prompt_(false) { |
65 RefreshFromRegistry(); | 77 RefreshFromRegistry(); |
66 } | 78 } |
67 | 79 |
68 ~PolicySettings() { | 80 ~PolicySettings() { |
69 } | 81 } |
70 | 82 |
71 // Protected for now since the class is not thread safe. | 83 // Protected for now since the class is not thread safe. |
72 void RefreshFromRegistry(); | 84 void RefreshFromRegistry(); |
73 | 85 |
74 protected: | 86 protected: |
75 RendererForUrl default_renderer_; | 87 RendererForUrl default_renderer_; |
88 SkipMetadataCheck skip_metadata_check_; | |
76 std::vector<std::wstring> renderer_exclusion_list_; | 89 std::vector<std::wstring> renderer_exclusion_list_; |
77 std::vector<std::wstring> content_type_list_; | 90 std::vector<std::wstring> content_type_list_; |
78 std::wstring application_locale_; | 91 std::wstring application_locale_; |
79 CommandLine additional_launch_parameters_; | 92 CommandLine additional_launch_parameters_; |
80 bool suppress_turndown_prompt_; | 93 bool suppress_turndown_prompt_; |
81 | 94 |
82 private: | 95 private: |
83 // This ensures no construction is possible outside of the class itself. | 96 // This ensures no construction is possible outside of the class itself. |
84 friend struct DefaultSingletonTraits<PolicySettings>; | 97 friend struct DefaultSingletonTraits<PolicySettings>; |
85 DISALLOW_COPY_AND_ASSIGN(PolicySettings); | 98 DISALLOW_COPY_AND_ASSIGN(PolicySettings); |
86 }; | 99 }; |
87 | 100 |
88 #endif // CHROME_FRAME_POLICY_SETTINGS_H_ | 101 #endif // CHROME_FRAME_POLICY_SETTINGS_H_ |
OLD | NEW |