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

Side by Side Diff: base/win/metro.cc

Issue 969813005: Unify the Windows Parental Controls Platform Caching (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Feedback Created 5 years, 9 months 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
OLDNEW
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 #include "base/win/metro.h" 5 #include "base/win/metro.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
grt (UTC plus 2) 2015/03/04 03:59:39 this also seems to be unused. would you remove it
robliao 2015/03/04 18:47:43 Done.
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/win/scoped_comptr.h" 9 #include "base/win/scoped_comptr.h"
grt (UTC plus 2) 2015/03/04 03:59:39 unused
robliao 2015/03/04 18:47:44 Done.
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
grt (UTC plus 2) 2015/03/04 03:59:39 unused
robliao 2015/03/04 18:47:44 Done.
11 11
12 namespace base { 12 namespace base {
13 namespace win { 13 namespace win {
14 14
15 HMODULE GetMetroModule() { 15 HMODULE GetMetroModule() {
16 const HMODULE kUninitialized = reinterpret_cast<HMODULE>(1); 16 const HMODULE kUninitialized = reinterpret_cast<HMODULE>(1);
17 static HMODULE metro_module = kUninitialized; 17 static HMODULE metro_module = kUninitialized;
18 18
19 if (metro_module == kUninitialized) { 19 if (metro_module == kUninitialized) {
20 // Initialize the cache, note that the initialization is idempotent 20 // Initialize the cache, note that the initialization is idempotent
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 return false; 66 return false;
67 } 67 }
68 68
69 wchar_t* LocalAllocAndCopyString(const string16& src) { 69 wchar_t* LocalAllocAndCopyString(const string16& src) {
70 size_t dest_size = (src.length() + 1) * sizeof(wchar_t); 70 size_t dest_size = (src.length() + 1) * sizeof(wchar_t);
71 wchar_t* dest = reinterpret_cast<wchar_t*>(LocalAlloc(LPTR, dest_size)); 71 wchar_t* dest = reinterpret_cast<wchar_t*>(LocalAlloc(LPTR, dest_size));
72 base::wcslcpy(dest, src.c_str(), dest_size); 72 base::wcslcpy(dest, src.c_str(), dest_size);
73 return dest; 73 return dest;
74 } 74 }
75 75
76 bool IsParentalControlActivityLoggingOn() {
77 // Query this info on Windows 7 and above.
78 if (base::win::GetVersion() < base::win::VERSION_WIN7)
79 return false;
80
81 static bool parental_control_logging_required = false;
82 static bool parental_control_status_determined = false;
83
84 if (parental_control_status_determined)
85 return parental_control_logging_required;
86
87 parental_control_status_determined = true;
88
89 ScopedComPtr<IWindowsParentalControlsCore> parent_controls;
90 HRESULT hr = parent_controls.CreateInstance(
91 __uuidof(WindowsParentalControls));
92 if (FAILED(hr))
93 return false;
94
95 ScopedComPtr<IWPCSettings> settings;
96 hr = parent_controls->GetUserSettings(NULL, settings.Receive());
97 if (FAILED(hr))
98 return false;
99
100 unsigned long restrictions = 0;
101 settings->GetRestrictions(&restrictions);
102
103 parental_control_logging_required =
104 (restrictions & WPCFLAG_LOGGING_REQUIRED) == WPCFLAG_LOGGING_REQUIRED;
105 return parental_control_logging_required;
106 }
107
108 // Metro driver exports for getting the launch type, initial url, initial 76 // Metro driver exports for getting the launch type, initial url, initial
109 // search term, etc. 77 // search term, etc.
110 extern "C" { 78 extern "C" {
111 typedef const wchar_t* (*GetInitialUrl)(); 79 typedef const wchar_t* (*GetInitialUrl)();
112 typedef const wchar_t* (*GetInitialSearchString)(); 80 typedef const wchar_t* (*GetInitialSearchString)();
113 typedef base::win::MetroLaunchType (*GetLaunchType)( 81 typedef base::win::MetroLaunchType (*GetLaunchType)(
114 base::win::MetroPreviousExecutionState* previous_state); 82 base::win::MetroPreviousExecutionState* previous_state);
115 } 83 }
116 84
117 MetroLaunchType GetMetroLaunchParams(string16* params) { 85 MetroLaunchType GetMetroLaunchParams(string16* params) {
(...skipping 18 matching lines...) Expand all
136 reinterpret_cast<GetInitialSearchString>( 104 reinterpret_cast<GetInitialSearchString>(
137 ::GetProcAddress(metro, "GetInitialSearchString")); 105 ::GetProcAddress(metro, "GetInitialSearchString"));
138 DCHECK(initial_search_string); 106 DCHECK(initial_search_string);
139 *params = initial_search_string(); 107 *params = initial_search_string();
140 } 108 }
141 return launch_type; 109 return launch_type;
142 } 110 }
143 111
144 } // namespace win 112 } // namespace win
145 } // namespace base 113 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698