blob: f8a097e3e39e1a574bb62cc5459c0a26cf813a84 [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();
27 ~ChromeRLZTrackerDelegate() override;
28
gab3ca4a492017-03-02 00:19:4129 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
30
sdefresned967d552015-07-16 08:34:3531 static bool IsGoogleDefaultSearch(Profile* profile);
32 static bool IsGoogleHomepage(Profile* profile);
33 static bool IsGoogleInStartpages(Profile* profile);
34
35 private:
36 // RLZTrackerDelegate implementation.
37 void Cleanup() override;
38 bool IsOnUIThread() override;
Antonio Gomesa739bf462018-08-13 20:50:3039 scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
sdefresned967d552015-07-16 08:34:3540 bool GetBrand(std::string* brand) override;
41 bool IsBrandOrganic(const std::string& brand) override;
42 bool GetReactivationBrand(std::string* brand) override;
43 bool ShouldEnableZeroDelayForTesting() override;
44 bool GetLanguage(base::string16* language) override;
45 bool GetReferral(base::string16* referral) override;
46 bool ClearReferral() override;
Ayu Ishiiebdc85f2020-02-07 17:50:4347 void SetOmniboxSearchCallback(base::OnceClosure callback) override;
48 void SetHomepageSearchCallback(base::OnceClosure callback) override;
Jérôme Lebel0d2a5a82018-12-06 10:13:3749 bool ShouldUpdateExistingAccessPointRlz() override;
sdefresned967d552015-07-16 08:34:3550
51 // content::NotificationObserver implementation:
52 void Observe(int type,
53 const content::NotificationSource& source,
54 const content::NotificationDetails& details) override;
55
blundell81308002015-08-18 15:06:0956 // Called when a URL is opened from the Omnibox.
57 void OnURLOpenedFromOmnibox(OmniboxLog* log);
58
sdefresned967d552015-07-16 08:34:3559 content::NotificationRegistrar registrar_;
Ayu Ishiiebdc85f2020-02-07 17:50:4360 base::OnceClosure on_omnibox_search_callback_;
61 base::OnceClosure on_homepage_search_callback_;
sdefresned967d552015-07-16 08:34:3562
blundell81308002015-08-18 15:06:0963 // Subscription for receiving callbacks that a URL was opened from the
64 // omnibox.
dcheng4af48582016-04-19 00:29:3565 std::unique_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription>
blundell81308002015-08-18 15:06:0966 omnibox_url_opened_subscription_;
67
sdefresned967d552015-07-16 08:34:3568 DISALLOW_COPY_AND_ASSIGN(ChromeRLZTrackerDelegate);
69};
70
71#endif // CHROME_BROWSER_RLZ_CHROME_RLZ_TRACKER_DELEGATE_H_