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(content::WebContents * web_contents)11SearchIPCRouterPolicyImpl::SearchIPCRouterPolicyImpl( 12 content::WebContents* web_contents) 13 : web_contents_(web_contents), is_incognito_(true) { 14 DCHECK(web_contents); 15 16 Profile* profile = 17 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); 18 if (profile) 19 is_incognito_ = profile->IsOffTheRecord(); 20 } 21 ~SearchIPCRouterPolicyImpl()22SearchIPCRouterPolicyImpl::~SearchIPCRouterPolicyImpl() {} 23 ShouldProcessFocusOmnibox(bool is_active_tab)24bool SearchIPCRouterPolicyImpl::ShouldProcessFocusOmnibox(bool is_active_tab) { 25 return is_active_tab && !is_incognito_ && search::IsInstantNTP(web_contents_); 26 } 27 ShouldProcessDeleteMostVisitedItem()28bool SearchIPCRouterPolicyImpl::ShouldProcessDeleteMostVisitedItem() { 29 return !is_incognito_ && search::IsInstantNTP(web_contents_); 30 } 31 ShouldProcessUndoMostVisitedDeletion()32bool SearchIPCRouterPolicyImpl::ShouldProcessUndoMostVisitedDeletion() { 33 return !is_incognito_ && search::IsInstantNTP(web_contents_); 34 } 35 ShouldProcessUndoAllMostVisitedDeletions()36bool SearchIPCRouterPolicyImpl::ShouldProcessUndoAllMostVisitedDeletions() { 37 return !is_incognito_ && search::IsInstantNTP(web_contents_); 38 } 39 ShouldProcessAddCustomLink()40bool SearchIPCRouterPolicyImpl::ShouldProcessAddCustomLink() { 41 return !is_incognito_ && search::IsInstantNTP(web_contents_); 42 } 43 ShouldProcessUpdateCustomLink()44bool SearchIPCRouterPolicyImpl::ShouldProcessUpdateCustomLink() { 45 return !is_incognito_ && search::IsInstantNTP(web_contents_); 46 } 47 ShouldProcessReorderCustomLink()48bool SearchIPCRouterPolicyImpl::ShouldProcessReorderCustomLink() { 49 return !is_incognito_ && search::IsInstantNTP(web_contents_); 50 } 51 ShouldProcessDeleteCustomLink()52bool SearchIPCRouterPolicyImpl::ShouldProcessDeleteCustomLink() { 53 return !is_incognito_ && search::IsInstantNTP(web_contents_); 54 } 55 ShouldProcessUndoCustomLinkAction()56bool SearchIPCRouterPolicyImpl::ShouldProcessUndoCustomLinkAction() { 57 return !is_incognito_ && search::IsInstantNTP(web_contents_); 58 } 59 ShouldProcessResetCustomLinks()60bool SearchIPCRouterPolicyImpl::ShouldProcessResetCustomLinks() { 61 return !is_incognito_ && search::IsInstantNTP(web_contents_); 62 } 63 ShouldProcessToggleMostVisitedOrCustomLinks()64bool SearchIPCRouterPolicyImpl::ShouldProcessToggleMostVisitedOrCustomLinks() { 65 return !is_incognito_ && search::IsInstantNTP(web_contents_); 66 } 67 ShouldProcessToggleShortcutsVisibility()68bool SearchIPCRouterPolicyImpl::ShouldProcessToggleShortcutsVisibility() { 69 return !is_incognito_ && search::IsInstantNTP(web_contents_); 70 } 71 ShouldProcessLogEvent()72bool SearchIPCRouterPolicyImpl::ShouldProcessLogEvent() { 73 return !is_incognito_ && search::IsInstantNTP(web_contents_); 74 } 75 ShouldProcessLogSuggestionEventWithValue()76bool SearchIPCRouterPolicyImpl::ShouldProcessLogSuggestionEventWithValue() { 77 return !is_incognito_ && search::IsInstantNTP(web_contents_); 78 } 79 ShouldProcessPasteIntoOmnibox(bool is_active_tab)80bool SearchIPCRouterPolicyImpl::ShouldProcessPasteIntoOmnibox( 81 bool is_active_tab) { 82 return is_active_tab && !is_incognito_ && search::IsInstantNTP(web_contents_); 83 } 84 ShouldSendSetInputInProgress(bool is_active_tab)85bool SearchIPCRouterPolicyImpl::ShouldSendSetInputInProgress( 86 bool is_active_tab) { 87 return is_active_tab && !is_incognito_; 88 } 89 ShouldSendOmniboxFocusChanged()90bool SearchIPCRouterPolicyImpl::ShouldSendOmniboxFocusChanged() { 91 return !is_incognito_; 92 } 93 ShouldSendMostVisitedInfo()94bool SearchIPCRouterPolicyImpl::ShouldSendMostVisitedInfo() { 95 return !is_incognito_ && search::IsInstantNTP(web_contents_); 96 } 97 ShouldSendNtpTheme()98bool SearchIPCRouterPolicyImpl::ShouldSendNtpTheme() { 99 return !is_incognito_ && search::IsInstantNTP(web_contents_); 100 } 101 ShouldSendLocalBackgroundSelected()102bool SearchIPCRouterPolicyImpl::ShouldSendLocalBackgroundSelected() { 103 return !is_incognito_ && search::IsInstantNTP(web_contents_); 104 } 105 ShouldProcessSelectLocalBackgroundImage()106bool SearchIPCRouterPolicyImpl::ShouldProcessSelectLocalBackgroundImage() { 107 return !is_incognito_ && search::IsInstantNTP(web_contents_); 108 } 109 ShouldProcessSetCustomBackgroundInfo()110bool SearchIPCRouterPolicyImpl::ShouldProcessSetCustomBackgroundInfo() { 111 return !is_incognito_ && search::IsInstantNTP(web_contents_); 112 } 113 ShouldProcessBlocklistSearchSuggestion()114bool SearchIPCRouterPolicyImpl::ShouldProcessBlocklistSearchSuggestion() { 115 return !is_incognito_ && search::IsInstantNTP(web_contents_); 116 } 117 118 bool SearchIPCRouterPolicyImpl:: ShouldProcessBlocklistSearchSuggestionWithHash()119 ShouldProcessBlocklistSearchSuggestionWithHash() { 120 return !is_incognito_ && search::IsInstantNTP(web_contents_); 121 } 122 ShouldProcessSearchSuggestionSelected()123bool SearchIPCRouterPolicyImpl::ShouldProcessSearchSuggestionSelected() { 124 return !is_incognito_ && search::IsInstantNTP(web_contents_); 125 } 126 ShouldProcessOptOutOfSearchSuggestions()127bool SearchIPCRouterPolicyImpl::ShouldProcessOptOutOfSearchSuggestions() { 128 return !is_incognito_ && search::IsInstantNTP(web_contents_); 129 } 130 ShouldProcessThemeChangeMessages()131bool SearchIPCRouterPolicyImpl::ShouldProcessThemeChangeMessages() { 132 return !is_incognito_ && search::IsInstantNTP(web_contents_); 133 } 134 ShouldProcessAutocompleteResultChanged(bool is_active_tab)135bool SearchIPCRouterPolicyImpl::ShouldProcessAutocompleteResultChanged( 136 bool is_active_tab) { 137 return is_active_tab && !is_incognito_ && search::IsInstantNTP(web_contents_); 138 } 139 ShouldProcessAutocompleteMatchImageAvailable(bool is_active_tab)140bool SearchIPCRouterPolicyImpl::ShouldProcessAutocompleteMatchImageAvailable( 141 bool is_active_tab) { 142 return is_active_tab && !is_incognito_ && search::IsInstantNTP(web_contents_); 143 } 144 ShouldProcessQueryAutocomplete(bool is_active_tab)145bool SearchIPCRouterPolicyImpl::ShouldProcessQueryAutocomplete( 146 bool is_active_tab) { 147 return is_active_tab && !is_incognito_ && search::IsInstantNTP(web_contents_); 148 } 149 ShouldProcessStopAutocomplete()150bool SearchIPCRouterPolicyImpl::ShouldProcessStopAutocomplete() { 151 return !is_incognito_ && search::IsInstantNTP(web_contents_); 152 } 153 ShouldProcessLogCharTypedToRepaintLatency()154bool SearchIPCRouterPolicyImpl::ShouldProcessLogCharTypedToRepaintLatency() { 155 return !is_incognito_ && search::IsInstantNTP(web_contents_); 156 } 157 ShouldProcessBlocklistPromo()158bool SearchIPCRouterPolicyImpl::ShouldProcessBlocklistPromo() { 159 return !is_incognito_ && search::IsInstantNTP(web_contents_); 160 } 161 ShouldProcessOpenExtensionsPage()162bool SearchIPCRouterPolicyImpl::ShouldProcessOpenExtensionsPage() { 163 return !is_incognito_ && search::IsInstantNTP(web_contents_); 164 } 165 ShouldProcessOpenAutocompleteMatch(bool is_active_tab)166bool SearchIPCRouterPolicyImpl::ShouldProcessOpenAutocompleteMatch( 167 bool is_active_tab) { 168 return is_active_tab && !is_incognito_ && search::IsInstantNTP(web_contents_); 169 } 170 ShouldProcessDeleteAutocompleteMatch()171bool SearchIPCRouterPolicyImpl::ShouldProcessDeleteAutocompleteMatch() { 172 return !is_incognito_ && search::IsInstantNTP(web_contents_); 173 } 174 175 bool SearchIPCRouterPolicyImpl:: ShouldProcessToggleSuggestionGroupIdVisibility()176 ShouldProcessToggleSuggestionGroupIdVisibility() { 177 return !is_incognito_ && search::IsInstantNTP(web_contents_); 178 } 179