Chromium Code Reviews| Index: chrome/browser/chromeos/display/quirks_manager_delegate_impl.cc |
| diff --git a/chrome/browser/chromeos/display/quirks_manager_delegate_impl.cc b/chrome/browser/chromeos/display/quirks_manager_delegate_impl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e5e8fe0574bf61d3f9baf989771428f304ca17ed |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/display/quirks_manager_delegate_impl.cc |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/display/quirks_manager_delegate_impl.h" |
| + |
| +#include "base/path_service.h" |
| +#include "base/sys_info.h" |
| +#include "base/task_runner_util.h" |
| +#include "base/threading/thread_restrictions.h" |
| +#include "chrome/browser/chromeos/login/startup_utils.h" |
| +#include "chrome/common/chrome_paths.h" |
| +#include "chromeos/chromeos_paths.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "google_apis/google_api_keys.h" |
| + |
| +namespace { |
| + |
| +const char kUserDataDisplayProfilesDirectory[] = "display_profiles"; |
| + |
| +int GetDaysSinceOobeOnBlockingPool() { |
| + base::ThreadRestrictions::AssertIOAllowed(); |
|
oshima
2016/03/22 20:27:21
I thought BlockingPool is allowed to access file s
Greg Levin
2016/03/23 00:16:18
Yeah, as far as I know. This should've been delet
|
| + return chromeos::StartupUtils::GetTimeSinceOobeFlagFileCreation().InDays(); |
| +} |
| + |
| +} // namespace |
| + |
| +namespace quirks { |
| + |
| +std::string QuirksManagerDelegateImpl::GetApiKey() const { |
| + return google_apis::GetAPIKey(); |
| +} |
| + |
| +base::FilePath QuirksManagerDelegateImpl::GetBuiltInDisplayProfileDirectory() |
| + const { |
| + base::FilePath path; |
| + if (!PathService::Get(chromeos::DIR_DEVICE_COLOR_CALIBRATION_PROFILES, &path)) |
| + LOG(ERROR) << "Could not get system path for display calibration profiles."; |
| + return path; |
| +} |
| + |
| +// On chrome device, returns /var/cache/display_profiles. |
| +// On Linux desktop, returns {DIR_USER_DATA}/display_profiles. |
| +base::FilePath QuirksManagerDelegateImpl::GetDownloadDisplayProfileDirectory() |
| + const { |
| + base::FilePath directory; |
| + if (base::SysInfo::IsRunningOnChromeOS()) { |
| + PathService::Get(chromeos::DIR_DEVICE_DISPLAY_PROFILES, &directory); |
| + } else { |
| + PathService::Get(chrome::DIR_USER_DATA, &directory); |
| + directory = directory.Append(kUserDataDisplayProfilesDirectory); |
| + } |
| + return directory; |
| +} |
| + |
| +void QuirksManagerDelegateImpl::GetDaysSinceOobe( |
| + QuirksManager::DaysSinceOobeCallback callback) const { |
| + base::PostTaskAndReplyWithResult( |
| + content::BrowserThread::GetBlockingPool(), FROM_HERE, |
| + base::Bind(&GetDaysSinceOobeOnBlockingPool), callback); |
| +} |
| + |
| +} // namespace quirks |