OLD | NEW |
1 // Copyright (c) 2011 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 #include "base/memory/singleton.h" | |
11 | 10 |
12 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/command_line.h" |
| 13 #include "base/memory/singleton.h" |
13 | 14 |
14 // 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. |
15 // TODO(tommi): Support refreshing when new settings are pushed. | 16 // TODO(tommi): Support refreshing when new settings are pushed. |
16 // 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). |
17 class PolicySettings { | 18 class PolicySettings { |
18 public: | 19 public: |
19 typedef enum RendererForUrl { | 20 typedef enum RendererForUrl { |
20 RENDERER_NOT_SPECIFIED = -1, | 21 RENDERER_NOT_SPECIFIED = -1, |
21 RENDER_IN_HOST, | 22 RENDER_IN_HOST, |
22 RENDER_IN_CHROME_FRAME, | 23 RENDER_IN_CHROME_FRAME, |
23 }; | 24 }; |
24 | 25 |
25 static PolicySettings* GetInstance(); | 26 static PolicySettings* GetInstance(); |
26 | 27 |
27 RendererForUrl default_renderer() const { | 28 RendererForUrl default_renderer() const { |
28 return default_renderer_; | 29 return default_renderer_; |
29 } | 30 } |
30 | 31 |
31 RendererForUrl GetRendererForUrl(const wchar_t* url); | 32 RendererForUrl GetRendererForUrl(const wchar_t* url); |
32 | 33 |
33 RendererForUrl GetRendererForContentType(const wchar_t* content_type); | 34 RendererForUrl GetRendererForContentType(const wchar_t* content_type); |
34 | 35 |
35 // Returns the policy-configured Chrome app locale, or an empty string if none | 36 // Returns the policy-configured Chrome app locale, or an empty string if none |
36 // is configured. | 37 // is configured. |
37 const std::wstring& ApplicationLocale() const { | 38 const std::wstring& ApplicationLocale() const { |
38 return application_locale_; | 39 return application_locale_; |
39 } | 40 } |
40 | 41 |
| 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 |
41 // Helper functions for reading settings from the registry | 47 // Helper functions for reading settings from the registry |
42 static void ReadUrlSettings(RendererForUrl* default_renderer, | 48 static void ReadUrlSettings(RendererForUrl* default_renderer, |
43 std::vector<std::wstring>* renderer_exclusion_list); | 49 std::vector<std::wstring>* renderer_exclusion_list); |
44 static void ReadContentTypeSetting( | 50 static void ReadContentTypeSetting( |
45 std::vector<std::wstring>* content_type_list); | 51 std::vector<std::wstring>* content_type_list); |
46 static void ReadApplicationLocaleSetting(std::wstring* application_locale); | 52 static void ReadStringSetting(const char* value_name, std::wstring* value); |
47 | 53 |
48 protected: | 54 protected: |
49 PolicySettings() : default_renderer_(RENDERER_NOT_SPECIFIED) { | 55 PolicySettings() |
| 56 : default_renderer_(RENDERER_NOT_SPECIFIED), |
| 57 additional_launch_parameters_(CommandLine::NO_PROGRAM) { |
50 RefreshFromRegistry(); | 58 RefreshFromRegistry(); |
51 } | 59 } |
52 | 60 |
53 ~PolicySettings() { | 61 ~PolicySettings() { |
54 } | 62 } |
55 | 63 |
56 // Protected for now since the class is not thread safe. | 64 // Protected for now since the class is not thread safe. |
57 void RefreshFromRegistry(); | 65 void RefreshFromRegistry(); |
58 | 66 |
59 protected: | 67 protected: |
60 RendererForUrl default_renderer_; | 68 RendererForUrl default_renderer_; |
61 std::vector<std::wstring> renderer_exclusion_list_; | 69 std::vector<std::wstring> renderer_exclusion_list_; |
62 std::vector<std::wstring> content_type_list_; | 70 std::vector<std::wstring> content_type_list_; |
63 std::wstring application_locale_; | 71 std::wstring application_locale_; |
| 72 CommandLine additional_launch_parameters_; |
64 | 73 |
65 private: | 74 private: |
66 // This ensures no construction is possible outside of the class itself. | 75 // This ensures no construction is possible outside of the class itself. |
67 friend struct DefaultSingletonTraits<PolicySettings>; | 76 friend struct DefaultSingletonTraits<PolicySettings>; |
68 DISALLOW_COPY_AND_ASSIGN(PolicySettings); | 77 DISALLOW_COPY_AND_ASSIGN(PolicySettings); |
69 }; | 78 }; |
70 | 79 |
71 #endif // CHROME_FRAME_POLICY_SETTINGS_H_ | 80 #endif // CHROME_FRAME_POLICY_SETTINGS_H_ |
OLD | NEW |