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.
5 #ifndef CHROME_FRAME_POLICY_SETTINGS_H_
6 #define CHROME_FRAME_POLICY_SETTINGS_H_
11 #include "base/basictypes.h"
12 #include "base/command_line.h"
13 #include "base/memory/singleton.h"
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
{
20 typedef enum RendererForUrl
{
21 RENDERER_NOT_SPECIFIED
= -1,
23 RENDER_IN_CHROME_FRAME
,
26 static PolicySettings
* GetInstance();
28 RendererForUrl
default_renderer() const {
29 return default_renderer_
;
32 RendererForUrl
GetRendererForUrl(const wchar_t* url
);
34 RendererForUrl
GetRendererForContentType(const wchar_t* content_type
);
36 // Returns the policy-configured Chrome app locale, or an empty string if none
38 const std::wstring
& ApplicationLocale() const {
39 return application_locale_
;
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;
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
);
52 static void ReadStringSetting(const char* value_name
, std::wstring
* value
);
56 : default_renderer_(RENDERER_NOT_SPECIFIED
),
57 additional_launch_parameters_(CommandLine::NO_PROGRAM
) {
58 RefreshFromRegistry();
64 // Protected for now since the class is not thread safe.
65 void RefreshFromRegistry();
68 RendererForUrl default_renderer_
;
69 std::vector
<std::wstring
> renderer_exclusion_list_
;
70 std::vector
<std::wstring
> content_type_list_
;
71 std::wstring application_locale_
;
72 CommandLine additional_launch_parameters_
;
75 // This ensures no construction is possible outside of the class itself.
76 friend struct DefaultSingletonTraits
<PolicySettings
>;
77 DISALLOW_COPY_AND_ASSIGN(PolicySettings
);
80 #endif // CHROME_FRAME_POLICY_SETTINGS_H_