OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/supervised_user/supervised_user_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 BrowserThread::PostTask( | 165 BrowserThread::PostTask( |
166 BrowserThread::IO, | 166 BrowserThread::IO, |
167 FROM_HERE, | 167 FROM_HERE, |
168 base::Bind(&SupervisedUserURLFilter::SetBlacklist, | 168 base::Bind(&SupervisedUserURLFilter::SetBlacklist, |
169 io_url_filter_, | 169 io_url_filter_, |
170 &blacklist_)); | 170 &blacklist_)); |
171 } | 171 } |
172 | 172 |
173 void SupervisedUserService::URLFilterContext::InitAsyncURLChecker( | 173 void SupervisedUserService::URLFilterContext::InitAsyncURLChecker( |
174 net::URLRequestContextGetter* context, | 174 net::URLRequestContextGetter* context, |
175 const std::string& cx) { | 175 const std::string& cx, |
176 ui_url_filter_->InitAsyncURLChecker(context, cx); | 176 const std::string& api_key) { |
| 177 ui_url_filter_->InitAsyncURLChecker(context, cx, api_key); |
177 BrowserThread::PostTask( | 178 BrowserThread::PostTask( |
178 BrowserThread::IO, | 179 BrowserThread::IO, |
179 FROM_HERE, | 180 FROM_HERE, |
180 base::Bind(&SupervisedUserURLFilter::InitAsyncURLChecker, | 181 base::Bind(&SupervisedUserURLFilter::InitAsyncURLChecker, |
181 io_url_filter_, context, cx)); | 182 io_url_filter_, context, cx, api_key)); |
182 } | 183 } |
183 | 184 |
184 SupervisedUserService::SupervisedUserService(Profile* profile) | 185 SupervisedUserService::SupervisedUserService(Profile* profile) |
185 : includes_sync_sessions_type_(true), | 186 : includes_sync_sessions_type_(true), |
186 profile_(profile), | 187 profile_(profile), |
187 active_(false), | 188 active_(false), |
188 delegate_(NULL), | 189 delegate_(NULL), |
189 #if defined(ENABLE_EXTENSIONS) | 190 #if defined(ENABLE_EXTENSIONS) |
190 extension_registry_observer_(this), | 191 extension_registry_observer_(this), |
191 #endif | 192 #endif |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 if (!blacklist_path.empty()) | 864 if (!blacklist_path.empty()) |
864 LoadBlacklist(blacklist_path, delegate_->GetBlacklistURL()); | 865 LoadBlacklist(blacklist_path, delegate_->GetBlacklistURL()); |
865 } | 866 } |
866 bool use_safesites = | 867 bool use_safesites = |
867 CommandLine::ForCurrentProcess()->HasSwitch( | 868 CommandLine::ForCurrentProcess()->HasSwitch( |
868 switches::kEnableSupervisedUserSafeSites); | 869 switches::kEnableSupervisedUserSafeSites); |
869 if (delegate_ && use_safesites) { | 870 if (delegate_ && use_safesites) { |
870 const std::string& cx = delegate_->GetSafeSitesCx(); | 871 const std::string& cx = delegate_->GetSafeSitesCx(); |
871 if (!cx.empty()) { | 872 if (!cx.empty()) { |
872 url_filter_context_.InitAsyncURLChecker( | 873 url_filter_context_.InitAsyncURLChecker( |
873 profile_->GetRequestContext(), cx); | 874 profile_->GetRequestContext(), cx, delegate_->GetSafeSitesApiKey()); |
874 } | 875 } |
875 } | 876 } |
876 | 877 |
877 #if !defined(OS_ANDROID) | 878 #if !defined(OS_ANDROID) |
878 // TODO(bauerb): Get rid of the platform-specific #ifdef here. | 879 // TODO(bauerb): Get rid of the platform-specific #ifdef here. |
879 // http://crbug.com/313377 | 880 // http://crbug.com/313377 |
880 BrowserList::AddObserver(this); | 881 BrowserList::AddObserver(this); |
881 #endif | 882 #endif |
882 } else { | 883 } else { |
883 permissions_creators_.clear(); | 884 permissions_creators_.clear(); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 // The active user can be NULL in unit tests. | 1007 // The active user can be NULL in unit tests. |
1007 if (user_manager::UserManager::Get()->GetActiveUser()) { | 1008 if (user_manager::UserManager::Get()->GetActiveUser()) { |
1008 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( | 1009 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( |
1009 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); | 1010 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); |
1010 } | 1011 } |
1011 return std::string(); | 1012 return std::string(); |
1012 #else | 1013 #else |
1013 return profile_->GetPrefs()->GetString(prefs::kProfileName); | 1014 return profile_->GetPrefs()->GetString(prefs::kProfileName); |
1014 #endif | 1015 #endif |
1015 } | 1016 } |
OLD | NEW |