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_SEARCH_IPC_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ |
6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ | 6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 // decide whether to process the message received from the page, and vice | 38 // decide whether to process the message received from the page, and vice |
39 // versa (decide whether to send messages to the page). | 39 // versa (decide whether to send messages to the page). |
40 class Policy { | 40 class Policy { |
41 public: | 41 public: |
42 virtual ~Policy() {} | 42 virtual ~Policy() {} |
43 | 43 |
44 // SearchIPCRouter calls these functions before sending/receiving messages | 44 // SearchIPCRouter calls these functions before sending/receiving messages |
45 // to/from the page. | 45 // to/from the page. |
46 virtual bool ShouldProcessSetVoiceSearchSupport() = 0; | 46 virtual bool ShouldProcessSetVoiceSearchSupport() = 0; |
47 virtual bool ShouldSendSetDisplayInstantResults() = 0; | 47 virtual bool ShouldSendSetDisplayInstantResults() = 0; |
| 48 virtual bool ShouldSendSetSuggestionToPrefetch() = 0; |
48 virtual bool ShouldSendMostVisitedItems() = 0; | 49 virtual bool ShouldSendMostVisitedItems() = 0; |
49 virtual bool ShouldSendThemeBackgroundInfo() = 0; | 50 virtual bool ShouldSendThemeBackgroundInfo() = 0; |
50 }; | 51 }; |
51 | 52 |
52 SearchIPCRouter(content::WebContents* web_contents, Delegate* delegate, | 53 SearchIPCRouter(content::WebContents* web_contents, Delegate* delegate, |
53 scoped_ptr<Policy> policy); | 54 scoped_ptr<Policy> policy); |
54 virtual ~SearchIPCRouter(); | 55 virtual ~SearchIPCRouter(); |
55 | 56 |
56 // Tells the renderer to determine if the page supports the Instant API, which | 57 // Tells the renderer to determine if the page supports the Instant API, which |
57 // results in a call to OnInstantSupportDetermined() when the reply is | 58 // results in a call to OnInstantSupportDetermined() when the reply is |
58 // received. | 59 // received. |
59 void DetermineIfPageSupportsInstant(); | 60 void DetermineIfPageSupportsInstant(); |
60 | 61 |
61 // Tells the renderer whether to display the Instant results. | 62 // Tells the renderer whether to display the Instant results. |
62 void SetDisplayInstantResults(); | 63 void SetDisplayInstantResults(); |
63 | 64 |
64 // Tells the renderer about the most visited items. | 65 // Tells the renderer about the most visited items. |
65 void SendMostVisitedItems(const std::vector<InstantMostVisitedItem>& items); | 66 void SendMostVisitedItems(const std::vector<InstantMostVisitedItem>& items); |
66 | 67 |
67 // Tells the renderer about the current theme background. | 68 // Tells the renderer about the current theme background. |
68 void SendThemeBackgroundInfo(const ThemeBackgroundInfo& theme_info); | 69 void SendThemeBackgroundInfo(const ThemeBackgroundInfo& theme_info); |
69 | 70 |
| 71 // Tells the page the suggestion to be prefetched if any. |
| 72 void SetSuggestionToPrefetch(const InstantSuggestion& suggestion); |
| 73 |
70 private: | 74 private: |
71 friend class SearchIPCRouterTest; | 75 friend class SearchIPCRouterTest; |
72 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 76 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
73 DetermineIfPageSupportsInstant_Local); | 77 DetermineIfPageSupportsInstant_Local); |
74 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 78 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
75 DetermineIfPageSupportsInstant_NonLocal); | 79 DetermineIfPageSupportsInstant_NonLocal); |
76 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 80 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
77 PageURLDoesntBelongToInstantRenderer); | 81 PageURLDoesntBelongToInstantRenderer); |
78 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, | 82 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, |
79 ProcessVoiceSearchSupportMsg); | 83 ProcessVoiceSearchSupportMsg); |
80 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, | 84 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, |
81 SendSetDisplayInstantResults); | 85 SendSetDisplayInstantResults); |
82 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, | 86 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, |
83 DoNotSetDisplayInstantResultsForIncognitoPage); | 87 SendSetSuggestionToPrefetch); |
| 88 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, |
| 89 DoNotSendSetMessagesForIncognitoPage); |
84 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, SendMostVisitedItems); | 90 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, SendMostVisitedItems); |
85 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, | 91 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, |
86 DoNotSendMostVisitedItems); | 92 DoNotSendMostVisitedItems); |
87 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, | 93 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, |
88 DoNotSendMostVisitedItemsForIncognitoPage); | 94 DoNotSendMostVisitedItemsForIncognitoPage); |
89 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, SendThemeBackgroundInfo); | 95 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, SendThemeBackgroundInfo); |
90 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, | 96 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, |
91 DoNotSendThemeBackgroundInfo); | 97 DoNotSendThemeBackgroundInfo); |
92 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, | 98 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterPolicyTest, |
93 DoNotSendThemeBackgroundInfoForIncognitoPage); | 99 DoNotSendThemeBackgroundInfoForIncognitoPage); |
(...skipping 19 matching lines...) Expand all Loading... |
113 // Used by unit tests. | 119 // Used by unit tests. |
114 Policy* policy() const { return policy_.get(); } | 120 Policy* policy() const { return policy_.get(); } |
115 | 121 |
116 Delegate* delegate_; | 122 Delegate* delegate_; |
117 scoped_ptr<Policy> policy_; | 123 scoped_ptr<Policy> policy_; |
118 | 124 |
119 DISALLOW_COPY_AND_ASSIGN(SearchIPCRouter); | 125 DISALLOW_COPY_AND_ASSIGN(SearchIPCRouter); |
120 }; | 126 }; |
121 | 127 |
122 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ | 128 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ |
OLD | NEW |