| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 333 |
| 334 void SearchTabHelper::NavigationEntryCommitted( | 334 void SearchTabHelper::NavigationEntryCommitted( |
| 335 const content::LoadCommittedDetails& load_details) { | 335 const content::LoadCommittedDetails& load_details) { |
| 336 if (!is_search_enabled_) | 336 if (!is_search_enabled_) |
| 337 return; | 337 return; |
| 338 | 338 |
| 339 if (!load_details.is_main_frame) | 339 if (!load_details.is_main_frame) |
| 340 return; | 340 return; |
| 341 | 341 |
| 342 if (search::ShouldAssignURLToInstantRenderer(web_contents_->GetURL(), | 342 if (search::ShouldAssignURLToInstantRenderer(web_contents_->GetURL(), |
| 343 profile())) { | 343 profile())) |
| 344 InstantService* instant_service = | |
| 345 InstantServiceFactory::GetForProfile(profile()); | |
| 346 ipc_router_.SetOmniboxStartMargin(instant_service->omnibox_start_margin()); | |
| 347 ipc_router_.SetDisplayInstantResults(); | 344 ipc_router_.SetDisplayInstantResults(); |
| 348 } | |
| 349 | 345 |
| 350 UpdateMode(true, false); | 346 UpdateMode(true, false); |
| 351 | 347 |
| 352 content::NavigationEntry* entry = | 348 content::NavigationEntry* entry = |
| 353 web_contents_->GetController().GetVisibleEntry(); | 349 web_contents_->GetController().GetVisibleEntry(); |
| 354 DCHECK(entry); | 350 DCHECK(entry); |
| 355 | 351 |
| 356 // Already determined the instant support state for this page, do not reset | 352 // Already determined the instant support state for this page, do not reset |
| 357 // the instant support state. | 353 // the instant support state. |
| 358 if (load_details.is_in_page) { | 354 if (load_details.is_in_page) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 event = NTP_CLIENT_SIDE_SUGGESTION; | 399 event = NTP_CLIENT_SIDE_SUGGESTION; |
| 404 } | 400 } |
| 405 // The metrics are emitted for each suggestion as the design requirement | 401 // The metrics are emitted for each suggestion as the design requirement |
| 406 // even the ntp_user_data_logger.cc now only supports the scenario: | 402 // even the ntp_user_data_logger.cc now only supports the scenario: |
| 407 // all suggestions are provided by server OR | 403 // all suggestions are provided by server OR |
| 408 // all suggestions are provided by client. | 404 // all suggestions are provided by client. |
| 409 this->OnLogEvent(event, base::TimeDelta()); | 405 this->OnLogEvent(event, base::TimeDelta()); |
| 410 } | 406 } |
| 411 } | 407 } |
| 412 | 408 |
| 413 void SearchTabHelper::OmniboxStartMarginChanged(int omnibox_start_margin) { | |
| 414 ipc_router_.SetOmniboxStartMargin(omnibox_start_margin); | |
| 415 } | |
| 416 | |
| 417 void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) { | 409 void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) { |
| 418 // TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef. | 410 // TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef. |
| 419 #if !defined(OS_ANDROID) | 411 #if !defined(OS_ANDROID) |
| 420 OmniboxView* omnibox = GetOmniboxView(); | 412 OmniboxView* omnibox = GetOmniboxView(); |
| 421 if (!omnibox) | 413 if (!omnibox) |
| 422 return; | 414 return; |
| 423 | 415 |
| 424 // Do not add a default case in the switch block for the following reasons: | 416 // Do not add a default case in the switch block for the following reasons: |
| 425 // (1) Explicitly handle the new states. If new states are added in the | 417 // (1) Explicitly handle the new states. If new states are added in the |
| 426 // OmniboxFocusState, the compiler will warn the developer to handle the new | 418 // OmniboxFocusState, the compiler will warn the developer to handle the new |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 590 |
| 599 bool SearchTabHelper::IsInputInProgress() const { | 591 bool SearchTabHelper::IsInputInProgress() const { |
| 600 OmniboxView* omnibox = GetOmniboxView(); | 592 OmniboxView* omnibox = GetOmniboxView(); |
| 601 return !model_.mode().is_ntp() && omnibox && | 593 return !model_.mode().is_ntp() && omnibox && |
| 602 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 594 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
| 603 } | 595 } |
| 604 | 596 |
| 605 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 597 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
| 606 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 598 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
| 607 } | 599 } |
| OLD | NEW |