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

Side by Side Diff: chrome/browser/prefs/incognito_mode_prefs.cc

Issue 2894483002: Migrate from ScopedComPtr::CreateInstance() to CoCreateInstance in chrome/... (Closed)
Patch Set: Fix Header Include Location Created 3 years, 7 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 "chrome/browser/prefs/incognito_mode_prefs.h" 5 #include "chrome/browser/prefs/incognito_mode_prefs.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/task_scheduler/post_task.h" 13 #include "base/task_scheduler/post_task.h"
14 #include "base/threading/thread_restrictions.h" 14 #include "base/threading/thread_restrictions.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "components/pref_registry/pref_registry_syncable.h" 20 #include "components/pref_registry/pref_registry_syncable.h"
21 #include "components/prefs/pref_service.h" 21 #include "components/prefs/pref_service.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 23
24 #if defined(OS_WIN) 24 #if defined(OS_WIN)
25 #include <windows.h> 25 #include <windows.h>
26 #include <objbase.h>
26 #include <wpcapi.h> 27 #include <wpcapi.h>
27 #include "base/bind.h" 28 #include "base/bind.h"
28 #include "base/bind_helpers.h" 29 #include "base/bind_helpers.h"
29 #include "base/memory/singleton.h" 30 #include "base/memory/singleton.h"
30 #include "base/win/scoped_comptr.h" 31 #include "base/win/scoped_comptr.h"
31 #include "base/win/windows_version.h" 32 #include "base/win/windows_version.h"
32 #endif // OS_WIN 33 #endif // OS_WIN
33 34
34 #if defined(OS_ANDROID) 35 #if defined(OS_ANDROID)
35 #include "chrome/browser/android/partner_browser_customizations.h" 36 #include "chrome/browser/android/partner_browser_customizations.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool result = IsParentalControlActivityLoggingOnImpl(); 96 bool result = IsParentalControlActivityLoggingOnImpl();
96 UMA_HISTOGRAM_TIMES("IncognitoModePrefs.WindowsParentalControlsInitTime", 97 UMA_HISTOGRAM_TIMES("IncognitoModePrefs.WindowsParentalControlsInitTime",
97 base::Time::Now() - begin_time); 98 base::Time::Now() - begin_time);
98 return result; 99 return result;
99 } 100 }
100 101
101 // Does the work of determining if Windows Parental control activity logging 102 // Does the work of determining if Windows Parental control activity logging
102 // is enabled. 103 // is enabled.
103 static bool IsParentalControlActivityLoggingOnImpl() { 104 static bool IsParentalControlActivityLoggingOnImpl() {
104 base::win::ScopedComPtr<IWindowsParentalControlsCore> parent_controls; 105 base::win::ScopedComPtr<IWindowsParentalControlsCore> parent_controls;
105 HRESULT hr = parent_controls.CreateInstance( 106 HRESULT hr = ::CoCreateInstance(__uuidof(WindowsParentalControls), nullptr,
106 __uuidof(WindowsParentalControls)); 107 CLSCTX_ALL, IID_PPV_ARGS(&parent_controls));
107 if (FAILED(hr)) 108 if (FAILED(hr))
108 return false; 109 return false;
109 110
110 base::win::ScopedComPtr<IWPCSettings> settings; 111 base::win::ScopedComPtr<IWPCSettings> settings;
111 hr = parent_controls->GetUserSettings(nullptr, settings.GetAddressOf()); 112 hr = parent_controls->GetUserSettings(nullptr, settings.GetAddressOf());
112 if (FAILED(hr)) 113 if (FAILED(hr))
113 return false; 114 return false;
114 115
115 unsigned long restrictions = 0; 116 unsigned long restrictions = 0;
116 settings->GetRestrictions(&restrictions); 117 settings->GetRestrictions(&restrictions);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 bool valid = IntToAvailability(pref_value, &result); 229 bool valid = IntToAvailability(pref_value, &result);
229 DCHECK(valid); 230 DCHECK(valid);
230 if (result != IncognitoModePrefs::DISABLED && 231 if (result != IncognitoModePrefs::DISABLED &&
231 mode == CHECK_PARENTAL_CONTROLS && ArePlatformParentalControlsEnabled()) { 232 mode == CHECK_PARENTAL_CONTROLS && ArePlatformParentalControlsEnabled()) {
232 if (result == IncognitoModePrefs::FORCED) 233 if (result == IncognitoModePrefs::FORCED)
233 LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on"; 234 LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on";
234 return IncognitoModePrefs::DISABLED; 235 return IncognitoModePrefs::DISABLED;
235 } 236 }
236 return result; 237 return result;
237 } 238 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/antivirus_metrics_provider_win.cc ('k') | chrome/browser/shell_integration_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698