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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
37 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
38 #include "chrome/grit/generated_resources.h" | 38 #include "chrome/grit/generated_resources.h" |
39 #include "components/pref_registry/pref_registry_syncable.h" | 39 #include "components/pref_registry/pref_registry_syncable.h" |
40 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 40 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
41 #include "components/signin/core/browser/signin_manager.h" | 41 #include "components/signin/core/browser/signin_manager.h" |
42 #include "components/signin/core/browser/signin_manager_base.h" | 42 #include "components/signin/core/browser/signin_manager_base.h" |
43 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
44 #include "content/public/browser/user_metrics.h" | 44 #include "content/public/browser/user_metrics.h" |
45 #include "google_apis/gaia/google_service_auth_error.h" | 45 #include "google_apis/gaia/google_service_auth_error.h" |
46 #include "net/base/escape.h" | |
47 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
48 | 47 |
49 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
50 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 49 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
51 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 50 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
52 #include "components/user_manager/user_manager.h" | 51 #include "components/user_manager/user_manager.h" |
53 #endif | 52 #endif |
54 | 53 |
55 #if defined(ENABLE_EXTENSIONS) | 54 #if defined(ENABLE_EXTENSIONS) |
56 #include "chrome/browser/extensions/extension_service.h" | 55 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 } | 533 } |
535 | 534 |
536 void SupervisedUserService::OnPermissionRequestIssued() { | 535 void SupervisedUserService::OnPermissionRequestIssued() { |
537 waiting_for_permissions_ = false; | 536 waiting_for_permissions_ = false; |
538 // TODO(akuegel): Figure out how to show the result of issuing the permission | 537 // TODO(akuegel): Figure out how to show the result of issuing the permission |
539 // request in the UI. Currently, we assume the permission request was created | 538 // request in the UI. Currently, we assume the permission request was created |
540 // successfully. | 539 // successfully. |
541 } | 540 } |
542 | 541 |
543 void SupervisedUserService::AddAccessRequest(const GURL& url) { | 542 void SupervisedUserService::AddAccessRequest(const GURL& url) { |
544 // Normalize the URL. | |
545 GURL normalized_url = SupervisedUserURLFilter::Normalize(url); | |
546 | |
547 // Escape the URL. | |
548 std::string output(net::EscapeQueryParamValue(normalized_url.spec(), true)); | |
549 | |
550 waiting_for_permissions_ = true; | 543 waiting_for_permissions_ = true; |
551 permissions_creator_->CreatePermissionRequest( | 544 permissions_creator_->CreatePermissionRequest( |
552 output, | 545 SupervisedUserURLFilter::Normalize(url), |
553 base::Bind(&SupervisedUserService::OnPermissionRequestIssued, | 546 base::Bind(&SupervisedUserService::OnPermissionRequestIssued, |
554 weak_ptr_factory_.GetWeakPtr())); | 547 weak_ptr_factory_.GetWeakPtr())); |
555 } | 548 } |
556 | 549 |
557 SupervisedUserService::ManualBehavior | 550 SupervisedUserService::ManualBehavior |
558 SupervisedUserService::GetManualBehaviorForHost( | 551 SupervisedUserService::GetManualBehaviorForHost( |
559 const std::string& hostname) { | 552 const std::string& hostname) { |
560 const base::DictionaryValue* dict = | 553 const base::DictionaryValue* dict = |
561 profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualHosts); | 554 profile_->GetPrefs()->GetDictionary(prefs::kSupervisedUserManualHosts); |
562 bool allow = false; | 555 bool allow = false; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 // The active user can be NULL in unit tests. | 816 // The active user can be NULL in unit tests. |
824 if (user_manager::UserManager::Get()->GetActiveUser()) { | 817 if (user_manager::UserManager::Get()->GetActiveUser()) { |
825 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( | 818 return UTF16ToUTF8(user_manager::UserManager::Get()->GetUserDisplayName( |
826 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); | 819 user_manager::UserManager::Get()->GetActiveUser()->GetUserID())); |
827 } | 820 } |
828 return std::string(); | 821 return std::string(); |
829 #else | 822 #else |
830 return profile_->GetPrefs()->GetString(prefs::kProfileName); | 823 return profile_->GetPrefs()->GetString(prefs::kProfileName); |
831 #endif | 824 #endif |
832 } | 825 } |
OLD | NEW |