| OLD | NEW |
| 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" | |
| 8 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 9 #include "base/win/scoped_comptr.h" | |
| 10 #include "base/win/windows_version.h" | |
| 11 | 8 |
| 12 namespace base { | 9 namespace base { |
| 13 namespace win { | 10 namespace win { |
| 14 | 11 |
| 15 HMODULE GetMetroModule() { | 12 HMODULE GetMetroModule() { |
| 16 const HMODULE kUninitialized = reinterpret_cast<HMODULE>(1); | 13 const HMODULE kUninitialized = reinterpret_cast<HMODULE>(1); |
| 17 static HMODULE metro_module = kUninitialized; | 14 static HMODULE metro_module = kUninitialized; |
| 18 | 15 |
| 19 if (metro_module == kUninitialized) { | 16 if (metro_module == kUninitialized) { |
| 20 // Initialize the cache, note that the initialization is idempotent | 17 // Initialize the cache, note that the initialization is idempotent |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 return false; | 63 return false; |
| 67 } | 64 } |
| 68 | 65 |
| 69 wchar_t* LocalAllocAndCopyString(const string16& src) { | 66 wchar_t* LocalAllocAndCopyString(const string16& src) { |
| 70 size_t dest_size = (src.length() + 1) * sizeof(wchar_t); | 67 size_t dest_size = (src.length() + 1) * sizeof(wchar_t); |
| 71 wchar_t* dest = reinterpret_cast<wchar_t*>(LocalAlloc(LPTR, dest_size)); | 68 wchar_t* dest = reinterpret_cast<wchar_t*>(LocalAlloc(LPTR, dest_size)); |
| 72 base::wcslcpy(dest, src.c_str(), dest_size); | 69 base::wcslcpy(dest, src.c_str(), dest_size); |
| 73 return dest; | 70 return dest; |
| 74 } | 71 } |
| 75 | 72 |
| 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 | 73 // Metro driver exports for getting the launch type, initial url, initial |
| 109 // search term, etc. | 74 // search term, etc. |
| 110 extern "C" { | 75 extern "C" { |
| 111 typedef const wchar_t* (*GetInitialUrl)(); | 76 typedef const wchar_t* (*GetInitialUrl)(); |
| 112 typedef const wchar_t* (*GetInitialSearchString)(); | 77 typedef const wchar_t* (*GetInitialSearchString)(); |
| 113 typedef base::win::MetroLaunchType (*GetLaunchType)( | 78 typedef base::win::MetroLaunchType (*GetLaunchType)( |
| 114 base::win::MetroPreviousExecutionState* previous_state); | 79 base::win::MetroPreviousExecutionState* previous_state); |
| 115 } | 80 } |
| 116 | 81 |
| 117 MetroLaunchType GetMetroLaunchParams(string16* params) { | 82 MetroLaunchType GetMetroLaunchParams(string16* params) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 136 reinterpret_cast<GetInitialSearchString>( | 101 reinterpret_cast<GetInitialSearchString>( |
| 137 ::GetProcAddress(metro, "GetInitialSearchString")); | 102 ::GetProcAddress(metro, "GetInitialSearchString")); |
| 138 DCHECK(initial_search_string); | 103 DCHECK(initial_search_string); |
| 139 *params = initial_search_string(); | 104 *params = initial_search_string(); |
| 140 } | 105 } |
| 141 return launch_type; | 106 return launch_type; |
| 142 } | 107 } |
| 143 | 108 |
| 144 } // namespace win | 109 } // namespace win |
| 145 } // namespace base | 110 } // namespace base |
| OLD | NEW |