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_UI_SEARCH_INSTANT_SEARCH_PRERENDERER_H_ | 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_SEARCH_PRERENDERER_H_ |
6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_SEARCH_PRERENDERER_H_ | 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_SEARCH_PRERENDERER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 const content::SessionStorageNamespaceMap& session_storage_namespace_map, | 53 const content::SessionStorageNamespaceMap& session_storage_namespace_map, |
54 const gfx::Size& size); | 54 const gfx::Size& size); |
55 | 55 |
56 // Cancels the current request. | 56 // Cancels the current request. |
57 void Cancel(); | 57 void Cancel(); |
58 | 58 |
59 // Tells the Instant search base page to prerender |suggestion|. | 59 // Tells the Instant search base page to prerender |suggestion|. |
60 void Prerender(const InstantSuggestion& suggestion); | 60 void Prerender(const InstantSuggestion& suggestion); |
61 | 61 |
62 // Tells the Instant search base page to render the prefetched search results. | 62 // Tells the Instant search base page to render the prefetched search results. |
63 void Commit(const string16& query); | 63 void Commit(const base::string16& query); |
64 | 64 |
65 // Returns true if the prerendered page can be used to process the search for | 65 // Returns true if the prerendered page can be used to process the search for |
66 // the given |source|. | 66 // the given |source|. |
67 bool CanCommitQuery(content::WebContents* source, | 67 bool CanCommitQuery(content::WebContents* source, |
68 const string16& query) const; | 68 const base::string16& query) const; |
69 | 69 |
70 // Returns true and updates |params->target_contents| if a prerendered page | 70 // Returns true and updates |params->target_contents| if a prerendered page |
71 // exists for |url| and is swapped in. | 71 // exists for |url| and is swapped in. |
72 bool UsePrerenderedPage(const GURL& url, chrome::NavigateParams* params); | 72 bool UsePrerenderedPage(const GURL& url, chrome::NavigateParams* params); |
73 | 73 |
74 // Returns the last prefetched search query. | 74 // Returns the last prefetched search query. |
75 const string16& get_last_query() const { | 75 const base::string16& get_last_query() const { |
76 return last_instant_suggestion_.text; | 76 return last_instant_suggestion_.text; |
77 } | 77 } |
78 | 78 |
79 // Returns true when prerendering is allowed for the given |source| and | 79 // Returns true when prerendering is allowed for the given |source| and |
80 // |match|. | 80 // |match|. |
81 bool IsAllowed(const AutocompleteMatch& match, | 81 bool IsAllowed(const AutocompleteMatch& match, |
82 content::WebContents* source) const; | 82 content::WebContents* source) const; |
83 | 83 |
84 private: | 84 private: |
85 friend class InstantSearchPrerendererTest; | 85 friend class InstantSearchPrerendererTest; |
86 | 86 |
87 content::WebContents* prerender_contents() const; | 87 content::WebContents* prerender_contents() const; |
88 | 88 |
89 Profile* const profile_; | 89 Profile* const profile_; |
90 | 90 |
91 // Instant search base page URL. | 91 // Instant search base page URL. |
92 const GURL prerender_url_; | 92 const GURL prerender_url_; |
93 | 93 |
94 scoped_ptr<prerender::PrerenderHandle> prerender_handle_; | 94 scoped_ptr<prerender::PrerenderHandle> prerender_handle_; |
95 | 95 |
96 InstantSuggestion last_instant_suggestion_; | 96 InstantSuggestion last_instant_suggestion_; |
97 | 97 |
98 DISALLOW_COPY_AND_ASSIGN(InstantSearchPrerenderer); | 98 DISALLOW_COPY_AND_ASSIGN(InstantSearchPrerenderer); |
99 }; | 99 }; |
100 | 100 |
101 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_SEARCH_PRERENDERER_H_ | 101 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_SEARCH_PRERENDERER_H_ |
OLD | NEW |