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