Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: chrome_frame/policy_settings.h

Issue 5581008: Add a new GetInstance() method for singleton classes, take 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/singleton.h"
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 13
13 // A simple class that reads and caches policy settings for Chrome Frame. 14 // A simple class that reads and caches policy settings for Chrome Frame.
14 // TODO(tommi): Support refreshing when new settings are pushed. 15 // TODO(tommi): Support refreshing when new settings are pushed.
15 // TODO(tommi): Use Chrome's classes for this (and the notification service). 16 // TODO(tommi): Use Chrome's classes for this (and the notification service).
16 class PolicySettings { 17 class PolicySettings {
17 public: 18 public:
18 typedef enum RendererForUrl { 19 typedef enum RendererForUrl {
19 RENDERER_NOT_SPECIFIED = -1, 20 RENDERER_NOT_SPECIFIED = -1,
20 RENDER_IN_HOST, 21 RENDER_IN_HOST,
21 RENDER_IN_CHROME_FRAME, 22 RENDER_IN_CHROME_FRAME,
22 }; 23 };
23 24
24 PolicySettings() : default_renderer_(RENDERER_NOT_SPECIFIED) { 25 static PolicySettings* GetInstance();
25 RefreshFromRegistry();
26 }
27
28 ~PolicySettings() {
29 }
30 26
31 RendererForUrl default_renderer() const { 27 RendererForUrl default_renderer() const {
32 return default_renderer_; 28 return default_renderer_;
33 } 29 }
34 30
35 RendererForUrl GetRendererForUrl(const wchar_t* url); 31 RendererForUrl GetRendererForUrl(const wchar_t* url);
36 32
37 RendererForUrl GetRendererForContentType(const wchar_t* content_type); 33 RendererForUrl GetRendererForContentType(const wchar_t* content_type);
38 34
39 // Returns the policy-configured Chrome app locale, or an empty string if none 35 // Returns the policy-configured Chrome app locale, or an empty string if none
40 // is configured. 36 // is configured.
41 const std::wstring& ApplicationLocale() const { 37 const std::wstring& ApplicationLocale() const {
42 return application_locale_; 38 return application_locale_;
43 } 39 }
44 40
45 // Helper functions for reading settings from the registry 41 // Helper functions for reading settings from the registry
46 static void ReadUrlSettings(RendererForUrl* default_renderer, 42 static void ReadUrlSettings(RendererForUrl* default_renderer,
47 std::vector<std::wstring>* renderer_exclusion_list); 43 std::vector<std::wstring>* renderer_exclusion_list);
48 static void ReadContentTypeSetting( 44 static void ReadContentTypeSetting(
49 std::vector<std::wstring>* content_type_list); 45 std::vector<std::wstring>* content_type_list);
50 static void ReadApplicationLocaleSetting(std::wstring* application_locale); 46 static void ReadApplicationLocaleSetting(std::wstring* application_locale);
51 47
52 protected: 48 protected:
49 PolicySettings() : default_renderer_(RENDERER_NOT_SPECIFIED) {
50 RefreshFromRegistry();
51 }
52
53 ~PolicySettings() {
54 }
55
53 // Protected for now since the class is not thread safe. 56 // Protected for now since the class is not thread safe.
54 void RefreshFromRegistry(); 57 void RefreshFromRegistry();
55 58
56 protected: 59 protected:
57 RendererForUrl default_renderer_; 60 RendererForUrl default_renderer_;
58 std::vector<std::wstring> renderer_exclusion_list_; 61 std::vector<std::wstring> renderer_exclusion_list_;
59 std::vector<std::wstring> content_type_list_; 62 std::vector<std::wstring> content_type_list_;
60 std::wstring application_locale_; 63 std::wstring application_locale_;
61 64
62 private: 65 private:
66 // This ensures no construction is possible outside of the class itself.
67 friend struct DefaultSingletonTraits<PolicySettings>;
63 DISALLOW_COPY_AND_ASSIGN(PolicySettings); 68 DISALLOW_COPY_AND_ASSIGN(PolicySettings);
64 }; 69 };
65 70
66
67 #endif // CHROME_FRAME_POLICY_SETTINGS_H_ 71 #endif // CHROME_FRAME_POLICY_SETTINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698