| OLD | NEW |
| 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 #include "chrome/browser/ui/search/search_ipc_router.h" | 5 #include "chrome/browser/ui/search/search_ipc_router.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/instant_service.h" | 10 #include "chrome/browser/search/instant_service.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 | 176 |
| 177 void SearchIPCRouter::OnTabDeactivated() { | 177 void SearchIPCRouter::OnTabDeactivated() { |
| 178 is_active_tab_ = false; | 178 is_active_tab_ = false; |
| 179 } | 179 } |
| 180 | 180 |
| 181 void SearchIPCRouter::FocusOmnibox(int page_seq_no, OmniboxFocusState state) { | 181 void SearchIPCRouter::FocusOmnibox(int page_seq_no, OmniboxFocusState state) { |
| 182 if (page_seq_no != commit_counter_) | 182 if (page_seq_no != commit_counter_) |
| 183 return; | 183 return; |
| 184 | 184 |
| 185 delegate_->OnInstantSupportDetermined(true); | |
| 186 if (!policy_->ShouldProcessFocusOmnibox(is_active_tab_)) | 185 if (!policy_->ShouldProcessFocusOmnibox(is_active_tab_)) |
| 187 return; | 186 return; |
| 188 | 187 |
| 189 delegate_->FocusOmnibox(state); | 188 delegate_->FocusOmnibox(state); |
| 190 } | 189 } |
| 191 | 190 |
| 192 void SearchIPCRouter::DeleteMostVisitedItem(int page_seq_no, const GURL& url) { | 191 void SearchIPCRouter::DeleteMostVisitedItem(int page_seq_no, const GURL& url) { |
| 193 if (page_seq_no != commit_counter_) | 192 if (page_seq_no != commit_counter_) |
| 194 return; | 193 return; |
| 195 | 194 |
| 196 delegate_->OnInstantSupportDetermined(true); | |
| 197 if (!policy_->ShouldProcessDeleteMostVisitedItem()) | 195 if (!policy_->ShouldProcessDeleteMostVisitedItem()) |
| 198 return; | 196 return; |
| 199 | 197 |
| 200 delegate_->OnDeleteMostVisitedItem(url); | 198 delegate_->OnDeleteMostVisitedItem(url); |
| 201 } | 199 } |
| 202 | 200 |
| 203 void SearchIPCRouter::UndoMostVisitedDeletion(int page_seq_no, | 201 void SearchIPCRouter::UndoMostVisitedDeletion(int page_seq_no, |
| 204 const GURL& url) { | 202 const GURL& url) { |
| 205 if (page_seq_no != commit_counter_) | 203 if (page_seq_no != commit_counter_) |
| 206 return; | 204 return; |
| 207 | 205 |
| 208 delegate_->OnInstantSupportDetermined(true); | |
| 209 if (!policy_->ShouldProcessUndoMostVisitedDeletion()) | 206 if (!policy_->ShouldProcessUndoMostVisitedDeletion()) |
| 210 return; | 207 return; |
| 211 | 208 |
| 212 delegate_->OnUndoMostVisitedDeletion(url); | 209 delegate_->OnUndoMostVisitedDeletion(url); |
| 213 } | 210 } |
| 214 | 211 |
| 215 void SearchIPCRouter::UndoAllMostVisitedDeletions(int page_seq_no) { | 212 void SearchIPCRouter::UndoAllMostVisitedDeletions(int page_seq_no) { |
| 216 if (page_seq_no != commit_counter_) | 213 if (page_seq_no != commit_counter_) |
| 217 return; | 214 return; |
| 218 | 215 |
| 219 delegate_->OnInstantSupportDetermined(true); | |
| 220 if (!policy_->ShouldProcessUndoAllMostVisitedDeletions()) | 216 if (!policy_->ShouldProcessUndoAllMostVisitedDeletions()) |
| 221 return; | 217 return; |
| 222 | 218 |
| 223 delegate_->OnUndoAllMostVisitedDeletions(); | 219 delegate_->OnUndoAllMostVisitedDeletions(); |
| 224 } | 220 } |
| 225 | 221 |
| 226 void SearchIPCRouter::LogEvent(int page_seq_no, | 222 void SearchIPCRouter::LogEvent(int page_seq_no, |
| 227 NTPLoggingEventType event, | 223 NTPLoggingEventType event, |
| 228 base::TimeDelta time) { | 224 base::TimeDelta time) { |
| 229 if (page_seq_no != commit_counter_) | 225 if (page_seq_no != commit_counter_) |
| 230 return; | 226 return; |
| 231 | 227 |
| 232 delegate_->OnInstantSupportDetermined(true); | |
| 233 if (!policy_->ShouldProcessLogEvent()) | 228 if (!policy_->ShouldProcessLogEvent()) |
| 234 return; | 229 return; |
| 235 | 230 |
| 236 delegate_->OnLogEvent(event, time); | 231 delegate_->OnLogEvent(event, time); |
| 237 } | 232 } |
| 238 | 233 |
| 239 void SearchIPCRouter::LogMostVisitedImpression( | 234 void SearchIPCRouter::LogMostVisitedImpression( |
| 240 int page_seq_no, | 235 int page_seq_no, |
| 241 int position, | 236 int position, |
| 242 ntp_tiles::TileSource tile_source, | 237 ntp_tiles::TileSource tile_source, |
| 243 ntp_tiles::TileVisualType tile_type) { | 238 ntp_tiles::TileVisualType tile_type) { |
| 244 if (page_seq_no != commit_counter_) | 239 if (page_seq_no != commit_counter_) |
| 245 return; | 240 return; |
| 246 | 241 |
| 247 delegate_->OnInstantSupportDetermined(true); | |
| 248 // Logging impressions is controlled by the same policy as logging events. | 242 // Logging impressions is controlled by the same policy as logging events. |
| 249 if (!policy_->ShouldProcessLogEvent()) | 243 if (!policy_->ShouldProcessLogEvent()) |
| 250 return; | 244 return; |
| 251 | 245 |
| 252 delegate_->OnLogMostVisitedImpression(position, tile_source, tile_type); | 246 delegate_->OnLogMostVisitedImpression(position, tile_source, tile_type); |
| 253 } | 247 } |
| 254 | 248 |
| 255 void SearchIPCRouter::LogMostVisitedNavigation( | 249 void SearchIPCRouter::LogMostVisitedNavigation( |
| 256 int page_seq_no, | 250 int page_seq_no, |
| 257 int position, | 251 int position, |
| 258 ntp_tiles::TileSource tile_source, | 252 ntp_tiles::TileSource tile_source, |
| 259 ntp_tiles::TileVisualType tile_type) { | 253 ntp_tiles::TileVisualType tile_type) { |
| 260 if (page_seq_no != commit_counter_) | 254 if (page_seq_no != commit_counter_) |
| 261 return; | 255 return; |
| 262 | 256 |
| 263 delegate_->OnInstantSupportDetermined(true); | |
| 264 // Logging navigations is controlled by the same policy as logging events. | 257 // Logging navigations is controlled by the same policy as logging events. |
| 265 if (!policy_->ShouldProcessLogEvent()) | 258 if (!policy_->ShouldProcessLogEvent()) |
| 266 return; | 259 return; |
| 267 | 260 |
| 268 delegate_->OnLogMostVisitedNavigation(position, tile_source, tile_type); | 261 delegate_->OnLogMostVisitedNavigation(position, tile_source, tile_type); |
| 269 } | 262 } |
| 270 | 263 |
| 271 void SearchIPCRouter::PasteAndOpenDropdown(int page_seq_no, | 264 void SearchIPCRouter::PasteAndOpenDropdown(int page_seq_no, |
| 272 const base::string16& text) { | 265 const base::string16& text) { |
| 273 if (page_seq_no != commit_counter_) | 266 if (page_seq_no != commit_counter_) |
| 274 return; | 267 return; |
| 275 | 268 |
| 276 delegate_->OnInstantSupportDetermined(true); | |
| 277 if (!policy_->ShouldProcessPasteIntoOmnibox(is_active_tab_)) | 269 if (!policy_->ShouldProcessPasteIntoOmnibox(is_active_tab_)) |
| 278 return; | 270 return; |
| 279 | 271 |
| 280 delegate_->PasteIntoOmnibox(text); | 272 delegate_->PasteIntoOmnibox(text); |
| 281 } | 273 } |
| 282 | 274 |
| 283 void SearchIPCRouter::ChromeIdentityCheck(int page_seq_no, | 275 void SearchIPCRouter::ChromeIdentityCheck(int page_seq_no, |
| 284 const base::string16& identity) { | 276 const base::string16& identity) { |
| 285 if (page_seq_no != commit_counter_) | 277 if (page_seq_no != commit_counter_) |
| 286 return; | 278 return; |
| 287 | 279 |
| 288 delegate_->OnInstantSupportDetermined(true); | |
| 289 if (!policy_->ShouldProcessChromeIdentityCheck()) | 280 if (!policy_->ShouldProcessChromeIdentityCheck()) |
| 290 return; | 281 return; |
| 291 | 282 |
| 292 delegate_->OnChromeIdentityCheck(identity); | 283 delegate_->OnChromeIdentityCheck(identity); |
| 293 } | 284 } |
| 294 | 285 |
| 295 void SearchIPCRouter::HistorySyncCheck(int page_seq_no) { | 286 void SearchIPCRouter::HistorySyncCheck(int page_seq_no) { |
| 296 if (page_seq_no != commit_counter_) | 287 if (page_seq_no != commit_counter_) |
| 297 return; | 288 return; |
| 298 | 289 |
| 299 delegate_->OnInstantSupportDetermined(true); | |
| 300 if (!policy_->ShouldProcessHistorySyncCheck()) | 290 if (!policy_->ShouldProcessHistorySyncCheck()) |
| 301 return; | 291 return; |
| 302 | 292 |
| 303 delegate_->OnHistorySyncCheck(); | 293 delegate_->OnHistorySyncCheck(); |
| 304 } | 294 } |
| 305 | 295 |
| 306 void SearchIPCRouter::set_delegate_for_testing(Delegate* delegate) { | 296 void SearchIPCRouter::set_delegate_for_testing(Delegate* delegate) { |
| 307 DCHECK(delegate); | 297 DCHECK(delegate); |
| 308 delegate_ = delegate; | 298 delegate_ = delegate; |
| 309 } | 299 } |
| 310 | 300 |
| 311 void SearchIPCRouter::set_policy_for_testing(std::unique_ptr<Policy> policy) { | 301 void SearchIPCRouter::set_policy_for_testing(std::unique_ptr<Policy> policy) { |
| 312 DCHECK(policy); | 302 DCHECK(policy); |
| 313 policy_ = std::move(policy); | 303 policy_ = std::move(policy); |
| 314 } | 304 } |
| OLD | NEW |