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

Side by Side Diff: chrome/browser/profiles/profile_io_data.cc

Issue 336213005: Disable incognito link if parental control is on (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moves parental control check to profile_io_data Created 6 years, 6 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/profiles/profile_io_data.h" 5 #include "chrome/browser/profiles/profile_io_data.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 24 matching lines...) Expand all
35 #include "chrome/browser/extensions/extension_resource_protocols.h" 35 #include "chrome/browser/extensions/extension_resource_protocols.h"
36 #include "chrome/browser/io_thread.h" 36 #include "chrome/browser/io_thread.h"
37 #include "chrome/browser/media/media_device_id_salt.h" 37 #include "chrome/browser/media/media_device_id_salt.h"
38 #include "chrome/browser/net/about_protocol_handler.h" 38 #include "chrome/browser/net/about_protocol_handler.h"
39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" 39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h"
40 #include "chrome/browser/net/chrome_http_user_agent_settings.h" 40 #include "chrome/browser/net/chrome_http_user_agent_settings.h"
41 #include "chrome/browser/net/chrome_net_log.h" 41 #include "chrome/browser/net/chrome_net_log.h"
42 #include "chrome/browser/net/chrome_network_delegate.h" 42 #include "chrome/browser/net/chrome_network_delegate.h"
43 #include "chrome/browser/net/cookie_store_util.h" 43 #include "chrome/browser/net/cookie_store_util.h"
44 #include "chrome/browser/net/proxy_service_factory.h" 44 #include "chrome/browser/net/proxy_service_factory.h"
45 #include "chrome/browser/prefs/incognito_mode_prefs.h"
45 #include "chrome/browser/profiles/profile.h" 46 #include "chrome/browser/profiles/profile.h"
46 #include "chrome/browser/profiles/profile_manager.h" 47 #include "chrome/browser/profiles/profile_manager.h"
47 #include "chrome/browser/signin/signin_names_io_thread.h" 48 #include "chrome/browser/signin/signin_names_io_thread.h"
48 #include "chrome/common/chrome_paths.h" 49 #include "chrome/common/chrome_paths.h"
49 #include "chrome/common/chrome_switches.h" 50 #include "chrome/common/chrome_switches.h"
50 #include "chrome/common/pref_names.h" 51 #include "chrome/common/pref_names.h"
51 #include "chrome/common/url_constants.h" 52 #include "chrome/common/url_constants.h"
52 #include "components/startup_metric_utils/startup_metric_utils.h" 53 #include "components/startup_metric_utils/startup_metric_utils.h"
53 #include "components/sync_driver/pref_names.h" 54 #include "components/sync_driver/pref_names.h"
54 #include "components/url_fixer/url_fixer.h" 55 #include "components/url_fixer/url_fixer.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 #include "net/cert/multi_threaded_cert_verifier.h" 113 #include "net/cert/multi_threaded_cert_verifier.h"
113 #include "net/ssl/client_cert_store_chromeos.h" 114 #include "net/ssl/client_cert_store_chromeos.h"
114 #endif // defined(OS_CHROMEOS) 115 #endif // defined(OS_CHROMEOS)
115 116
116 #if defined(USE_NSS) 117 #if defined(USE_NSS)
117 #include "chrome/browser/ui/crypto_module_delegate_nss.h" 118 #include "chrome/browser/ui/crypto_module_delegate_nss.h"
118 #include "net/ssl/client_cert_store_nss.h" 119 #include "net/ssl/client_cert_store_nss.h"
119 #endif 120 #endif
120 121
121 #if defined(OS_WIN) 122 #if defined(OS_WIN)
123 #include "base/win/metro.h"
122 #include "net/ssl/client_cert_store_win.h" 124 #include "net/ssl/client_cert_store_win.h"
123 #endif 125 #endif
124 126
125 #if defined(OS_MACOSX) 127 #if defined(OS_MACOSX)
126 #include "net/ssl/client_cert_store_mac.h" 128 #include "net/ssl/client_cert_store_mac.h"
127 #endif 129 #endif
128 130
131 #if defined(OS_ANDROID)
Bernhard Bauer 2014/06/17 09:15:45 Move this block before OS_WIN, so the #ifdef condi
guohui 2014/06/17 18:45:04 Done.
132 #include "chrome/browser/android/chromium_application.h"
133 #endif // OS_ANDROID
134
129 using content::BrowserContext; 135 using content::BrowserContext;
130 using content::BrowserThread; 136 using content::BrowserThread;
131 using content::ResourceContext; 137 using content::ResourceContext;
132 138
133 namespace { 139 namespace {
134 140
135 #if defined(DEBUG_DEVTOOLS) 141 #if defined(DEBUG_DEVTOOLS)
136 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { 142 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) {
137 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); 143 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath);
138 bundled_path_prefix = "/" + bundled_path_prefix + "/"; 144 bundled_path_prefix = "/" + bundled_path_prefix + "/";
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // Add policy headers for non-incognito requests. 463 // Add policy headers for non-incognito requests.
458 policy::PolicyHeaderService* policy_header_service = 464 policy::PolicyHeaderService* policy_header_service =
459 policy::PolicyHeaderServiceFactory::GetForBrowserContext(profile); 465 policy::PolicyHeaderServiceFactory::GetForBrowserContext(profile);
460 if (policy_header_service) { 466 if (policy_header_service) {
461 policy_header_helper_ = policy_header_service->CreatePolicyHeaderIOHelper( 467 policy_header_helper_ = policy_header_service->CreatePolicyHeaderIOHelper(
462 io_message_loop_proxy); 468 io_message_loop_proxy);
463 } 469 }
464 } 470 }
465 #endif 471 #endif
466 472
473 // Makes sure the cached variable for parental control is initialized.
474 IncognitoModePrefs::GetAvailability(profile->GetPrefs());
mmenke 2014/06/16 23:25:11 Is there a reason we can't use a PrefMember to kee
Bernhard Bauer 2014/06/17 09:15:45 The value isn't always coming from PrefService (if
467 incognito_availibility_pref_.Init( 475 incognito_availibility_pref_.Init(
468 prefs::kIncognitoModeAvailability, pref_service); 476 prefs::kIncognitoModeAvailability, pref_service);
469 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy); 477 incognito_availibility_pref_.MoveToThread(io_message_loop_proxy);
470 478
471 initialized_on_UI_thread_ = true; 479 initialized_on_UI_thread_ = true;
472 480
473 // We need to make sure that content initializes its own data structures that 481 // We need to make sure that content initializes its own data structures that
474 // are associated with each ResourceContext because we might post this 482 // are associated with each ResourceContext because we might post this
475 // object to the IO thread after this function. 483 // object to the IO thread after this function.
476 BrowserContext::EnsureResourceContextInitialized(profile); 484 BrowserContext::EnsureResourceContextInitialized(profile);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 753
746 ResourceContext::SaltCallback ProfileIOData::GetMediaDeviceIDSalt() const { 754 ResourceContext::SaltCallback ProfileIOData::GetMediaDeviceIDSalt() const {
747 return base::Bind(&MediaDeviceIDSalt::GetSalt, media_device_id_salt_); 755 return base::Bind(&MediaDeviceIDSalt::GetSalt, media_device_id_salt_);
748 } 756 }
749 757
750 bool ProfileIOData::IsOffTheRecord() const { 758 bool ProfileIOData::IsOffTheRecord() const {
751 return profile_type() == Profile::INCOGNITO_PROFILE 759 return profile_type() == Profile::INCOGNITO_PROFILE
752 || profile_type() == Profile::GUEST_PROFILE; 760 || profile_type() == Profile::GUEST_PROFILE;
753 } 761 }
754 762
763 bool ProfileIOData::ArePlatformParentalControlsEnabledCached() const {
Bernhard Bauer 2014/06/17 09:15:45 So... above we initialize the parental control set
guohui 2014/06/17 18:45:04 Done.
764 #if defined(OS_WIN)
765 return base::win::IsParentalControlActivityLoggingOnCached();
766 #elif defined(OS_ANDROID)
767 return chrome::android::ChromiumApplication::AreParentalControlsEnabled();
768 #else
769 return false;
770 #endif
771 }
772
755 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { 773 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() {
756 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 774 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
757 #if defined(OS_CHROMEOS) 775 #if defined(OS_CHROMEOS)
758 // Just fetch the value from ChromeOS' settings while we're on the UI thread. 776 // Just fetch the value from ChromeOS' settings while we're on the UI thread.
759 // TODO(stevet): For now, this value is only set on profile initialization. 777 // TODO(stevet): For now, this value is only set on profile initialization.
760 // We will want to do something similar to the PrefMember method below in the 778 // We will want to do something similar to the PrefMember method below in the
761 // future to more accurately capture this state. 779 // future to more accurately capture this state.
762 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, 780 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref,
763 &enable_metrics_); 781 &enable_metrics_);
764 #elif defined(OS_ANDROID) 782 #elif defined(OS_ANDROID)
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 void ProfileIOData::SetCookieSettingsForTesting( 1209 void ProfileIOData::SetCookieSettingsForTesting(
1192 CookieSettings* cookie_settings) { 1210 CookieSettings* cookie_settings) {
1193 DCHECK(!cookie_settings_.get()); 1211 DCHECK(!cookie_settings_.get());
1194 cookie_settings_ = cookie_settings; 1212 cookie_settings_ = cookie_settings;
1195 } 1213 }
1196 1214
1197 void ProfileIOData::set_signin_names_for_testing( 1215 void ProfileIOData::set_signin_names_for_testing(
1198 SigninNamesOnIOThread* signin_names) { 1216 SigninNamesOnIOThread* signin_names) {
1199 signin_names_.reset(signin_names); 1217 signin_names_.reset(signin_names);
1200 } 1218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698