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

Unified Diff: chrome/browser/ui/search/search_ipc_router.cc

Issue 178253008: Redoing Issue 36073011: Allowing file:/// in Instant Extended's Most Visited links. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused consts. Created 6 years, 9 months 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 side-by-side diff with in-line comments
Download patch
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..09b1a72b1fc942cd7e65df60ee8087502b430791 100644
--- a/chrome/browser/ui/search/search_ipc_router.cc
+++ b/chrome/browser/ui/search/search_ipc_router.cc
@@ -8,6 +8,24 @@
#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.
+ // The empty string is considered valid and should be treated as if no
+ // provider were specified.
+ 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),
@@ -141,7 +159,10 @@ bool SearchIPCRouter::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions,
OnUndoAllMostVisitedDeletions);
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogEvent, OnLogEvent);
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogImpression, OnLogImpression);
+ IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogMostVisitedImpression,
+ OnLogMostVisitedImpression);
+ IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogMostVisitedNavigation,
+ OnLogMostVisitedNavigation);
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PasteAndOpenDropdown,
OnPasteAndOpenDropDown);
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ChromeIdentityCheck,
@@ -245,27 +266,30 @@ void SearchIPCRouter::OnLogEvent(int page_id, NTPLoggingEventType event) const {
delegate_->OnLogEvent(event);
}
-void SearchIPCRouter::OnLogImpression(int page_id,
- int position,
- const base::string16& provider) const {
- if (!web_contents()->IsActiveEntry(page_id))
+void SearchIPCRouter::OnLogMostVisitedImpression(
+ int page_id, int position, const base::string16& provider) const {
+ if (!web_contents()->IsActiveEntry(page_id) || !IsProviderValid(provider))
return;
- // Only allow string of 8 alphanumeric characters or less as providers.
- if (provider.length() > 8)
+ delegate_->OnInstantSupportDetermined(true);
+ // Logging impressions is controlled by the same policy as logging events.
+ if (!policy_->ShouldProcessLogEvent())
+ return;
+
+ delegate_->OnLogMostVisitedImpression(position, provider);
+}
+
+void SearchIPCRouter::OnLogMostVisitedNavigation(
+ int page_id, int position, const base::string16& provider) const {
+ if (!web_contents()->IsActiveEntry(page_id) || !IsProviderValid(provider))
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.
+ // Logging navigations is controlled by the same policy as logging events.
if (!policy_->ShouldProcessLogEvent())
return;
- delegate_->OnLogImpression(position, provider);
+ delegate_->OnLogMostVisitedNavigation(position, provider);
}
void SearchIPCRouter::OnPasteAndOpenDropDown(int page_id,

Powered by Google App Engine
This is Rietveld 408576698