[M120][Tizen][Onscreen] Fix build errors for TV profile
[platform/framework/web/chromium-efl.git] / chrome / browser / font_prewarmer_tab_helper.h
1 // Copyright 2021 The Chromium Authors
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_FONT_PREWARMER_TAB_HELPER_H_
6 #define CHROME_BROWSER_FONT_PREWARMER_TAB_HELPER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "content/public/browser/web_contents_observer.h"
12 #include "content/public/browser/web_contents_user_data.h"
13
14 class Profile;
15
16 namespace user_prefs {
17 class PrefRegistrySyncable;
18 }
19
20 // FontPrewarmerTabHelper is responsible for tracking navigations to the search
21 // results page of the default search engine and prewarming the fonts that were
22 // previously used the last time a search results page of the default search
23 // engine was visited.
24 class FontPrewarmerTabHelper
25     : public content::WebContentsObserver,
26       public content::WebContentsUserData<FontPrewarmerTabHelper> {
27  public:
28   FontPrewarmerTabHelper(const FontPrewarmerTabHelper&) = delete;
29   FontPrewarmerTabHelper& operator=(const FontPrewarmerTabHelper&) = delete;
30   ~FontPrewarmerTabHelper() override;
31
32   static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
33
34  private:
35   friend class content::WebContentsUserData<FontPrewarmerTabHelper>;
36   friend class FontPrewarmerTabHelperTest;
37
38   explicit FontPrewarmerTabHelper(content::WebContents* web_contents);
39
40   // Testing helpers:
41   static std::string GetSearchResultsPagePrimaryFontsPref();
42   static std::vector<std::string> GetPrimaryFontNames(Profile* profile);
43
44   Profile* GetProfile();
45
46   // Returns true if the url of `navigation_handle` is a search results page of
47   // the default search provider.
48   bool IsSearchResultsPageNavigation(
49       content::NavigationHandle* navigation_handle);
50
51   // content::WebContentsObserver implementation.
52   void DidStartNavigation(
53       content::NavigationHandle* navigation_handle) override;
54   void ReadyToCommitNavigation(
55       content::NavigationHandle* navigation_handle) override;
56
57   absl::optional<int> expected_render_process_host_id_;
58
59   WEB_CONTENTS_USER_DATA_KEY_DECL();
60 };
61
62 #endif  // CHROME_BROWSER_FONT_PREWARMER_TAB_HELPER_H_