| 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 <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 312 |
| 313 if (!load_details.is_main_frame) | 313 if (!load_details.is_main_frame) |
| 314 return; | 314 return; |
| 315 | 315 |
| 316 UpdateMode(true); | 316 UpdateMode(true); |
| 317 | 317 |
| 318 content::NavigationEntry* entry = | 318 content::NavigationEntry* entry = |
| 319 web_contents_->GetController().GetVisibleEntry(); | 319 web_contents_->GetController().GetVisibleEntry(); |
| 320 DCHECK(entry); | 320 DCHECK(entry); |
| 321 | 321 |
| 322 // Already determined the instant support state for this page, do not reset | |
| 323 // the instant support state. | |
| 324 if (load_details.is_in_page) { | |
| 325 // When an "in-page" navigation happens, we will not receive a | |
| 326 // DidFinishLoad() event. Therefore, we will not determine the Instant | |
| 327 // support for the navigated page. So, copy over the Instant support from | |
| 328 // the previous entry. If the page does not support Instant, update the | |
| 329 // location bar from here to turn off search terms replacement. | |
| 330 if (delegate_ && model_.instant_support() == INSTANT_SUPPORT_NO) | |
| 331 delegate_->OnWebContentsInstantSupportDisabled(web_contents_); | |
| 332 return; | |
| 333 } | |
| 334 | |
| 335 model_.SetInstantSupportState(INSTANT_SUPPORT_UNKNOWN); | 322 model_.SetInstantSupportState(INSTANT_SUPPORT_UNKNOWN); |
| 336 | 323 |
| 337 if (InInstantProcess(profile(), web_contents_)) | 324 if (InInstantProcess(profile(), web_contents_)) |
| 338 ipc_router_.OnNavigationEntryCommitted(); | 325 ipc_router_.OnNavigationEntryCommitted(); |
| 339 } | 326 } |
| 340 | 327 |
| 341 void SearchTabHelper::OnInstantSupportDetermined(bool supports_instant) { | 328 void SearchTabHelper::OnInstantSupportDetermined(bool supports_instant) { |
| 342 InstantSupportChanged(supports_instant); | 329 InstantSupportChanged(supports_instant); |
| 343 } | 330 } |
| 344 | 331 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 } | 468 } |
| 482 | 469 |
| 483 void SearchTabHelper::InstantSupportChanged(bool instant_support) { | 470 void SearchTabHelper::InstantSupportChanged(bool instant_support) { |
| 484 if (!is_search_enabled_) | 471 if (!is_search_enabled_) |
| 485 return; | 472 return; |
| 486 | 473 |
| 487 InstantSupportState new_state = instant_support ? INSTANT_SUPPORT_YES : | 474 InstantSupportState new_state = instant_support ? INSTANT_SUPPORT_YES : |
| 488 INSTANT_SUPPORT_NO; | 475 INSTANT_SUPPORT_NO; |
| 489 | 476 |
| 490 model_.SetInstantSupportState(new_state); | 477 model_.SetInstantSupportState(new_state); |
| 491 | |
| 492 if (web_contents_->GetController().GetLastCommittedEntry() && delegate_ && | |
| 493 !instant_support) { | |
| 494 delegate_->OnWebContentsInstantSupportDisabled(web_contents_); | |
| 495 } | |
| 496 } | 478 } |
| 497 | 479 |
| 498 void SearchTabHelper::UpdateMode(bool update_origin) { | 480 void SearchTabHelper::UpdateMode(bool update_origin) { |
| 499 SearchMode::Type type = SearchMode::MODE_DEFAULT; | 481 SearchMode::Type type = SearchMode::MODE_DEFAULT; |
| 500 SearchMode::Origin origin = SearchMode::ORIGIN_DEFAULT; | 482 SearchMode::Origin origin = SearchMode::ORIGIN_DEFAULT; |
| 501 if (IsNTP(web_contents_)) { | 483 if (IsNTP(web_contents_)) { |
| 502 type = SearchMode::MODE_NTP; | 484 type = SearchMode::MODE_NTP; |
| 503 origin = SearchMode::ORIGIN_NTP; | 485 origin = SearchMode::ORIGIN_NTP; |
| 504 } | 486 } |
| 505 if (!update_origin) | 487 if (!update_origin) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 | 519 |
| 538 bool SearchTabHelper::IsInputInProgress() const { | 520 bool SearchTabHelper::IsInputInProgress() const { |
| 539 OmniboxView* omnibox = GetOmniboxView(); | 521 OmniboxView* omnibox = GetOmniboxView(); |
| 540 return !model_.mode().is_ntp() && omnibox && | 522 return !model_.mode().is_ntp() && omnibox && |
| 541 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 523 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
| 542 } | 524 } |
| 543 | 525 |
| 544 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 526 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
| 545 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 527 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
| 546 } | 528 } |
| OLD | NEW |