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_RENDERER_SEARCHBOX_SEARCH_BOUNCER_H_ | 5 #ifndef CHROME_RENDERER_SEARCHBOX_SEARCH_BOUNCER_H_ |
6 #define CHROME_RENDERER_SEARCHBOX_SEARCH_BOUNCER_H_ | 6 #define CHROME_RENDERER_SEARCHBOX_SEARCH_BOUNCER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "content/public/renderer/render_process_observer.h" | 12 #include "content/public/renderer/render_process_observer.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace IPC { | 15 namespace IPC { |
16 class Message; | 16 class Message; |
17 } | 17 } |
18 | 18 |
19 // SearchBouncer tracks a set of URLs which should be transferred back to the | 19 // SearchBouncer tracks a set of URLs which should be transferred back to the |
20 // browser process for potential reassignment to an Instant renderer process. | 20 // browser process for potential reassignment to an Instant renderer process. |
21 class SearchBouncer : public content::RenderProcessObserver { | 21 class SearchBouncer : public content::RenderProcessObserver { |
22 public: | 22 public: |
23 SearchBouncer(); | 23 SearchBouncer(); |
24 ~SearchBouncer() override; | 24 ~SearchBouncer() override; |
25 | 25 |
26 static SearchBouncer* GetInstance(); | 26 static SearchBouncer* GetInstance(); |
27 | 27 |
28 // Returns whether a navigation to |url| should bounce back to the browser as | 28 // Returns whether a navigation to |url| should bounce back to the browser as |
29 // a potential Instant url. See chrome::ShouldAssignURLToInstantRenderer(). | 29 // a potential Instant url. See search::ShouldAssignURLToInstantRenderer(). |
30 bool ShouldFork(const GURL& url) const; | 30 bool ShouldFork(const GURL& url) const; |
31 | 31 |
32 // Returns whether |url| is a valid Instant new tab page URL. | 32 // Returns whether |url| is a valid Instant new tab page URL. |
33 bool IsNewTabPage(const GURL& url) const; | 33 bool IsNewTabPage(const GURL& url) const; |
34 | 34 |
35 // Exposed for testing. | 35 // Exposed for testing. |
36 void OnSetSearchURLs(std::vector<GURL> search_urls, GURL new_tab_page_url); | 36 void OnSetSearchURLs(std::vector<GURL> search_urls, GURL new_tab_page_url); |
37 | 37 |
38 private: | 38 private: |
39 FRIEND_TEST_ALL_PREFIXES(SearchBouncerTest, SetSearchURLs); | 39 FRIEND_TEST_ALL_PREFIXES(SearchBouncerTest, SetSearchURLs); |
40 | 40 |
41 // From RenderProcessObserver: | 41 // From RenderProcessObserver: |
42 bool OnControlMessageReceived(const IPC::Message& message) override; | 42 bool OnControlMessageReceived(const IPC::Message& message) override; |
43 | 43 |
44 // URLs to bounce back to the browser. | 44 // URLs to bounce back to the browser. |
45 std::vector<GURL> search_urls_; | 45 std::vector<GURL> search_urls_; |
46 GURL new_tab_page_url_; | 46 GURL new_tab_page_url_; |
47 | 47 |
48 DISALLOW_COPY_AND_ASSIGN(SearchBouncer); | 48 DISALLOW_COPY_AND_ASSIGN(SearchBouncer); |
49 }; | 49 }; |
50 | 50 |
51 #endif // CHROME_RENDERER_SEARCHBOX_SEARCH_BOUNCER_H_ | 51 #endif // CHROME_RENDERER_SEARCHBOX_SEARCH_BOUNCER_H_ |
OLD | NEW |