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()39ChromeProfileAlloy::ChromeProfileAlloy() { 40 profile_metrics::SetBrowserProfileType( 41 this, profile_metrics::BrowserProfileType::kRegular); 42 } 43 ~ChromeProfileAlloy()44ChromeProfileAlloy::~ChromeProfileAlloy() {} 45 IsOffTheRecord()46bool ChromeProfileAlloy::IsOffTheRecord() { 47 return false; 48 } 49 IsOffTheRecord() const50bool 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() const56const 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()63variations::VariationsClient* ChromeProfileAlloy::GetVariationsClient() { 64 if (!variations_client_) 65 variations_client_ = std::make_unique<CefVariationsClient>(this); 66 return variations_client_.get(); 67 } 68 GetIOTaskRunner()69scoped_refptr<base::SequencedTaskRunner> ChromeProfileAlloy::GetIOTaskRunner() { 70 NOTREACHED(); 71 return scoped_refptr<base::SequencedTaskRunner>(); 72 } 73 GetProfileUserName() const74std::string ChromeProfileAlloy::GetProfileUserName() const { 75 NOTREACHED(); 76 return std::string(); 77 } 78 GetOffTheRecordProfile(const Profile::OTRProfileID & otr_profile_id,bool create_if_needed)79Profile* ChromeProfileAlloy::GetOffTheRecordProfile( 80 const Profile::OTRProfileID& otr_profile_id, 81 bool create_if_needed) { 82 NOTREACHED(); 83 return nullptr; 84 } 85 GetAllOffTheRecordProfiles()86std::vector<Profile*> ChromeProfileAlloy::GetAllOffTheRecordProfiles() { 87 return {}; 88 } 89 DestroyOffTheRecordProfile(Profile * otr_profile)90void ChromeProfileAlloy::DestroyOffTheRecordProfile(Profile* otr_profile) { 91 NOTREACHED(); 92 } 93 HasOffTheRecordProfile(const Profile::OTRProfileID & otr_profile_id)94bool ChromeProfileAlloy::HasOffTheRecordProfile( 95 const Profile::OTRProfileID& otr_profile_id) { 96 return false; 97 } 98 HasAnyOffTheRecordProfile()99bool ChromeProfileAlloy::HasAnyOffTheRecordProfile() { 100 return false; 101 } 102 GetOriginalProfile()103Profile* ChromeProfileAlloy::GetOriginalProfile() { 104 return this; 105 } 106 GetOriginalProfile() const107const Profile* ChromeProfileAlloy::GetOriginalProfile() const { 108 return this; 109 } 110 IsChild() const111bool ChromeProfileAlloy::IsChild() const { 112 return false; 113 } 114 115 ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy()116ChromeProfileAlloy::GetExtensionSpecialStoragePolicy() { 117 NOTREACHED(); 118 return nullptr; 119 } 120 IsSameOrParent(Profile * profile)121bool ChromeProfileAlloy::IsSameOrParent(Profile* profile) { 122 NOTREACHED(); 123 return false; 124 } 125 GetStartTime() const126base::Time ChromeProfileAlloy::GetStartTime() const { 127 NOTREACHED(); 128 return base::Time(); 129 } 130 last_selected_directory()131base::FilePath ChromeProfileAlloy::last_selected_directory() { 132 NOTREACHED(); 133 return base::FilePath(); 134 } 135 set_last_selected_directory(const base::FilePath & path)136void ChromeProfileAlloy::set_last_selected_directory( 137 const base::FilePath& path) { 138 NOTREACHED(); 139 } 140 GetHomePage()141GURL ChromeProfileAlloy::GetHomePage() { 142 NOTREACHED(); 143 return GURL(); 144 } 145 WasCreatedByVersionOrLater(const std::string & version)146bool ChromeProfileAlloy::WasCreatedByVersionOrLater( 147 const std::string& version) { 148 NOTREACHED(); 149 return false; 150 } 151 GetCreationTime() const152base::Time ChromeProfileAlloy::GetCreationTime() const { 153 NOTREACHED(); 154 return base::Time(); 155 } 156 SetCreationTimeForTesting(base::Time creation_time)157void ChromeProfileAlloy::SetCreationTimeForTesting(base::Time creation_time) { 158 NOTREACHED(); 159 } 160 RecordPrimaryMainFrameNavigation()161void ChromeProfileAlloy::RecordPrimaryMainFrameNavigation() { 162 NOTREACHED(); 163 } 164 IsSignedIn()165bool ChromeProfileAlloy::IsSignedIn() { 166 NOTREACHED(); 167 return false; 168 } 169