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 3 // found in the LICENSE file. 4 5 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" 6 7 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/search/search.h" 9 #include "content/public/browser/web_contents.h" 10 SearchIPCRouterPolicyImpl(const content::WebContents * web_contents)11SearchIPCRouterPolicyImpl::SearchIPCRouterPolicyImpl( 12 const content::WebContents* web_contents) 13 : web_contents_(web_contents), 14 is_incognito_(true) { 15 DCHECK(web_contents); 16 17 Profile* profile = 18 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); 19 if (profile) 20 is_incognito_ = profile->IsOffTheRecord(); 21 } 22 ~SearchIPCRouterPolicyImpl()23SearchIPCRouterPolicyImpl::~SearchIPCRouterPolicyImpl() {} 24 ShouldProcessSetVoiceSearchSupport()25bool SearchIPCRouterPolicyImpl::ShouldProcessSetVoiceSearchSupport() { 26 return true; 27 } 28 ShouldProcessFocusOmnibox(bool is_active_tab)29bool SearchIPCRouterPolicyImpl::ShouldProcessFocusOmnibox(bool is_active_tab) { 30 return is_active_tab && !is_incognito_ && chrome::IsInstantNTP(web_contents_); 31 } 32 ShouldProcessNavigateToURL(bool is_active_tab)33bool SearchIPCRouterPolicyImpl::ShouldProcessNavigateToURL(bool is_active_tab) { 34 return is_active_tab && !is_incognito_ && chrome::IsInstantNTP(web_contents_); 35 } 36 ShouldProcessDeleteMostVisitedItem()37bool SearchIPCRouterPolicyImpl::ShouldProcessDeleteMostVisitedItem() { 38 return !is_incognito_ && chrome::IsInstantNTP(web_contents_); 39 } 40 ShouldProcessUndoMostVisitedDeletion()41bool SearchIPCRouterPolicyImpl::ShouldProcessUndoMostVisitedDeletion() { 42 return !is_incognito_ && chrome::IsInstantNTP(web_contents_); 43 } 44 ShouldProcessUndoAllMostVisitedDeletions()45bool SearchIPCRouterPolicyImpl::ShouldProcessUndoAllMostVisitedDeletions() { 46 return !is_incognito_ && chrome::IsInstantNTP(web_contents_); 47 } 48 ShouldProcessLogEvent()49bool SearchIPCRouterPolicyImpl::ShouldProcessLogEvent() { 50 return !is_incognito_ && chrome::IsInstantNTP(web_contents_); 51 } 52 ShouldProcessPasteIntoOmnibox(bool is_active_tab)53bool SearchIPCRouterPolicyImpl::ShouldProcessPasteIntoOmnibox( 54 bool is_active_tab) { 55 return is_active_tab && !is_incognito_ && chrome::IsInstantNTP(web_contents_); 56 } 57 ShouldProcessChromeIdentityCheck()58bool SearchIPCRouterPolicyImpl::ShouldProcessChromeIdentityCheck() { 59 return !is_incognito_ && chrome::IsInstantNTP(web_contents_); 60 } 61 ShouldSendSetPromoInformation()62bool SearchIPCRouterPolicyImpl::ShouldSendSetPromoInformation() { 63 return !is_incognito_ && chrome::IsInstantNTP(web_contents_); 64 } 65 ShouldSendSetDisplayInstantResults()66bool SearchIPCRouterPolicyImpl::ShouldSendSetDisplayInstantResults() { 67 return !is_incognito_; 68 } 69 ShouldSendSetSuggestionToPrefetch()70bool SearchIPCRouterPolicyImpl::ShouldSendSetSuggestionToPrefetch() { 71 return !is_incognito_; 72 } 73 ShouldSendSetOmniboxStartMargin()74bool SearchIPCRouterPolicyImpl::ShouldSendSetOmniboxStartMargin() { 75 return true; 76 } 77 ShouldSendSetInputInProgress(bool is_active_tab)78bool SearchIPCRouterPolicyImpl::ShouldSendSetInputInProgress( 79 bool is_active_tab) { 80 return is_active_tab && !is_incognito_; 81 } 82 ShouldSendOmniboxFocusChanged()83bool SearchIPCRouterPolicyImpl::ShouldSendOmniboxFocusChanged() { 84 return !is_incognito_; 85 } 86 ShouldSendMostVisitedItems()87bool SearchIPCRouterPolicyImpl::ShouldSendMostVisitedItems() { 88 return !is_incognito_ && chrome::IsInstantNTP(web_contents_); 89 } 90 ShouldSendThemeBackgroundInfo()91bool SearchIPCRouterPolicyImpl::ShouldSendThemeBackgroundInfo() { 92 return !is_incognito_ && chrome::IsInstantNTP(web_contents_); 93 } 94 ShouldSendToggleVoiceSearch()95bool SearchIPCRouterPolicyImpl::ShouldSendToggleVoiceSearch() { 96 return true; 97 } 98 ShouldSubmitQuery()99bool SearchIPCRouterPolicyImpl::ShouldSubmitQuery() { 100 return true; 101 } 102