OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/managed_mode/managed_user_service.h" | 5 #include "chrome/browser/managed_mode/managed_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/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 #if defined(OS_CHROMEOS) | 53 #if defined(OS_CHROMEOS) |
54 #include "chrome/browser/chromeos/login/supervised_user_manager.h" | 54 #include "chrome/browser/chromeos/login/supervised_user_manager.h" |
55 #include "chrome/browser/chromeos/login/user_manager.h" | 55 #include "chrome/browser/chromeos/login/user_manager.h" |
56 #endif | 56 #endif |
57 | 57 |
58 using base::DictionaryValue; | 58 using base::DictionaryValue; |
59 using base::Value; | 59 using base::Value; |
60 using content::BrowserThread; | 60 using content::BrowserThread; |
61 | 61 |
62 namespace { | |
63 | |
64 const char kManagedModeFinchActive[] = "Active"; | 62 const char kManagedModeFinchActive[] = "Active"; |
65 const char kManagedModeFinchName[] = "ManagedModeLaunch"; | 63 const char kManagedModeFinchName[] = "ManagedModeLaunch"; |
66 const char kManagedUserAccessRequestKeyPrefix[] = | 64 const char kManagedUserAccessRequestKeyPrefix[] = |
67 "X-ManagedUser-AccessRequests"; | 65 "X-ManagedUser-AccessRequests"; |
68 const char kManagedUserAccessRequestTime[] = "timestamp"; | 66 const char kManagedUserAccessRequestTime[] = "timestamp"; |
69 const char kOpenManagedProfileKeyPrefix[] = "X-ManagedUser-Events-OpenProfile"; | 67 const char kOpenManagedProfileKeyPrefix[] = "X-ManagedUser-Events-OpenProfile"; |
70 const char kQuitBrowserKeyPrefix[] = "X-ManagedUser-Events-QuitBrowser"; | 68 const char kQuitBrowserKeyPrefix[] = "X-ManagedUser-Events-QuitBrowser"; |
71 const char kSwitchFromManagedProfileKeyPrefix[] = | 69 const char kSwitchFromManagedProfileKeyPrefix[] = |
72 "X-ManagedUser-Events-SwitchProfile"; | 70 "X-ManagedUser-Events-SwitchProfile"; |
73 const char kEventTimestamp[] = "timestamp"; | 71 const char kEventTimestamp[] = "timestamp"; |
74 | 72 |
75 std::string CanonicalizeHostname(const std::string& hostname) { | |
76 std::string canonicalized; | |
77 url_canon::StdStringCanonOutput output(&canonicalized); | |
78 url_parse::Component in_comp(0, hostname.length()); | |
79 url_parse::Component out_comp; | |
80 | |
81 url_canon::CanonicalizeHost(hostname.c_str(), in_comp, &output, &out_comp); | |
82 output.Complete(); | |
83 return canonicalized; | |
84 } | |
85 | |
86 } // namespace | |
87 | |
88 ManagedUserService::URLFilterContext::URLFilterContext() | 73 ManagedUserService::URLFilterContext::URLFilterContext() |
89 : ui_url_filter_(new ManagedModeURLFilter), | 74 : ui_url_filter_(new ManagedModeURLFilter), |
90 io_url_filter_(new ManagedModeURLFilter) {} | 75 io_url_filter_(new ManagedModeURLFilter) {} |
91 ManagedUserService::URLFilterContext::~URLFilterContext() {} | 76 ManagedUserService::URLFilterContext::~URLFilterContext() {} |
92 | 77 |
93 ManagedModeURLFilter* | 78 ManagedModeURLFilter* |
94 ManagedUserService::URLFilterContext::ui_url_filter() const { | 79 ManagedUserService::URLFilterContext::ui_url_filter() const { |
95 return ui_url_filter_.get(); | 80 return ui_url_filter_.get(); |
96 } | 81 } |
97 | 82 |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 key_prefix, | 680 key_prefix, |
696 base::Int64ToString(base::TimeTicks::Now().ToInternalValue())); | 681 base::Int64ToString(base::TimeTicks::Now().ToInternalValue())); |
697 | 682 |
698 scoped_ptr<DictionaryValue> dict(new DictionaryValue); | 683 scoped_ptr<DictionaryValue> dict(new DictionaryValue); |
699 | 684 |
700 // TODO(bauerb): Use sane time when ready. | 685 // TODO(bauerb): Use sane time when ready. |
701 dict->SetDouble(kEventTimestamp, base::Time::Now().ToJsTime()); | 686 dict->SetDouble(kEventTimestamp, base::Time::Now().ToJsTime()); |
702 | 687 |
703 GetSettingsService()->UploadItem(key, dict.PassAs<Value>()); | 688 GetSettingsService()->UploadItem(key, dict.PassAs<Value>()); |
704 } | 689 } |
OLD | NEW |