blob: 0e48175f0c5ec6e880cc0114ab410790db9f414a [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
17// ChromeRLZTrackerDelegate implements RLZTrackerDelegate abstract interface
18// and provides access to Chrome features.
19class ChromeRLZTrackerDelegate : public rlz::RLZTrackerDelegate,
20 public content::NotificationObserver {
21 public:
22 ChromeRLZTrackerDelegate();
23 ~ChromeRLZTrackerDelegate() override;
24
25 static bool IsGoogleDefaultSearch(Profile* profile);
26 static bool IsGoogleHomepage(Profile* profile);
27 static bool IsGoogleInStartpages(Profile* profile);
28
29 private:
30 // RLZTrackerDelegate implementation.
31 void Cleanup() override;
32 bool IsOnUIThread() override;
33 base::SequencedWorkerPool* GetBlockingPool() override;
34 net::URLRequestContextGetter* GetRequestContext() override;
35 bool GetBrand(std::string* brand) override;
36 bool IsBrandOrganic(const std::string& brand) override;
37 bool GetReactivationBrand(std::string* brand) override;
38 bool ShouldEnableZeroDelayForTesting() override;
39 bool GetLanguage(base::string16* language) override;
40 bool GetReferral(base::string16* referral) override;
41 bool ClearReferral() override;
42 void SetOmniboxSearchCallback(const base::Closure& callback) override;
43 void SetHomepageSearchCallback(const base::Closure& callback) override;
44
45 // content::NotificationObserver implementation:
46 void Observe(int type,
47 const content::NotificationSource& source,
48 const content::NotificationDetails& details) override;
49
blundell81308002015-08-18 15:06:0950 // Called when a URL is opened from the Omnibox.
51 void OnURLOpenedFromOmnibox(OmniboxLog* log);
52
sdefresned967d552015-07-16 08:34:3553 content::NotificationRegistrar registrar_;
54 base::Closure on_omnibox_search_callback_;
55 base::Closure on_homepage_search_callback_;
56
blundell81308002015-08-18 15:06:0957 // Subscription for receiving callbacks that a URL was opened from the
58 // omnibox.
59 scoped_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription>
60 omnibox_url_opened_subscription_;
61
sdefresned967d552015-07-16 08:34:3562 DISALLOW_COPY_AND_ASSIGN(ChromeRLZTrackerDelegate);
63};
64
65#endif // CHROME_BROWSER_RLZ_CHROME_RLZ_TRACKER_DELEGATE_H_