2015-10-17 02:44:00 +02:00
|
|
|
// Copyright (c) 2015 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2012 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.
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
#include "libcef/browser/alloy/chrome_profile_alloy.h"
|
2015-10-17 02:44:00 +02:00
|
|
|
|
2020-08-29 00:39:23 +02:00
|
|
|
#include "base/no_destructor.h"
|
2021-06-04 03:34:56 +02:00
|
|
|
#include "components/profile_metrics/browser_profile_type.h"
|
2020-03-30 22:13:42 +02:00
|
|
|
#include "components/variations/variations_client.h"
|
2020-08-29 00:39:23 +02:00
|
|
|
#include "components/variations/variations_ids_provider.h"
|
2018-10-02 14:14:11 +02:00
|
|
|
#include "net/url_request/url_request_context.h"
|
|
|
|
|
2020-03-30 22:13:42 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
class CefVariationsClient : public variations::VariationsClient {
|
|
|
|
public:
|
|
|
|
explicit CefVariationsClient(content::BrowserContext* browser_context)
|
|
|
|
: browser_context_(browser_context) {}
|
|
|
|
|
|
|
|
~CefVariationsClient() override = default;
|
|
|
|
|
2020-07-08 19:23:29 +02:00
|
|
|
bool IsOffTheRecord() const override {
|
2020-03-30 22:13:42 +02:00
|
|
|
return browser_context_->IsOffTheRecord();
|
|
|
|
}
|
|
|
|
|
2020-10-08 21:54:42 +02:00
|
|
|
variations::mojom::VariationsHeadersPtr GetVariationsHeaders()
|
|
|
|
const override {
|
2020-08-29 00:39:23 +02:00
|
|
|
return variations::VariationsIdsProvider::GetInstance()
|
2020-10-08 21:54:42 +02:00
|
|
|
->GetClientDataHeaders(false /* is_signed_in */);
|
2020-03-30 22:13:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
content::BrowserContext* browser_context_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2021-06-04 03:34:56 +02:00
|
|
|
ChromeProfileAlloy::ChromeProfileAlloy() {
|
|
|
|
profile_metrics::SetBrowserProfileType(
|
|
|
|
this, profile_metrics::BrowserProfileType::kRegular);
|
|
|
|
}
|
2015-10-17 02:44:00 +02:00
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
ChromeProfileAlloy::~ChromeProfileAlloy() {}
|
2015-10-17 02:44:00 +02:00
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool ChromeProfileAlloy::IsOffTheRecord() {
|
2019-09-04 17:13:32 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool ChromeProfileAlloy::IsOffTheRecord() const {
|
2021-06-04 03:34:56 +02:00
|
|
|
// Alloy contexts are never flagged as off-the-record. It causes problems
|
|
|
|
// for the extension system.
|
2019-09-04 17:13:32 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
const Profile::OTRProfileID& ChromeProfileAlloy::GetOTRProfileID() const {
|
2020-06-09 19:48:00 +02:00
|
|
|
NOTREACHED();
|
|
|
|
static base::NoDestructor<Profile::OTRProfileID> otr_profile_id(
|
2021-06-04 03:34:56 +02:00
|
|
|
Profile::OTRProfileID::PrimaryID());
|
2020-06-09 19:48:00 +02:00
|
|
|
return *otr_profile_id;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
variations::VariationsClient* ChromeProfileAlloy::GetVariationsClient() {
|
2020-03-30 22:13:42 +02:00
|
|
|
if (!variations_client_)
|
|
|
|
variations_client_ = std::make_unique<CefVariationsClient>(this);
|
|
|
|
return variations_client_.get();
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
scoped_refptr<base::SequencedTaskRunner> ChromeProfileAlloy::GetIOTaskRunner() {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2015-10-17 02:44:00 +02:00
|
|
|
return scoped_refptr<base::SequencedTaskRunner>();
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
std::string ChromeProfileAlloy::GetProfileUserName() const {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2015-10-17 02:44:00 +02:00
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
Profile* ChromeProfileAlloy::GetOffTheRecordProfile(
|
2021-04-21 00:52:34 +02:00
|
|
|
const Profile::OTRProfileID& otr_profile_id,
|
|
|
|
bool create_if_needed) {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2015-10-17 02:44:00 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
std::vector<Profile*> ChromeProfileAlloy::GetAllOffTheRecordProfiles() {
|
2020-06-09 19:48:00 +02:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void ChromeProfileAlloy::DestroyOffTheRecordProfile(Profile* otr_profile) {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2015-10-17 02:44:00 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool ChromeProfileAlloy::HasOffTheRecordProfile(
|
2020-06-09 19:48:00 +02:00
|
|
|
const Profile::OTRProfileID& otr_profile_id) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool ChromeProfileAlloy::HasAnyOffTheRecordProfile() {
|
2015-10-17 02:44:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
Profile* ChromeProfileAlloy::GetOriginalProfile() {
|
2015-10-17 02:44:00 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
const Profile* ChromeProfileAlloy::GetOriginalProfile() const {
|
2017-12-07 22:44:24 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool ChromeProfileAlloy::IsSupervised() const {
|
2015-10-17 02:44:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool ChromeProfileAlloy::IsChild() const {
|
2015-10-17 02:44:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ExtensionSpecialStoragePolicy*
|
2020-06-28 20:29:44 +02:00
|
|
|
ChromeProfileAlloy::GetExtensionSpecialStoragePolicy() {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2015-10-17 02:44:00 +02:00
|
|
|
}
|
|
|
|
|
2020-07-08 19:23:29 +02:00
|
|
|
bool ChromeProfileAlloy::IsSameOrParent(Profile* profile) {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2015-10-17 02:44:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
base::Time ChromeProfileAlloy::GetStartTime() const {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2015-10-17 02:44:00 +02:00
|
|
|
return base::Time();
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
base::FilePath ChromeProfileAlloy::last_selected_directory() {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2015-10-17 02:44:00 +02:00
|
|
|
return base::FilePath();
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void ChromeProfileAlloy::set_last_selected_directory(
|
2016-11-07 20:14:09 +01:00
|
|
|
const base::FilePath& path) {
|
|
|
|
NOTREACHED();
|
2015-10-17 02:44:00 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
GURL ChromeProfileAlloy::GetHomePage() {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2015-10-17 02:44:00 +02:00
|
|
|
return GURL();
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool ChromeProfileAlloy::WasCreatedByVersionOrLater(
|
|
|
|
const std::string& version) {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2015-10-17 02:44:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void ChromeProfileAlloy::SetExitType(ExitType exit_type) {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2015-10-17 02:44:00 +02:00
|
|
|
}
|
|
|
|
|
2020-08-29 00:39:23 +02:00
|
|
|
Profile::ExitType ChromeProfileAlloy::GetLastSessionExitType() const {
|
2016-11-07 20:14:09 +01:00
|
|
|
NOTREACHED();
|
2015-10-17 02:44:00 +02:00
|
|
|
return EXIT_NORMAL;
|
|
|
|
}
|
2019-10-01 15:55:16 +02:00
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
base::Time ChromeProfileAlloy::GetCreationTime() const {
|
2019-10-01 15:55:16 +02:00
|
|
|
NOTREACHED();
|
|
|
|
return base::Time();
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void ChromeProfileAlloy::SetCreationTimeForTesting(base::Time creation_time) {
|
2019-10-01 15:55:16 +02:00
|
|
|
NOTREACHED();
|
|
|
|
}
|
2020-10-08 21:54:42 +02:00
|
|
|
|
|
|
|
void ChromeProfileAlloy::RecordMainFrameNavigation() {
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
2021-01-28 00:13:12 +01:00
|
|
|
|
|
|
|
bool ChromeProfileAlloy::IsSignedIn() {
|
|
|
|
NOTREACHED();
|
|
|
|
return false;
|
|
|
|
}
|