| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 web_contents_->UpdateTitleForEntry( | 279 web_contents_->UpdateTitleForEntry( |
| 280 entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); | 280 entry, l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 void SearchTabHelper::DidFinishLoad(content::RenderFrameHost* render_frame_host, | 284 void SearchTabHelper::DidFinishLoad(content::RenderFrameHost* render_frame_host, |
| 285 const GURL& /* validated_url */) { | 285 const GURL& /* validated_url */) { |
| 286 if (!render_frame_host->GetParent()) { | 286 if (!render_frame_host->GetParent()) { |
| 287 if (search::IsInstantNTP(web_contents_)) | 287 if (search::IsInstantNTP(web_contents_)) |
| 288 RecordNewTabLoadTime(web_contents_); | 288 RecordNewTabLoadTime(web_contents_); |
| 289 | |
| 290 InstantSupportChanged(InInstantProcess(profile(), web_contents_)); | |
| 291 } | 289 } |
| 292 } | 290 } |
| 293 | 291 |
| 294 void SearchTabHelper::NavigationEntryCommitted( | 292 void SearchTabHelper::NavigationEntryCommitted( |
| 295 const content::LoadCommittedDetails& load_details) { | 293 const content::LoadCommittedDetails& load_details) { |
| 296 if (!is_search_enabled_) | 294 if (!is_search_enabled_) |
| 297 return; | 295 return; |
| 298 | 296 |
| 299 if (!load_details.is_main_frame) | 297 if (!load_details.is_main_frame) |
| 300 return; | 298 return; |
| 301 | 299 |
| 302 UpdateMode(/*update_origin=*/true); | 300 UpdateMode(/*update_origin=*/true); |
| 303 | 301 |
| 304 InstantSupportChanged(InInstantProcess(profile(), web_contents_)); | |
| 305 | |
| 306 if (InInstantProcess(profile(), web_contents_)) | 302 if (InInstantProcess(profile(), web_contents_)) |
| 307 ipc_router_.OnNavigationEntryCommitted(); | 303 ipc_router_.OnNavigationEntryCommitted(); |
| 308 } | 304 } |
| 309 | 305 |
| 310 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { | 306 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { |
| 311 ipc_router_.SendThemeBackgroundInfo(theme_info); | 307 ipc_router_.SendThemeBackgroundInfo(theme_info); |
| 312 } | 308 } |
| 313 | 309 |
| 314 void SearchTabHelper::MostVisitedItemsChanged( | 310 void SearchTabHelper::MostVisitedItemsChanged( |
| 315 const std::vector<InstantMostVisitedItem>& items) { | 311 const std::vector<InstantMostVisitedItem>& items) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 manager->GetAuthenticatedAccountInfo().email)); | 437 manager->GetAuthenticatedAccountInfo().email)); |
| 442 } else { | 438 } else { |
| 443 ipc_router_.SendChromeIdentityCheckResult(identity, false); | 439 ipc_router_.SendChromeIdentityCheckResult(identity, false); |
| 444 } | 440 } |
| 445 } | 441 } |
| 446 | 442 |
| 447 void SearchTabHelper::OnHistorySyncCheck() { | 443 void SearchTabHelper::OnHistorySyncCheck() { |
| 448 ipc_router_.SendHistorySyncCheckResult(IsHistorySyncEnabled(profile())); | 444 ipc_router_.SendHistorySyncCheckResult(IsHistorySyncEnabled(profile())); |
| 449 } | 445 } |
| 450 | 446 |
| 451 void SearchTabHelper::InstantSupportChanged(bool instant_support) { | |
| 452 if (!is_search_enabled_) | |
| 453 return; | |
| 454 | |
| 455 InstantSupportState new_state = instant_support ? INSTANT_SUPPORT_YES : | |
| 456 INSTANT_SUPPORT_NO; | |
| 457 | |
| 458 model_.SetInstantSupportState(new_state); | |
| 459 } | |
| 460 | |
| 461 void SearchTabHelper::UpdateMode(bool update_origin) { | 447 void SearchTabHelper::UpdateMode(bool update_origin) { |
| 462 SearchMode::Type type = SearchMode::MODE_DEFAULT; | 448 SearchMode::Type type = SearchMode::MODE_DEFAULT; |
| 463 SearchMode::Origin origin = SearchMode::ORIGIN_DEFAULT; | 449 SearchMode::Origin origin = SearchMode::ORIGIN_DEFAULT; |
| 464 if (IsNTP(web_contents_)) { | 450 if (IsNTP(web_contents_)) { |
| 465 type = SearchMode::MODE_NTP; | 451 type = SearchMode::MODE_NTP; |
| 466 origin = SearchMode::ORIGIN_NTP; | 452 origin = SearchMode::ORIGIN_NTP; |
| 467 } | 453 } |
| 468 if (!update_origin) | 454 if (!update_origin) |
| 469 origin = model_.mode().origin; | 455 origin = model_.mode().origin; |
| 470 | 456 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 500 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 486 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 501 } | 487 } |
| 502 | 488 |
| 503 bool SearchTabHelper::IsInputInProgress() const { | 489 bool SearchTabHelper::IsInputInProgress() const { |
| 504 if (model_.mode().is_ntp()) | 490 if (model_.mode().is_ntp()) |
| 505 return false; | 491 return false; |
| 506 const OmniboxView* omnibox_view = GetOmniboxView(); | 492 const OmniboxView* omnibox_view = GetOmniboxView(); |
| 507 return omnibox_view && | 493 return omnibox_view && |
| 508 omnibox_view->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 494 omnibox_view->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
| 509 } | 495 } |
| OLD | NEW |