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 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 // Update theme info so that the page picks it up. | 980 // Update theme info so that the page picks it up. |
981 browser_->UpdateThemeInfo(); | 981 browser_->UpdateThemeInfo(); |
982 | 982 |
983 // Ensure the searchbox API has the correct initial state. | 983 // Ensure the searchbox API has the correct initial state. |
984 if (IsContentsFrom(overlay(), contents)) { | 984 if (IsContentsFrom(overlay(), contents)) { |
985 overlay_->SetDisplayInstantResults(instant_enabled_); | 985 overlay_->SetDisplayInstantResults(instant_enabled_); |
986 overlay_->KeyCaptureChanged( | 986 overlay_->KeyCaptureChanged( |
987 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); | 987 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); |
988 overlay_->SetOmniboxBounds(omnibox_bounds_); | 988 overlay_->SetOmniboxBounds(omnibox_bounds_); |
989 overlay_->InitializeFonts(); | 989 overlay_->InitializeFonts(); |
990 overlay_->GrantChromeSearchAccessFromOrigin(GURL(overlay_->instant_url())); | |
991 } else if (IsContentsFrom(ntp(), contents)) { | 990 } else if (IsContentsFrom(ntp(), contents)) { |
992 ntp_->SetDisplayInstantResults(instant_enabled_); | 991 ntp_->SetDisplayInstantResults(instant_enabled_); |
993 ntp_->SetOmniboxBounds(omnibox_bounds_); | 992 ntp_->SetOmniboxBounds(omnibox_bounds_); |
994 ntp_->InitializeFonts(); | 993 ntp_->InitializeFonts(); |
995 ntp_->GrantChromeSearchAccessFromOrigin(GURL(ntp_->instant_url())); | |
996 } else { | 994 } else { |
997 NOTREACHED(); | 995 NOTREACHED(); |
998 } | 996 } |
999 StartListeningToMostVisitedChanges(); | 997 StartListeningToMostVisitedChanges(); |
1000 } | 998 } |
1001 | 999 |
1002 void InstantController::InstantSupportDetermined( | 1000 void InstantController::InstantSupportDetermined( |
1003 const content::WebContents* contents, | 1001 const content::WebContents* contents, |
1004 bool supports_instant) { | 1002 bool supports_instant) { |
1005 if (IsContentsFrom(instant_tab(), contents)) { | 1003 if (IsContentsFrom(instant_tab(), contents)) { |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 if (!search_mode_.is_origin_default() && !use_local_overlay_only_) { | 1295 if (!search_mode_.is_origin_default() && !use_local_overlay_only_) { |
1298 content::WebContents* active_tab = browser_->GetActiveWebContents(); | 1296 content::WebContents* active_tab = browser_->GetActiveWebContents(); |
1299 if (!instant_tab_ || active_tab != instant_tab_->contents()) { | 1297 if (!instant_tab_ || active_tab != instant_tab_->contents()) { |
1300 instant_tab_.reset(new InstantTab(this)); | 1298 instant_tab_.reset(new InstantTab(this)); |
1301 instant_tab_->Init(active_tab); | 1299 instant_tab_->Init(active_tab); |
1302 // Update theme info for this tab. | 1300 // Update theme info for this tab. |
1303 browser_->UpdateThemeInfo(); | 1301 browser_->UpdateThemeInfo(); |
1304 instant_tab_->SetDisplayInstantResults(instant_enabled_); | 1302 instant_tab_->SetDisplayInstantResults(instant_enabled_); |
1305 instant_tab_->SetOmniboxBounds(omnibox_bounds_); | 1303 instant_tab_->SetOmniboxBounds(omnibox_bounds_); |
1306 instant_tab_->InitializeFonts(); | 1304 instant_tab_->InitializeFonts(); |
1307 instant_tab_->GrantChromeSearchAccessFromOrigin(active_tab->GetURL()); | |
1308 StartListeningToMostVisitedChanges(); | 1305 StartListeningToMostVisitedChanges(); |
1309 instant_tab_->KeyCaptureChanged( | 1306 instant_tab_->KeyCaptureChanged( |
1310 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); | 1307 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); |
1311 } | 1308 } |
1312 | 1309 |
1313 // Hide the |overlay_| since we are now using |instant_tab_| instead. | 1310 // Hide the |overlay_| since we are now using |instant_tab_| instead. |
1314 HideOverlay(); | 1311 HideOverlay(); |
1315 } else { | 1312 } else { |
1316 instant_tab_.reset(); | 1313 instant_tab_.reset(); |
1317 } | 1314 } |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 // for instance, if the user types 'i' and the suggestion is 'INSTANT', | 1576 // for instance, if the user types 'i' and the suggestion is 'INSTANT', |
1580 // suggest 'nstant'. Otherwise, the user text really isn't a prefix, so | 1577 // suggest 'nstant'. Otherwise, the user text really isn't a prefix, so |
1581 // suggest nothing. | 1578 // suggest nothing. |
1582 // TODO(samarth|jered): revisit this logic. http://crbug.com/196572. | 1579 // TODO(samarth|jered): revisit this logic. http://crbug.com/196572. |
1583 return true; | 1580 return true; |
1584 } | 1581 } |
1585 } | 1582 } |
1586 | 1583 |
1587 return false; | 1584 return false; |
1588 } | 1585 } |
OLD | NEW |