Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1552)

Side by Side Diff: chrome/browser/ui/search/instant_controller.cc

Issue 17303003: InstantExtended: hook up InstantTab in incognito. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Dont send other info in incognito. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <iterator> 7 #include <iterator>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 GURL(instant_url))) 1584 GURL(instant_url)))
1585 return false; 1585 return false;
1586 1586
1587 return page->supports_instant(); 1587 return page->supports_instant();
1588 } 1588 }
1589 1589
1590 void InstantController::ResetNTP(const std::string& instant_url) { 1590 void InstantController::ResetNTP(const std::string& instant_url) {
1591 // Instant NTP is only used in extended mode so we should always have a 1591 // Instant NTP is only used in extended mode so we should always have a
1592 // non-empty URL to use. 1592 // non-empty URL to use.
1593 DCHECK(!instant_url.empty()); 1593 DCHECK(!instant_url.empty());
1594 ntp_.reset(new InstantNTP(this, instant_url)); 1594 ntp_.reset(new InstantNTP(this, instant_url,
1595 browser_->profile()->IsOffTheRecord()));
1595 ntp_->InitContents(profile(), browser_->GetActiveWebContents(), 1596 ntp_->InitContents(profile(), browser_->GetActiveWebContents(),
1596 base::Bind(&InstantController::ReloadStaleNTP, 1597 base::Bind(&InstantController::ReloadStaleNTP,
1597 base::Unretained(this))); 1598 base::Unretained(this)));
1598 LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf( 1599 LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf(
1599 "ResetNTP: instant_url='%s'", instant_url.c_str())); 1600 "ResetNTP: instant_url='%s'", instant_url.c_str()));
1600 } 1601 }
1601 1602
1602 void InstantController::ReloadStaleNTP() { 1603 void InstantController::ReloadStaleNTP() {
1603 ResetNTP(GetInstantURL()); 1604 ResetNTP(GetInstantURL());
1604 } 1605 }
(...skipping 20 matching lines...) Expand all
1625 return !(InStartup() && chrome::ShouldPreferRemoteNTPOnStartup()); 1626 return !(InStartup() && chrome::ShouldPreferRemoteNTPOnStartup());
1626 } 1627 }
1627 1628
1628 void InstantController::ResetOverlay(const std::string& instant_url) { 1629 void InstantController::ResetOverlay(const std::string& instant_url) {
1629 HideInternal(); 1630 HideInternal();
1630 // If there's no active tab, the browser is opening or closing. 1631 // If there's no active tab, the browser is opening or closing.
1631 const content::WebContents* active_tab = browser_->GetActiveWebContents(); 1632 const content::WebContents* active_tab = browser_->GetActiveWebContents();
1632 if (!active_tab || instant_url.empty()) { 1633 if (!active_tab || instant_url.empty()) {
1633 overlay_.reset(); 1634 overlay_.reset();
1634 } else { 1635 } else {
1635 overlay_.reset(new InstantOverlay(this, instant_url)); 1636 overlay_.reset(new InstantOverlay(this, instant_url,
1637 browser_->profile()->IsOffTheRecord()));
1636 overlay_->InitContents(browser_->profile(), active_tab); 1638 overlay_->InitContents(browser_->profile(), active_tab);
1637 } 1639 }
1638 LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf( 1640 LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf(
1639 "ResetOverlay: instant_url='%s'", instant_url.c_str())); 1641 "ResetOverlay: instant_url='%s'", instant_url.c_str()));
1640 } 1642 }
1641 1643
1642 InstantController::InstantFallbackReason 1644 InstantController::InstantFallbackReason
1643 InstantController::ShouldSwitchToLocalOverlay() const { 1645 InstantController::ShouldSwitchToLocalOverlay() const {
1644 if (!extended_enabled()) 1646 if (!extended_enabled())
1645 return INSTANT_FALLBACK_NONE; 1647 return INSTANT_FALLBACK_NONE;
1646 1648
1647 if (!overlay()) 1649 if (!overlay())
1648 return DetermineFallbackReason(NULL, std::string()); 1650 return DetermineFallbackReason(NULL, std::string());
1649 1651
1650 // Assume users with Javascript disabled do not want the online experience. 1652 // Assume users with Javascript disabled do not want the online experience.
1651 if (!IsJavascriptEnabled()) 1653 if (!IsJavascriptEnabled())
1652 return INSTANT_FALLBACK_JAVASCRIPT_DISABLED; 1654 return INSTANT_FALLBACK_JAVASCRIPT_DISABLED;
1653 1655
1654 if (overlay()->IsLocal()) 1656 if (overlay()->IsLocal())
1655 return INSTANT_FALLBACK_NONE; 1657 return INSTANT_FALLBACK_NONE;
1656 1658
1657 bool page_is_current = PageIsCurrent(overlay()); 1659 bool page_is_current = PageIsCurrent(overlay());
1658 if (!page_is_current) 1660 if (!page_is_current)
1659 return DetermineFallbackReason(overlay(), GetInstantURL()); 1661 return DetermineFallbackReason(overlay(), GetInstantURL());
1660 1662
1661 return INSTANT_FALLBACK_NONE; 1663 return INSTANT_FALLBACK_NONE;
1662 } 1664 }
1663 1665
1664 void InstantController::ResetInstantTab() { 1666 void InstantController::ResetInstantTab() {
1665 // Do not wire up the InstantTab in Incognito, to prevent it from sending data 1667 if (!search_mode_.is_origin_default()) {
1666 // to the page.
1667 if (!search_mode_.is_origin_default() &&
1668 !browser_->profile()->IsOffTheRecord()) {
1669 content::WebContents* active_tab = browser_->GetActiveWebContents(); 1668 content::WebContents* active_tab = browser_->GetActiveWebContents();
1670 if (!instant_tab_ || active_tab != instant_tab_->contents()) { 1669 if (!instant_tab_ || active_tab != instant_tab_->contents()) {
1671 instant_tab_.reset(new InstantTab(this)); 1670 instant_tab_.reset(
1671 new InstantTab(this, browser_->profile()->IsOffTheRecord()));
1672 instant_tab_->Init(active_tab); 1672 instant_tab_->Init(active_tab);
1673 UpdateInfoForInstantTab(); 1673 UpdateInfoForInstantTab();
1674 use_tab_for_suggestions_ = true; 1674 use_tab_for_suggestions_ = true;
1675 } 1675 }
1676 1676
1677 // Hide the |overlay_| since we are now using |instant_tab_| instead. 1677 // Hide the |overlay_| since we are now using |instant_tab_| instead.
1678 HideOverlay(); 1678 HideOverlay();
1679 } else { 1679 } else {
1680 instant_tab_.reset(); 1680 instant_tab_.reset();
1681 } 1681 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 bool js_webkit_enabled = profile()->GetPrefs()->GetBoolean( 1911 bool js_webkit_enabled = profile()->GetPrefs()->GetBoolean(
1912 prefs::kWebKitJavascriptEnabled); 1912 prefs::kWebKitJavascriptEnabled);
1913 return js_content_enabled && js_webkit_enabled; 1913 return js_content_enabled && js_webkit_enabled;
1914 } 1914 }
1915 1915
1916 bool InstantController::InStartup() const { 1916 bool InstantController::InStartup() const {
1917 // TODO(shishir): This is not completely reliable. Find a better way to detect 1917 // TODO(shishir): This is not completely reliable. Find a better way to detect
1918 // startup time. 1918 // startup time.
1919 return !browser_->GetActiveWebContents(); 1919 return !browser_->GetActiveWebContents();
1920 } 1920 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698