Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: chrome/browser/search/search_terms_tracker.h

Issue 2814513002: Cleanup: Remove unused SearchTermsTracker (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/search/search_terms_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SEARCH_SEARCH_TERMS_TRACKER_H_
6 #define CHROME_BROWSER_SEARCH_SEARCH_TERMS_TRACKER_H_
7
8 #include <map>
9
10 #include "base/macros.h"
11 #include "base/strings/string16.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14
15 namespace content {
16 class NavigationController;
17 class WebContents;
18 }
19
20 namespace chrome {
21
22 // Observes navigation events (and WebContents destructions) to keep track of
23 // search terms associated with a WebContents. Essentially, as long as there are
24 // only web-triggerable navigations following a search results page, this class
25 // will consider the search terms from that SRP as the "current" search terms.
26 // Any other type of navigation will invalidate the search terms. The search
27 // terms are being tracked so they can be displayed in the location bar for
28 // related navigations that occur after a search.
29 class SearchTermsTracker : public content::NotificationObserver {
30 public:
31 SearchTermsTracker();
32 ~SearchTermsTracker() override;
33
34 // Returns the current search terms and navigation index of the corresponding
35 // search results page for the specified WebContents. This function will
36 // return true if there are valid search terms for |contents|. |search_terms|
37 // and/or |navigation_index| can be NULL if not needed.
38 bool GetSearchTerms(const content::WebContents* contents,
39 base::string16* search_terms,
40 int* navigation_index) const;
41
42 // content::NotificationObserver
43 void Observe(int type,
44 const content::NotificationSource& source,
45 const content::NotificationDetails& details) override;
46
47 private:
48 struct TabData {
49 TabData() : srp_navigation_index(-1) {}
50 base::string16 search_terms;
51 int srp_navigation_index;
52 };
53
54 // Keeps information about the specified WebContents.
55 typedef std::map<const content::WebContents*, TabData> TabState;
56
57 // Searches for the most recent search and, if found, fills |tab_data| with
58 // information about that search and returns true.
59 bool FindMostRecentSearch(const content::NavigationController* controller,
60 TabData* tab_data);
61
62 // Removes the TabData entry associated to the specified |contents|.
63 void RemoveTabData(const content::WebContents* contents);
64
65 content::NotificationRegistrar registrar_;
66 TabState tabs_;
67
68 DISALLOW_COPY_AND_ASSIGN(SearchTermsTracker);
69 };
70
71 } // namespace chrome
72
73 #endif // CHROME_BROWSER_SEARCH_SEARCH_TERMS_TRACKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/search/search_terms_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698