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/instant_controller.h" | 5 #include "chrome/browser/ui/search/instant_controller.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 // Update theme info so that the page picks it up. | 1008 // Update theme info so that the page picks it up. |
1009 browser_->UpdateThemeInfo(); | 1009 browser_->UpdateThemeInfo(); |
1010 | 1010 |
1011 // Ensure the searchbox API has the correct initial state. | 1011 // Ensure the searchbox API has the correct initial state. |
1012 if (IsContentsFrom(overlay(), contents)) { | 1012 if (IsContentsFrom(overlay(), contents)) { |
1013 overlay_->SetDisplayInstantResults(instant_enabled_); | 1013 overlay_->SetDisplayInstantResults(instant_enabled_); |
1014 overlay_->KeyCaptureChanged( | 1014 overlay_->KeyCaptureChanged( |
1015 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); | 1015 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); |
1016 overlay_->SetOmniboxBounds(omnibox_bounds_); | 1016 overlay_->SetOmniboxBounds(omnibox_bounds_); |
1017 overlay_->InitializeFonts(); | 1017 overlay_->InitializeFonts(); |
1018 overlay_->GrantChromeSearchAccessFromOrigin(GURL(overlay_->instant_url())); | |
1019 } else if (IsContentsFrom(ntp(), contents)) { | 1018 } else if (IsContentsFrom(ntp(), contents)) { |
1020 ntp_->SetDisplayInstantResults(instant_enabled_); | 1019 ntp_->SetDisplayInstantResults(instant_enabled_); |
1021 ntp_->SetOmniboxBounds(omnibox_bounds_); | 1020 ntp_->SetOmniboxBounds(omnibox_bounds_); |
1022 ntp_->InitializeFonts(); | 1021 ntp_->InitializeFonts(); |
1023 ntp_->GrantChromeSearchAccessFromOrigin(GURL(ntp_->instant_url())); | |
1024 } else { | 1022 } else { |
1025 NOTREACHED(); | 1023 NOTREACHED(); |
1026 } | 1024 } |
1027 StartListeningToMostVisitedChanges(); | 1025 StartListeningToMostVisitedChanges(); |
1028 } | 1026 } |
1029 | 1027 |
1030 void InstantController::InstantSupportDetermined( | 1028 void InstantController::InstantSupportDetermined( |
1031 const content::WebContents* contents, | 1029 const content::WebContents* contents, |
1032 bool supports_instant) { | 1030 bool supports_instant) { |
1033 if (IsContentsFrom(instant_tab(), contents)) { | 1031 if (IsContentsFrom(instant_tab(), contents)) { |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 if (!search_mode_.is_origin_default() && !use_local_overlay_only_) { | 1329 if (!search_mode_.is_origin_default() && !use_local_overlay_only_) { |
1332 content::WebContents* active_tab = browser_->GetActiveWebContents(); | 1330 content::WebContents* active_tab = browser_->GetActiveWebContents(); |
1333 if (!instant_tab_ || active_tab != instant_tab_->contents()) { | 1331 if (!instant_tab_ || active_tab != instant_tab_->contents()) { |
1334 instant_tab_.reset(new InstantTab(this)); | 1332 instant_tab_.reset(new InstantTab(this)); |
1335 instant_tab_->Init(active_tab); | 1333 instant_tab_->Init(active_tab); |
1336 // Update theme info for this tab. | 1334 // Update theme info for this tab. |
1337 browser_->UpdateThemeInfo(); | 1335 browser_->UpdateThemeInfo(); |
1338 instant_tab_->SetDisplayInstantResults(instant_enabled_); | 1336 instant_tab_->SetDisplayInstantResults(instant_enabled_); |
1339 instant_tab_->SetOmniboxBounds(omnibox_bounds_); | 1337 instant_tab_->SetOmniboxBounds(omnibox_bounds_); |
1340 instant_tab_->InitializeFonts(); | 1338 instant_tab_->InitializeFonts(); |
1341 instant_tab_->GrantChromeSearchAccessFromOrigin(active_tab->GetURL()); | |
1342 StartListeningToMostVisitedChanges(); | 1339 StartListeningToMostVisitedChanges(); |
1343 instant_tab_->KeyCaptureChanged( | 1340 instant_tab_->KeyCaptureChanged( |
1344 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); | 1341 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); |
1345 } | 1342 } |
1346 | 1343 |
1347 // Hide the |overlay_| since we are now using |instant_tab_| instead. | 1344 // Hide the |overlay_| since we are now using |instant_tab_| instead. |
1348 HideOverlay(); | 1345 HideOverlay(); |
1349 } else { | 1346 } else { |
1350 instant_tab_.reset(); | 1347 instant_tab_.reset(); |
1351 } | 1348 } |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 // for instance, if the user types 'i' and the suggestion is 'INSTANT', | 1616 // for instance, if the user types 'i' and the suggestion is 'INSTANT', |
1620 // suggest 'nstant'. Otherwise, the user text really isn't a prefix, so | 1617 // suggest 'nstant'. Otherwise, the user text really isn't a prefix, so |
1621 // suggest nothing. | 1618 // suggest nothing. |
1622 // TODO(samarth|jered): revisit this logic. http://crbug.com/196572. | 1619 // TODO(samarth|jered): revisit this logic. http://crbug.com/196572. |
1623 return true; | 1620 return true; |
1624 } | 1621 } |
1625 } | 1622 } |
1626 | 1623 |
1627 return false; | 1624 return false; |
1628 } | 1625 } |
OLD | NEW |