OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SEARCH_SEARCH_TERMS_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_SEARCH_TERMS_TRACKER_H_ |
6 #define CHROME_BROWSER_SEARCH_SEARCH_TERMS_TRACKER_H_ | 6 #define CHROME_BROWSER_SEARCH_SEARCH_TERMS_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // search results page for the specified WebContents. This function will | 34 // search results page for the specified WebContents. This function will |
35 // return true if there are valid search terms for |contents|. |search_terms| | 35 // return true if there are valid search terms for |contents|. |search_terms| |
36 // and/or |navigation_index| can be NULL if not needed. | 36 // and/or |navigation_index| can be NULL if not needed. |
37 bool GetSearchTerms(const content::WebContents* contents, | 37 bool GetSearchTerms(const content::WebContents* contents, |
38 base::string16* search_terms, | 38 base::string16* search_terms, |
39 int* navigation_index) const; | 39 int* navigation_index) const; |
40 | 40 |
41 // content::NotificationObserver | 41 // content::NotificationObserver |
42 virtual void Observe(int type, | 42 virtual void Observe(int type, |
43 const content::NotificationSource& source, | 43 const content::NotificationSource& source, |
44 const content::NotificationDetails& details) OVERRIDE; | 44 const content::NotificationDetails& details) override; |
45 | 45 |
46 private: | 46 private: |
47 struct TabData { | 47 struct TabData { |
48 TabData() : srp_navigation_index(-1) {} | 48 TabData() : srp_navigation_index(-1) {} |
49 base::string16 search_terms; | 49 base::string16 search_terms; |
50 int srp_navigation_index; | 50 int srp_navigation_index; |
51 }; | 51 }; |
52 | 52 |
53 // Keeps information about the specified WebContents. | 53 // Keeps information about the specified WebContents. |
54 typedef std::map<const content::WebContents*, TabData> TabState; | 54 typedef std::map<const content::WebContents*, TabData> TabState; |
55 | 55 |
56 // Searches for the most recent search and, if found, fills |tab_data| with | 56 // Searches for the most recent search and, if found, fills |tab_data| with |
57 // information about that search and returns true. | 57 // information about that search and returns true. |
58 bool FindMostRecentSearch(const content::NavigationController* controller, | 58 bool FindMostRecentSearch(const content::NavigationController* controller, |
59 TabData* tab_data); | 59 TabData* tab_data); |
60 | 60 |
61 // Removes the TabData entry associated to the specified |contents|. | 61 // Removes the TabData entry associated to the specified |contents|. |
62 void RemoveTabData(const content::WebContents* contents); | 62 void RemoveTabData(const content::WebContents* contents); |
63 | 63 |
64 content::NotificationRegistrar registrar_; | 64 content::NotificationRegistrar registrar_; |
65 TabState tabs_; | 65 TabState tabs_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(SearchTermsTracker); | 67 DISALLOW_COPY_AND_ASSIGN(SearchTermsTracker); |
68 }; | 68 }; |
69 | 69 |
70 } // namespace chrome | 70 } // namespace chrome |
71 | 71 |
72 #endif // CHROME_BROWSER_SEARCH_SEARCH_TERMS_TRACKER_H_ | 72 #endif // CHROME_BROWSER_SEARCH_SEARCH_TERMS_TRACKER_H_ |
OLD | NEW |