blob: aaae32c5d305968629cc2fe43b02e00fb21ab192 [file] [log] [blame]
[email protected]3e5dd572012-03-28 06:58:331// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]55604d72010-09-15 14:41:482// 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]6ae3d492010-10-20 14:01:2111#include "base/basictypes.h"
[email protected]3e5dd572012-03-28 06:58:3312#include "base/command_line.h"
13#include "base/memory/singleton.h"
[email protected]6ae3d492010-10-20 14:01:2114
[email protected]55604d72010-09-15 14:41:4815// 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).
18class 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]687b9602010-12-08 10:43:0826 static PolicySettings* GetInstance();
[email protected]55604d72010-09-15 14:41:4827
28 RendererForUrl default_renderer() const {
29 return default_renderer_;
30 }
31
32 RendererForUrl GetRendererForUrl(const wchar_t* url);
33
[email protected]5ac670a2010-10-04 23:07:4034 RendererForUrl GetRendererForContentType(const wchar_t* content_type);
35
[email protected]6ae3d492010-10-20 14:01:2136 // 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]3e5dd572012-03-28 06:58:3342 // 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]6ae3d492010-10-20 14:01:2147 // 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]3e5dd572012-03-28 06:58:3352 static void ReadStringSetting(const char* value_name, std::wstring* value);
[email protected]6ae3d492010-10-20 14:01:2153
[email protected]55604d72010-09-15 14:41:4854 protected:
[email protected]3e5dd572012-03-28 06:58:3355 PolicySettings()
56 : default_renderer_(RENDERER_NOT_SPECIFIED),
57 additional_launch_parameters_(CommandLine::NO_PROGRAM) {
[email protected]687b9602010-12-08 10:43:0858 RefreshFromRegistry();
59 }
60
61 ~PolicySettings() {
62 }
63
[email protected]55604d72010-09-15 14:41:4864 // 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]5ac670a2010-10-04 23:07:4070 std::vector<std::wstring> content_type_list_;
[email protected]6ae3d492010-10-20 14:01:2171 std::wstring application_locale_;
[email protected]3e5dd572012-03-28 06:58:3372 CommandLine additional_launch_parameters_;
[email protected]6ae3d492010-10-20 14:01:2173
74 private:
[email protected]687b9602010-12-08 10:43:0875 // This ensures no construction is possible outside of the class itself.
76 friend struct DefaultSingletonTraits<PolicySettings>;
[email protected]6ae3d492010-10-20 14:01:2177 DISALLOW_COPY_AND_ASSIGN(PolicySettings);
[email protected]55604d72010-09-15 14:41:4878};
79
[email protected]55604d72010-09-15 14:41:4880#endif // CHROME_FRAME_POLICY_SETTINGS_H_