| 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/instant/instant_controller.h" | 5 #include "chrome/browser/instant/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 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 // Update theme info so that the page picks it up. | 895 // Update theme info so that the page picks it up. |
| 896 browser_->UpdateThemeInfo(); | 896 browser_->UpdateThemeInfo(); |
| 897 | 897 |
| 898 // Ensure the searchbox API has the correct initial state. | 898 // Ensure the searchbox API has the correct initial state. |
| 899 if (IsContentsFrom(overlay(), contents)) { | 899 if (IsContentsFrom(overlay(), contents)) { |
| 900 overlay_->SetDisplayInstantResults(instant_enabled_); | 900 overlay_->SetDisplayInstantResults(instant_enabled_); |
| 901 overlay_->KeyCaptureChanged( | 901 overlay_->KeyCaptureChanged( |
| 902 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); | 902 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); |
| 903 overlay_->SetOmniboxBounds(omnibox_bounds_); | 903 overlay_->SetOmniboxBounds(omnibox_bounds_); |
| 904 overlay_->InitializeFonts(); | 904 overlay_->InitializeFonts(); |
| 905 overlay_->GrantChromeSearchAccessFromOrigin(GURL(overlay_->instant_url())); |
| 905 } else if (IsContentsFrom(ntp(), contents)) { | 906 } else if (IsContentsFrom(ntp(), contents)) { |
| 906 ntp_->SetDisplayInstantResults(instant_enabled_); | 907 ntp_->SetDisplayInstantResults(instant_enabled_); |
| 907 ntp_->SetOmniboxBounds(omnibox_bounds_); | 908 ntp_->SetOmniboxBounds(omnibox_bounds_); |
| 908 ntp_->InitializeFonts(); | 909 ntp_->InitializeFonts(); |
| 910 ntp_->GrantChromeSearchAccessFromOrigin(GURL(ntp_->instant_url())); |
| 909 } else { | 911 } else { |
| 910 NOTREACHED(); | 912 NOTREACHED(); |
| 911 } | 913 } |
| 912 StartListeningToMostVisitedChanges(); | 914 StartListeningToMostVisitedChanges(); |
| 913 } | 915 } |
| 914 | 916 |
| 915 void InstantController::InstantSupportDetermined( | 917 void InstantController::InstantSupportDetermined( |
| 916 const content::WebContents* contents, | 918 const content::WebContents* contents, |
| 917 bool supports_instant) { | 919 bool supports_instant) { |
| 918 if (IsContentsFrom(instant_tab(), contents)) { | 920 if (IsContentsFrom(instant_tab(), contents)) { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 if (!search_mode_.is_origin_default() && !use_local_overlay_only_) { | 1239 if (!search_mode_.is_origin_default() && !use_local_overlay_only_) { |
| 1238 content::WebContents* active_tab = browser_->GetActiveWebContents(); | 1240 content::WebContents* active_tab = browser_->GetActiveWebContents(); |
| 1239 if (!instant_tab_ || active_tab != instant_tab_->contents()) { | 1241 if (!instant_tab_ || active_tab != instant_tab_->contents()) { |
| 1240 instant_tab_.reset(new InstantTab(this)); | 1242 instant_tab_.reset(new InstantTab(this)); |
| 1241 instant_tab_->Init(active_tab); | 1243 instant_tab_->Init(active_tab); |
| 1242 // Update theme info for this tab. | 1244 // Update theme info for this tab. |
| 1243 browser_->UpdateThemeInfo(); | 1245 browser_->UpdateThemeInfo(); |
| 1244 instant_tab_->SetDisplayInstantResults(instant_enabled_); | 1246 instant_tab_->SetDisplayInstantResults(instant_enabled_); |
| 1245 instant_tab_->SetOmniboxBounds(omnibox_bounds_); | 1247 instant_tab_->SetOmniboxBounds(omnibox_bounds_); |
| 1246 instant_tab_->InitializeFonts(); | 1248 instant_tab_->InitializeFonts(); |
| 1249 instant_tab_->GrantChromeSearchAccessFromOrigin(active_tab->GetURL()); |
| 1247 StartListeningToMostVisitedChanges(); | 1250 StartListeningToMostVisitedChanges(); |
| 1248 instant_tab_->KeyCaptureChanged( | 1251 instant_tab_->KeyCaptureChanged( |
| 1249 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); | 1252 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); |
| 1250 } | 1253 } |
| 1251 | 1254 |
| 1252 // Hide the |overlay_| since we are now using |instant_tab_| instead. | 1255 // Hide the |overlay_| since we are now using |instant_tab_| instead. |
| 1253 HideOverlay(); | 1256 HideOverlay(); |
| 1254 } else { | 1257 } else { |
| 1255 instant_tab_.reset(); | 1258 instant_tab_.reset(); |
| 1256 } | 1259 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 overlay_->SendMostVisitedItems(items); | 1473 overlay_->SendMostVisitedItems(items); |
| 1471 if (ntp_) | 1474 if (ntp_) |
| 1472 ntp_->SendMostVisitedItems(items); | 1475 ntp_->SendMostVisitedItems(items); |
| 1473 if (instant_tab_) | 1476 if (instant_tab_) |
| 1474 instant_tab_->SendMostVisitedItems(items); | 1477 instant_tab_->SendMostVisitedItems(items); |
| 1475 content::NotificationService::current()->Notify( | 1478 content::NotificationService::current()->Notify( |
| 1476 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, | 1479 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, |
| 1477 content::Source<InstantController>(this), | 1480 content::Source<InstantController>(this), |
| 1478 content::NotificationService::NoDetails()); | 1481 content::NotificationService::NoDetails()); |
| 1479 } | 1482 } |
| OLD | NEW |