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

Side by Side Diff: chrome/browser/ui/search/search_ipc_router.h

Issue 701973002: Separate checking the user identity and checking if the user is syncing his history in two differen… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Answered kmadhusu and dcheng Created 6 years, 1 month 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
OLDNEW
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
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 syncs history.
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void OnLogMostVisitedImpression(int page_seq_no, 210 void OnLogMostVisitedImpression(int page_seq_no,
203 int position, 211 int position,
204 const base::string16& provider) const; 212 const base::string16& provider) const;
205 void OnLogMostVisitedNavigation(int page_seq_no, 213 void OnLogMostVisitedNavigation(int page_seq_no,
206 int position, 214 int position,
207 const base::string16& provider) const; 215 const base::string16& provider) const;
208 void OnPasteAndOpenDropDown(int page_seq_no, 216 void OnPasteAndOpenDropDown(int page_seq_no,
209 const base::string16& text) const; 217 const base::string16& text) const;
210 void OnChromeIdentityCheck(int page_seq_no, 218 void OnChromeIdentityCheck(int page_seq_no,
211 const base::string16& identity) const; 219 const base::string16& identity) const;
220 void OnHistorySyncCheck(int page_seq_no) const;
212 221
213 // Used by unit tests to set a fake delegate. 222 // Used by unit tests to set a fake delegate.
214 void set_delegate_for_testing(Delegate* delegate); 223 void set_delegate_for_testing(Delegate* delegate);
215 224
216 // Used by unit tests. 225 // Used by unit tests.
217 void set_policy_for_testing(scoped_ptr<Policy> policy); 226 void set_policy_for_testing(scoped_ptr<Policy> policy);
218 227
219 // Used by unit tests. 228 // Used by unit tests.
220 Policy* policy_for_testing() const { return policy_.get(); } 229 Policy* policy_for_testing() const { return policy_.get(); }
221 230
222 // Used by unit tests. 231 // Used by unit tests.
223 int page_seq_no_for_testing() const { return commit_counter_; } 232 int page_seq_no_for_testing() const { return commit_counter_; }
224 233
225 Delegate* delegate_; 234 Delegate* delegate_;
226 scoped_ptr<Policy> policy_; 235 scoped_ptr<Policy> policy_;
227 236
228 // Holds the number of main frame commits executed in this tab. Used by the 237 // Holds the number of main frame commits executed in this tab. Used by the
229 // SearchIPCRouter to ensure that delayed IPC replies are ignored. 238 // SearchIPCRouter to ensure that delayed IPC replies are ignored.
230 int commit_counter_; 239 int commit_counter_;
231 240
232 // Set to true, when the tab corresponding to |this| instance is active. 241 // Set to true, when the tab corresponding to |this| instance is active.
233 bool is_active_tab_; 242 bool is_active_tab_;
234 243
235 DISALLOW_COPY_AND_ASSIGN(SearchIPCRouter); 244 DISALLOW_COPY_AND_ASSIGN(SearchIPCRouter);
236 }; 245 };
237 246
238 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ 247 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698