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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 virtual void OnLogMostVisitedNavigation(int position, | 70 virtual void OnLogMostVisitedNavigation(int position, |
71 const base::string16& provider) = 0; | 71 const base::string16& provider) = 0; |
72 | 72 |
73 // Called when the page wants to paste the |text| (or the clipboard contents | 73 // Called when the page wants to paste the |text| (or the clipboard contents |
74 // if the |text| is empty) into the omnibox. | 74 // if the |text| is empty) into the omnibox. |
75 virtual void PasteIntoOmnibox(const base::string16& text) = 0; | 75 virtual void PasteIntoOmnibox(const base::string16& text) = 0; |
76 | 76 |
77 // Called when the SearchBox wants to verify the signed-in Chrome identity | 77 // Called when the SearchBox wants to verify the signed-in Chrome identity |
78 // against the provided |identity|. Will make a round-trip to the browser | 78 // against the provided |identity|. Will make a round-trip to the browser |
79 // and eventually return the result through SendChromeIdentityCheckResult. | 79 // and eventually return the result through SendChromeIdentityCheckResult. |
80 // Calls SendChromeIdentityCheckResult with true if both the identity | 80 // Calls SendChromeIdentityCheckResult with true if the identity matches. |
81 // matches and the user syncs their history. | |
82 // TODO(beaudoin): Change this function name and related APIs now that it's | |
83 // checking both the identity and the user's sync state. | |
84 virtual void OnChromeIdentityCheck(const base::string16& identity) = 0; | 81 virtual void OnChromeIdentityCheck(const base::string16& identity) = 0; |
82 | |
83 // Called when the SearchBox wants to verify the signed-in Chrome identity | |
84 // against the provided |identity|. Will make a round-trip to the browser | |
85 // and eventually return the result through SendHistorySyncCheckResult. | |
86 // Calls SendHistorySyncCheckResult with true if the user syncs their | |
87 // history. | |
88 virtual void OnHistorySyncCheck() = 0; | |
85 }; | 89 }; |
86 | 90 |
87 // An interface to be implemented by consumers of SearchIPCRouter objects to | 91 // An interface to be implemented by consumers of SearchIPCRouter objects to |
88 // decide whether to process the message received from the page, and vice | 92 // decide whether to process the message received from the page, and vice |
89 // versa (decide whether to send messages to the page). | 93 // versa (decide whether to send messages to the page). |
90 class Policy { | 94 class Policy { |
91 public: | 95 public: |
92 virtual ~Policy() {} | 96 virtual ~Policy() {} |
93 | 97 |
94 // SearchIPCRouter calls these functions before sending/receiving messages | 98 // SearchIPCRouter calls these functions before sending/receiving messages |
95 // to/from the page. | 99 // to/from the page. |
96 virtual bool ShouldProcessSetVoiceSearchSupport() = 0; | 100 virtual bool ShouldProcessSetVoiceSearchSupport() = 0; |
97 virtual bool ShouldProcessFocusOmnibox(bool is_active_tab) = 0; | 101 virtual bool ShouldProcessFocusOmnibox(bool is_active_tab) = 0; |
98 virtual bool ShouldProcessNavigateToURL(bool is_active_tab) = 0; | 102 virtual bool ShouldProcessNavigateToURL(bool is_active_tab) = 0; |
99 virtual bool ShouldProcessDeleteMostVisitedItem() = 0; | 103 virtual bool ShouldProcessDeleteMostVisitedItem() = 0; |
100 virtual bool ShouldProcessUndoMostVisitedDeletion() = 0; | 104 virtual bool ShouldProcessUndoMostVisitedDeletion() = 0; |
101 virtual bool ShouldProcessUndoAllMostVisitedDeletions() = 0; | 105 virtual bool ShouldProcessUndoAllMostVisitedDeletions() = 0; |
102 virtual bool ShouldProcessLogEvent() = 0; | 106 virtual bool ShouldProcessLogEvent() = 0; |
103 virtual bool ShouldProcessPasteIntoOmnibox(bool is_active_tab) = 0; | 107 virtual bool ShouldProcessPasteIntoOmnibox(bool is_active_tab) = 0; |
104 virtual bool ShouldProcessChromeIdentityCheck() = 0; | 108 virtual bool ShouldProcessChromeIdentityCheck() = 0; |
109 virtual bool ShouldProcessHistorySyncCheck() = 0; | |
105 virtual bool ShouldSendSetPromoInformation() = 0; | 110 virtual bool ShouldSendSetPromoInformation() = 0; |
106 virtual bool ShouldSendSetDisplayInstantResults() = 0; | 111 virtual bool ShouldSendSetDisplayInstantResults() = 0; |
107 virtual bool ShouldSendSetSuggestionToPrefetch() = 0; | 112 virtual bool ShouldSendSetSuggestionToPrefetch() = 0; |
108 virtual bool ShouldSendSetOmniboxStartMargin() = 0; | 113 virtual bool ShouldSendSetOmniboxStartMargin() = 0; |
109 virtual bool ShouldSendSetInputInProgress(bool is_active_tab) = 0; | 114 virtual bool ShouldSendSetInputInProgress(bool is_active_tab) = 0; |
110 virtual bool ShouldSendOmniboxFocusChanged() = 0; | 115 virtual bool ShouldSendOmniboxFocusChanged() = 0; |
111 virtual bool ShouldSendMostVisitedItems() = 0; | 116 virtual bool ShouldSendMostVisitedItems() = 0; |
112 virtual bool ShouldSendThemeBackgroundInfo() = 0; | 117 virtual bool ShouldSendThemeBackgroundInfo() = 0; |
113 virtual bool ShouldSendToggleVoiceSearch() = 0; | 118 virtual bool ShouldSendToggleVoiceSearch() = 0; |
114 virtual bool ShouldSubmitQuery() = 0; | 119 virtual bool ShouldSubmitQuery() = 0; |
115 }; | 120 }; |
116 | 121 |
117 SearchIPCRouter(content::WebContents* web_contents, Delegate* delegate, | 122 SearchIPCRouter(content::WebContents* web_contents, Delegate* delegate, |
118 scoped_ptr<Policy> policy); | 123 scoped_ptr<Policy> policy); |
119 ~SearchIPCRouter() override; | 124 ~SearchIPCRouter() override; |
120 | 125 |
121 // Tells the SearchIPCRouter that a new page in an Instant process committed. | 126 // Tells the SearchIPCRouter that a new page in an Instant process committed. |
122 void OnNavigationEntryCommitted(); | 127 void OnNavigationEntryCommitted(); |
123 | 128 |
124 // Tells the renderer to determine if the page supports the Instant API, which | 129 // Tells the renderer to determine if the page supports the Instant API, which |
125 // results in a call to OnInstantSupportDetermined() when the reply is | 130 // results in a call to OnInstantSupportDetermined() when the reply is |
126 // received. | 131 // received. |
127 void DetermineIfPageSupportsInstant(); | 132 void DetermineIfPageSupportsInstant(); |
128 | 133 |
129 // Tells the renderer about the result of the Chrome identity check. | 134 // Tells the renderer about the result of the Chrome identity check. |
130 void SendChromeIdentityCheckResult(const base::string16& identity, | 135 void SendChromeIdentityCheckResult(const base::string16& identity, |
131 bool identity_match); | 136 bool identity_match); |
132 | 137 |
138 // Tells the renderer whether the user sync his history. | |
dcheng
2014/11/12 21:40:47
syncs
kmadhusu
2014/11/19 19:56:19
nit: Please avoid using "his/her" in the comment.
beaudoin
2014/11/20 22:58:26
Done.
beaudoin
2014/11/20 22:58:26
Done.
| |
139 void SendHistorySyncCheckResult(bool sync_history); | |
140 | |
133 // Tells the renderer information it needs to display promos. | 141 // Tells the renderer information it needs to display promos. |
134 void SetPromoInformation(bool is_app_launcher_enabled); | 142 void SetPromoInformation(bool is_app_launcher_enabled); |
135 | 143 |
136 // Tells the renderer whether to display the Instant results. | 144 // Tells the renderer whether to display the Instant results. |
137 void SetDisplayInstantResults(); | 145 void SetDisplayInstantResults(); |
138 | 146 |
139 // Tells the page the suggestion to be prefetched if any. | 147 // Tells the page the suggestion to be prefetched if any. |
140 void SetSuggestionToPrefetch(const InstantSuggestion& suggestion); | 148 void SetSuggestionToPrefetch(const InstantSuggestion& suggestion); |
141 | 149 |
142 // Tells the page the left margin of the omnibox. This is used by the page to | 150 // Tells the page the left margin of the omnibox. This is used by the page to |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 void OnLogMostVisitedImpression(int page_seq_no, | 209 void OnLogMostVisitedImpression(int page_seq_no, |
202 int position, | 210 int position, |
203 const base::string16& provider) const; | 211 const base::string16& provider) const; |
204 void OnLogMostVisitedNavigation(int page_seq_no, | 212 void OnLogMostVisitedNavigation(int page_seq_no, |
205 int position, | 213 int position, |
206 const base::string16& provider) const; | 214 const base::string16& provider) const; |
207 void OnPasteAndOpenDropDown(int page_seq_no, | 215 void OnPasteAndOpenDropDown(int page_seq_no, |
208 const base::string16& text) const; | 216 const base::string16& text) const; |
209 void OnChromeIdentityCheck(int page_seq_no, | 217 void OnChromeIdentityCheck(int page_seq_no, |
210 const base::string16& identity) const; | 218 const base::string16& identity) const; |
219 void OnHistorySyncCheck(int page_seq_no) const; | |
211 | 220 |
212 // Used by unit tests to set a fake delegate. | 221 // Used by unit tests to set a fake delegate. |
213 void set_delegate_for_testing(Delegate* delegate); | 222 void set_delegate_for_testing(Delegate* delegate); |
214 | 223 |
215 // Used by unit tests. | 224 // Used by unit tests. |
216 void set_policy_for_testing(scoped_ptr<Policy> policy); | 225 void set_policy_for_testing(scoped_ptr<Policy> policy); |
217 | 226 |
218 // Used by unit tests. | 227 // Used by unit tests. |
219 Policy* policy_for_testing() const { return policy_.get(); } | 228 Policy* policy_for_testing() const { return policy_.get(); } |
220 | 229 |
221 // Used by unit tests. | 230 // Used by unit tests. |
222 int page_seq_no_for_testing() const { return commit_counter_; } | 231 int page_seq_no_for_testing() const { return commit_counter_; } |
223 | 232 |
224 Delegate* delegate_; | 233 Delegate* delegate_; |
225 scoped_ptr<Policy> policy_; | 234 scoped_ptr<Policy> policy_; |
226 | 235 |
227 // Holds the number of main frame commits executed in this tab. Used by the | 236 // Holds the number of main frame commits executed in this tab. Used by the |
228 // SearchIPCRouter to ensure that delayed IPC replies are ignored. | 237 // SearchIPCRouter to ensure that delayed IPC replies are ignored. |
229 int commit_counter_; | 238 int commit_counter_; |
230 | 239 |
231 // Set to true, when the tab corresponding to |this| instance is active. | 240 // Set to true, when the tab corresponding to |this| instance is active. |
232 bool is_active_tab_; | 241 bool is_active_tab_; |
233 | 242 |
234 DISALLOW_COPY_AND_ASSIGN(SearchIPCRouter); | 243 DISALLOW_COPY_AND_ASSIGN(SearchIPCRouter); |
235 }; | 244 }; |
236 | 245 |
237 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ | 246 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ |
OLD | NEW |