blob: f59e5b19093f2b47cc2479aa6341feb4a246b002 [file] [log] [blame]
sdefresned967d552015-07-16 08:34:351// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_RLZ_CHROME_RLZ_TRACKER_DELEGATE_H_
6#define CHROME_BROWSER_RLZ_CHROME_RLZ_TRACKER_DELEGATE_H_
7
sdefresnebd4c75c2015-07-22 09:06:188#include "base/callback.h"
sdefresned967d552015-07-16 08:34:359#include "base/macros.h"
blundell81308002015-08-18 15:06:0910#include "components/omnibox/browser/omnibox_event_global_tracker.h"
sdefresned967d552015-07-16 08:34:3511#include "components/rlz/rlz_tracker_delegate.h"
12#include "content/public/browser/notification_observer.h"
13#include "content/public/browser/notification_registrar.h"
14
15class Profile;
16
gab3ca4a492017-03-02 00:19:4117namespace user_prefs {
18class PrefRegistrySyncable;
19}
20
sdefresned967d552015-07-16 08:34:3521// ChromeRLZTrackerDelegate implements RLZTrackerDelegate abstract interface
22// and provides access to Chrome features.
23class ChromeRLZTrackerDelegate : public rlz::RLZTrackerDelegate,
24 public content::NotificationObserver {
25 public:
26 ChromeRLZTrackerDelegate();
Peter Boström53c6c5952021-09-17 09:41:2627
28 ChromeRLZTrackerDelegate(const ChromeRLZTrackerDelegate&) = delete;
29 ChromeRLZTrackerDelegate& operator=(const ChromeRLZTrackerDelegate&) = delete;
30
sdefresned967d552015-07-16 08:34:3531 ~ChromeRLZTrackerDelegate() override;
32
gab3ca4a492017-03-02 00:19:4133 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
34
sdefresned967d552015-07-16 08:34:3535 static bool IsGoogleDefaultSearch(Profile* profile);
36 static bool IsGoogleHomepage(Profile* profile);
37 static bool IsGoogleInStartpages(Profile* profile);
38
39 private:
40 // RLZTrackerDelegate implementation.
41 void Cleanup() override;
42 bool IsOnUIThread() override;
Antonio Gomesa739bf462018-08-13 20:50:3043 scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
sdefresned967d552015-07-16 08:34:3544 bool GetBrand(std::string* brand) override;
45 bool IsBrandOrganic(const std::string& brand) override;
46 bool GetReactivationBrand(std::string* brand) override;
47 bool ShouldEnableZeroDelayForTesting() override;
Jan Wilken Dörriedec99122021-03-11 18:02:3048 bool GetLanguage(std::u16string* language) override;
49 bool GetReferral(std::u16string* referral) override;
sdefresned967d552015-07-16 08:34:3550 bool ClearReferral() override;
Ayu Ishiiebdc85f2020-02-07 17:50:4351 void SetOmniboxSearchCallback(base::OnceClosure callback) override;
52 void SetHomepageSearchCallback(base::OnceClosure callback) override;
Jérôme Lebel0d2a5a82018-12-06 10:13:3753 bool ShouldUpdateExistingAccessPointRlz() override;
sdefresned967d552015-07-16 08:34:3554
55 // content::NotificationObserver implementation:
56 void Observe(int type,
57 const content::NotificationSource& source,
58 const content::NotificationDetails& details) override;
59
blundell81308002015-08-18 15:06:0960 // Called when a URL is opened from the Omnibox.
61 void OnURLOpenedFromOmnibox(OmniboxLog* log);
62
sdefresned967d552015-07-16 08:34:3563 content::NotificationRegistrar registrar_;
Ayu Ishiiebdc85f2020-02-07 17:50:4364 base::OnceClosure on_omnibox_search_callback_;
65 base::OnceClosure on_homepage_search_callback_;
sdefresned967d552015-07-16 08:34:3566
blundell81308002015-08-18 15:06:0967 // Subscription for receiving callbacks that a URL was opened from the
68 // omnibox.
Peter Kasting7ba9440c2020-11-22 01:49:0269 base::CallbackListSubscription omnibox_url_opened_subscription_;
sdefresned967d552015-07-16 08:34:3570};
71
72#endif // CHROME_BROWSER_RLZ_CHROME_RLZ_TRACKER_DELEGATE_H_