rlz_tracker_delegate.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #ifndef COMPONENTS_RLZ_RLZ_TRACKER_DELEGATE_H_
  5. #define COMPONENTS_RLZ_RLZ_TRACKER_DELEGATE_H_
  6. #include <string>
  7. #include "base/callback_forward.h"
  8. namespace network {
  9. class SharedURLLoaderFactory;
  10. } // namespace network
  11. namespace rlz {
  12. // RLZTrackerDelegate is an abstract interface that provides access to embedder
  13. // specific singletons or gives information about the embedder environment.
  14. class RLZTrackerDelegate {
  15. public:
  16. RLZTrackerDelegate() {}
  17. RLZTrackerDelegate(const RLZTrackerDelegate&) = delete;
  18. RLZTrackerDelegate& operator=(const RLZTrackerDelegate&) = delete;
  19. virtual ~RLZTrackerDelegate() {}
  20. // Invoked during RLZTracker cleanup, to request the cleanup of the delegate.
  21. virtual void Cleanup() = 0;
  22. // Returns whether the current thread is the UI thread.
  23. virtual bool IsOnUIThread() = 0;
  24. // Returns the SharedURLLoaderFactory to use for network connections.
  25. virtual scoped_refptr<network::SharedURLLoaderFactory>
  26. GetURLLoaderFactory() = 0;
  27. // Returns the brand code for the installation of Chrome in |brand| and a
  28. // boolean indicating whether the operation was a success or not.
  29. virtual bool GetBrand(std::string* brand) = 0;
  30. // Returns whether |brand| is an organic brand.
  31. virtual bool IsBrandOrganic(const std::string& brand) = 0;
  32. // Returns the reactivation brand code for Chrome in |brand| and a boolean
  33. // indicating whether the operation was a success or not.
  34. virtual bool GetReactivationBrand(std::string* brand) = 0;
  35. // Returns true if RLZTracker should ignore initial delay for testing.
  36. virtual bool ShouldEnableZeroDelayForTesting() = 0;
  37. // Returns the installation language in |language| and a boolean indicating
  38. // whether the operation was a success or not.
  39. virtual bool GetLanguage(std::u16string* language) = 0;
  40. // Returns the referral code in |referral| and a boolean indicating whether
  41. // the operation was a success or not. Deprecated.
  42. virtual bool GetReferral(std::u16string* referral) = 0;
  43. // Clears the referral code. Deprecated.
  44. virtual bool ClearReferral() = 0;
  45. // Registers |callback| to be invoked the next time the user perform a search
  46. // using Google search engine via the omnibox. Callback will invoked at most
  47. // once.
  48. virtual void SetOmniboxSearchCallback(base::OnceClosure callback) = 0;
  49. // Registers |callback| to be invoked the next time the user perform a search
  50. // using Google search engine via the homepage. Callback will invoked at most
  51. // once.
  52. virtual void SetHomepageSearchCallback(base::OnceClosure callback) = 0;
  53. // Returns true if the existing access point RLZ strings in the data file
  54. // should be updated.
  55. virtual bool ShouldUpdateExistingAccessPointRlz() = 0;
  56. };
  57. } // namespace rlz
  58. #endif // COMPONENTS_RLZ_RLZ_TRACKER_DELEGATE_H_