Chromium Code Reviews| Index: chrome/browser/ui/search/search_ipc_router.cc |
| diff --git a/chrome/browser/ui/search/search_ipc_router.cc b/chrome/browser/ui/search/search_ipc_router.cc |
| index 013e351bb919103fed6d4d04935a4b0705f24890..c6cf6029ea4b4dd62af4da3d8ff7d85dbace0b8a 100644 |
| --- a/chrome/browser/ui/search/search_ipc_router.cc |
| +++ b/chrome/browser/ui/search/search_ipc_router.cc |
| @@ -8,6 +8,22 @@ |
| #include "chrome/common/render_messages.h" |
| #include "content/public/browser/web_contents.h" |
| +namespace { |
| + |
| +bool IsProviderValid(const base::string16& provider) { |
| + // Only allow string of 8 alphanumeric characters or less as providers. |
|
beaudoin
2014/03/04 21:33:15
// The empty string is considered valid and should
huangs
2014/03/04 22:10:43
Done.
|
| + if (provider.length() > 8) |
| + return false; |
| + for (base::string16::const_iterator it = provider.begin(); |
| + it != provider.end(); ++it) { |
| + if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it)) |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| +} // namespace |
| + |
| SearchIPCRouter::SearchIPCRouter(content::WebContents* web_contents, |
| Delegate* delegate, scoped_ptr<Policy> policy) |
| : WebContentsObserver(web_contents), |
| @@ -142,6 +158,7 @@ bool SearchIPCRouter::OnMessageReceived(const IPC::Message& message) { |
| OnUndoAllMostVisitedDeletions); |
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogEvent, OnLogEvent); |
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogImpression, OnLogImpression); |
| + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogNavigation, OnLogNavigation); |
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PasteAndOpenDropdown, |
| OnPasteAndOpenDropDown); |
| IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ChromeIdentityCheck, |
| @@ -248,18 +265,9 @@ void SearchIPCRouter::OnLogEvent(int page_id, NTPLoggingEventType event) const { |
| void SearchIPCRouter::OnLogImpression(int page_id, |
| int position, |
| const base::string16& provider) const { |
| - if (!web_contents()->IsActiveEntry(page_id)) |
| + if (!web_contents()->IsActiveEntry(page_id) || !IsProviderValid(provider)) |
| return; |
| - // Only allow string of 8 alphanumeric characters or less as providers. |
| - if (provider.length() > 8) |
| - return; |
| - for (base::string16::const_iterator it = provider.begin(); |
| - it != provider.end(); ++it) { |
| - if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it)) |
| - return; |
| - } |
| - |
| delegate_->OnInstantSupportDetermined(true); |
| // Logging impressions is controlled by the same policy as logging events. |
| if (!policy_->ShouldProcessLogEvent()) |
| @@ -268,6 +276,20 @@ void SearchIPCRouter::OnLogImpression(int page_id, |
| delegate_->OnLogImpression(position, provider); |
| } |
| +void SearchIPCRouter::OnLogNavigation(int page_id, |
| + int position, |
| + const base::string16& provider) const { |
| + if (!web_contents()->IsActiveEntry(page_id) || !IsProviderValid(provider)) |
| + return; |
| + |
| + delegate_->OnInstantSupportDetermined(true); |
| + // Logging navigations is controlled by the same policy as logging events. |
| + if (!policy_->ShouldProcessLogEvent()) |
| + return; |
| + |
| + delegate_->OnLogNavigation(position, provider); |
| +} |
| + |
| void SearchIPCRouter::OnPasteAndOpenDropDown(int page_id, |
| const base::string16& text) const { |
| if (!web_contents()->IsActiveEntry(page_id)) |