sdefresne | d967d55 | 2015-07-16 08:34:35 | [diff] [blame] | 1 | // 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 | |
sdefresne | bd4c75c | 2015-07-22 09:06:18 | [diff] [blame] | 8 | #include "base/callback.h" |
sdefresne | d967d55 | 2015-07-16 08:34:35 | [diff] [blame] | 9 | #include "base/macros.h" |
blundell | 8130800 | 2015-08-18 15:06:09 | [diff] [blame^] | 10 | #include "components/omnibox/browser/omnibox_event_global_tracker.h" |
sdefresne | d967d55 | 2015-07-16 08:34:35 | [diff] [blame] | 11 | #include "components/rlz/rlz_tracker_delegate.h" |
| 12 | #include "content/public/browser/notification_observer.h" |
| 13 | #include "content/public/browser/notification_registrar.h" |
| 14 | |
| 15 | class Profile; |
| 16 | |
| 17 | // ChromeRLZTrackerDelegate implements RLZTrackerDelegate abstract interface |
| 18 | // and provides access to Chrome features. |
| 19 | class 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 | |
blundell | 8130800 | 2015-08-18 15:06:09 | [diff] [blame^] | 50 | // Called when a URL is opened from the Omnibox. |
| 51 | void OnURLOpenedFromOmnibox(OmniboxLog* log); |
| 52 | |
sdefresne | d967d55 | 2015-07-16 08:34:35 | [diff] [blame] | 53 | content::NotificationRegistrar registrar_; |
| 54 | base::Closure on_omnibox_search_callback_; |
| 55 | base::Closure on_homepage_search_callback_; |
| 56 | |
blundell | 8130800 | 2015-08-18 15:06:09 | [diff] [blame^] | 57 | // 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 | |
sdefresne | d967d55 | 2015-07-16 08:34:35 | [diff] [blame] | 62 | DISALLOW_COPY_AND_ASSIGN(ChromeRLZTrackerDelegate); |
| 63 | }; |
| 64 | |
| 65 | #endif // CHROME_BROWSER_RLZ_CHROME_RLZ_TRACKER_DELEGATE_H_ |