• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2015 The Chromium Embedded Framework Authors.
2 // Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 
6 #include "libcef/browser/alloy/chrome_profile_alloy.h"
7 
8 #include "base/no_destructor.h"
9 #include "components/profile_metrics/browser_profile_type.h"
10 #include "components/variations/variations_client.h"
11 #include "components/variations/variations_ids_provider.h"
12 #include "net/url_request/url_request_context.h"
13 
14 namespace {
15 
16 class CefVariationsClient : public variations::VariationsClient {
17  public:
CefVariationsClient(content::BrowserContext * browser_context)18   explicit CefVariationsClient(content::BrowserContext* browser_context)
19       : browser_context_(browser_context) {}
20 
21   ~CefVariationsClient() override = default;
22 
IsOffTheRecord() const23   bool IsOffTheRecord() const override {
24     return browser_context_->IsOffTheRecord();
25   }
26 
GetVariationsHeaders() const27   variations::mojom::VariationsHeadersPtr GetVariationsHeaders()
28       const override {
29     return variations::VariationsIdsProvider::GetInstance()
30         ->GetClientDataHeaders(false /* is_signed_in */);
31   }
32 
33  private:
34   content::BrowserContext* browser_context_;
35 };
36 
37 }  // namespace
38 
ChromeProfileAlloy()39 ChromeProfileAlloy::ChromeProfileAlloy() {
40   profile_metrics::SetBrowserProfileType(
41       this, profile_metrics::BrowserProfileType::kRegular);
42 }
43 
~ChromeProfileAlloy()44 ChromeProfileAlloy::~ChromeProfileAlloy() {}
45 
IsOffTheRecord()46 bool ChromeProfileAlloy::IsOffTheRecord() {
47   return false;
48 }
49 
IsOffTheRecord() const50 bool ChromeProfileAlloy::IsOffTheRecord() const {
51   // Alloy contexts are never flagged as off-the-record. It causes problems
52   // for the extension system.
53   return false;
54 }
55 
GetOTRProfileID() const56 const Profile::OTRProfileID& ChromeProfileAlloy::GetOTRProfileID() const {
57   NOTREACHED();
58   static base::NoDestructor<Profile::OTRProfileID> otr_profile_id(
59       Profile::OTRProfileID::PrimaryID());
60   return *otr_profile_id;
61 }
62 
GetVariationsClient()63 variations::VariationsClient* ChromeProfileAlloy::GetVariationsClient() {
64   if (!variations_client_)
65     variations_client_ = std::make_unique<CefVariationsClient>(this);
66   return variations_client_.get();
67 }
68 
GetIOTaskRunner()69 scoped_refptr<base::SequencedTaskRunner> ChromeProfileAlloy::GetIOTaskRunner() {
70   NOTREACHED();
71   return scoped_refptr<base::SequencedTaskRunner>();
72 }
73 
GetProfileUserName() const74 std::string ChromeProfileAlloy::GetProfileUserName() const {
75   NOTREACHED();
76   return std::string();
77 }
78 
GetOffTheRecordProfile(const Profile::OTRProfileID & otr_profile_id,bool create_if_needed)79 Profile* ChromeProfileAlloy::GetOffTheRecordProfile(
80     const Profile::OTRProfileID& otr_profile_id,
81     bool create_if_needed) {
82   NOTREACHED();
83   return nullptr;
84 }
85 
GetAllOffTheRecordProfiles()86 std::vector<Profile*> ChromeProfileAlloy::GetAllOffTheRecordProfiles() {
87   return {};
88 }
89 
DestroyOffTheRecordProfile(Profile * otr_profile)90 void ChromeProfileAlloy::DestroyOffTheRecordProfile(Profile* otr_profile) {
91   NOTREACHED();
92 }
93 
HasOffTheRecordProfile(const Profile::OTRProfileID & otr_profile_id)94 bool ChromeProfileAlloy::HasOffTheRecordProfile(
95     const Profile::OTRProfileID& otr_profile_id) {
96   return false;
97 }
98 
HasAnyOffTheRecordProfile()99 bool ChromeProfileAlloy::HasAnyOffTheRecordProfile() {
100   return false;
101 }
102 
GetOriginalProfile()103 Profile* ChromeProfileAlloy::GetOriginalProfile() {
104   return this;
105 }
106 
GetOriginalProfile() const107 const Profile* ChromeProfileAlloy::GetOriginalProfile() const {
108   return this;
109 }
110 
IsChild() const111 bool ChromeProfileAlloy::IsChild() const {
112   return false;
113 }
114 
115 ExtensionSpecialStoragePolicy*
GetExtensionSpecialStoragePolicy()116 ChromeProfileAlloy::GetExtensionSpecialStoragePolicy() {
117   NOTREACHED();
118   return nullptr;
119 }
120 
IsSameOrParent(Profile * profile)121 bool ChromeProfileAlloy::IsSameOrParent(Profile* profile) {
122   NOTREACHED();
123   return false;
124 }
125 
GetStartTime() const126 base::Time ChromeProfileAlloy::GetStartTime() const {
127   NOTREACHED();
128   return base::Time();
129 }
130 
last_selected_directory()131 base::FilePath ChromeProfileAlloy::last_selected_directory() {
132   NOTREACHED();
133   return base::FilePath();
134 }
135 
set_last_selected_directory(const base::FilePath & path)136 void ChromeProfileAlloy::set_last_selected_directory(
137     const base::FilePath& path) {
138   NOTREACHED();
139 }
140 
GetHomePage()141 GURL ChromeProfileAlloy::GetHomePage() {
142   NOTREACHED();
143   return GURL();
144 }
145 
WasCreatedByVersionOrLater(const std::string & version)146 bool ChromeProfileAlloy::WasCreatedByVersionOrLater(
147     const std::string& version) {
148   NOTREACHED();
149   return false;
150 }
151 
GetCreationTime() const152 base::Time ChromeProfileAlloy::GetCreationTime() const {
153   NOTREACHED();
154   return base::Time();
155 }
156 
SetCreationTimeForTesting(base::Time creation_time)157 void ChromeProfileAlloy::SetCreationTimeForTesting(base::Time creation_time) {
158   NOTREACHED();
159 }
160 
RecordPrimaryMainFrameNavigation()161 void ChromeProfileAlloy::RecordPrimaryMainFrameNavigation() {
162   NOTREACHED();
163 }
164 
IsSignedIn()165 bool ChromeProfileAlloy::IsSignedIn() {
166   NOTREACHED();
167   return false;
168 }
169