| 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_whitelist_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_whitelist_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 installer_->Subscribe( | 65 installer_->Subscribe( |
| 66 base::Bind(&SupervisedUserWhitelistService::OnWhitelistReady, | 66 base::Bind(&SupervisedUserWhitelistService::OnWhitelistReady, |
| 67 weak_ptr_factory_.GetWeakPtr())); | 67 weak_ptr_factory_.GetWeakPtr())); |
| 68 | 68 |
| 69 // Register whitelists specified on the command line. | 69 // Register whitelists specified on the command line. |
| 70 const base::CommandLine* command_line = | 70 const base::CommandLine* command_line = |
| 71 base::CommandLine::ForCurrentProcess(); | 71 base::CommandLine::ForCurrentProcess(); |
| 72 std::string command_line_whitelists = command_line->GetSwitchValueASCII( | 72 std::string command_line_whitelists = command_line->GetSwitchValueASCII( |
| 73 switches::kInstallSupervisedUserWhitelists); | 73 switches::kInstallSupervisedUserWhitelists); |
| 74 std::vector<std::string> split_whitelists; | 74 for (const base::StringPiece& whitelist : base::SplitStringPiece( |
| 75 base::SplitString(command_line_whitelists, ',', &split_whitelists); | 75 command_line_whitelists, ",", |
| 76 for (const std::string& whitelist : split_whitelists) { | 76 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
| 77 std::string id; | 77 std::string id; |
| 78 std::string name; | 78 std::string name; |
| 79 size_t separator = whitelist.find(':'); | 79 size_t separator = whitelist.find(':'); |
| 80 if (separator != std::string::npos) { | 80 if (separator != base::StringPiece::npos) { |
| 81 id = whitelist.substr(0, separator); | 81 whitelist.substr(0, separator).CopyToString(&id); |
| 82 name = whitelist.substr(separator + 1); | 82 whitelist.substr(separator + 1).CopyToString(&name); |
| 83 } else { | 83 } else { |
| 84 id = whitelist; | 84 whitelist.CopyToString(&id); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Skip whitelists that were already registered. | 87 // Skip whitelists that were already registered. |
| 88 if (registered_whitelists_.count(id) > 0u) | 88 if (registered_whitelists_.count(id) > 0u) |
| 89 continue; | 89 continue; |
| 90 | 90 |
| 91 bool new_installation = true; | 91 bool new_installation = true; |
| 92 RegisterWhitelist(id, name, new_installation); | 92 RegisterWhitelist(id, name, new_installation); |
| 93 } | 93 } |
| 94 } | 94 } |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 UMA_HISTOGRAM_TIMES("ManagedUsers.Whitelist.TotalLoadDuration", | 341 UMA_HISTOGRAM_TIMES("ManagedUsers.Whitelist.TotalLoadDuration", |
| 342 base::TimeTicks::Now() - start_time); | 342 base::TimeTicks::Now() - start_time); |
| 343 | 343 |
| 344 // If the whitelist has been unregistered in the mean time, ignore it. | 344 // If the whitelist has been unregistered in the mean time, ignore it. |
| 345 if (registered_whitelists_.count(id) == 0u) | 345 if (registered_whitelists_.count(id) == 0u) |
| 346 return; | 346 return; |
| 347 | 347 |
| 348 loaded_whitelists_[id] = whitelist; | 348 loaded_whitelists_[id] = whitelist; |
| 349 NotifyWhitelistsChanged(); | 349 NotifyWhitelistsChanged(); |
| 350 } | 350 } |
| OLD | NEW |