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

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

Issue 13233003: Instant: Use Local NTP in non-incognito whenever possible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 content::NotificationService::NoDetails()); 476 content::NotificationService::NoDetails());
477 477
478 // We don't have new suggestions yet, but we can either reuse the existing 478 // We don't have new suggestions yet, but we can either reuse the existing
479 // suggestion or reset the existing "gray text". 479 // suggestion or reset the existing "gray text".
480 browser_->SetInstantSuggestion(last_suggestion_); 480 browser_->SetInstantSuggestion(last_suggestion_);
481 481
482 return true; 482 return true;
483 } 483 }
484 484
485 scoped_ptr<content::WebContents> InstantController::ReleaseNTPContents() { 485 scoped_ptr<content::WebContents> InstantController::ReleaseNTPContents() {
486 if (!extended_enabled_ || use_local_overlay_only_) 486 if (!extended_enabled_ || !browser_->profile() ||
487 browser_->profile()->IsOffTheRecord())
487 return scoped_ptr<content::WebContents>(NULL); 488 return scoped_ptr<content::WebContents>(NULL);
488 489
489 LOG_INSTANT_DEBUG_EVENT(this, "ReleaseNTPContents"); 490 LOG_INSTANT_DEBUG_EVENT(this, "ReleaseNTPContents");
490 491
491 if (ShouldSwitchToLocalNTP()) 492 if (ShouldSwitchToLocalNTP())
492 ResetNTP(false, true); 493 ResetNTP(false, true);
493 494
494 scoped_ptr<content::WebContents> ntp_contents; 495 scoped_ptr<content::WebContents> ntp_contents = ntp_->ReleaseContents();
495 if (ntp_)
496 ntp_contents = ntp_->ReleaseContents();
497 496
498 // Override the blacklist on an explicit user action. 497 // Override the blacklist on an explicit user action.
499 ResetNTP(true, false); 498 ResetNTP(true, false);
500 return ntp_contents.Pass(); 499 return ntp_contents.Pass();
501 } 500 }
502 501
503 // TODO(tonyg): This method only fires when the omnibox bounds change. It also 502 // TODO(tonyg): This method only fires when the omnibox bounds change. It also
504 // needs to fire when the overlay bounds change (e.g.: open/close info bar). 503 // needs to fire when the overlay bounds change (e.g.: open/close info bar).
505 void InstantController::SetPopupBounds(const gfx::Rect& bounds) { 504 void InstantController::SetPopupBounds(const gfx::Rect& bounds) {
506 if (!extended_enabled_ && !instant_enabled_) 505 if (!extended_enabled_ && !instant_enabled_)
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 #else 1249 #else
1251 if (IsFullHeight(model_)) 1250 if (IsFullHeight(model_))
1252 CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); 1251 CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST);
1253 else if (!IsViewInContents(GetViewGainingFocus(view_gaining_focus), 1252 else if (!IsViewInContents(GetViewGainingFocus(view_gaining_focus),
1254 overlay_->contents())) 1253 overlay_->contents()))
1255 HideOverlay(); 1254 HideOverlay();
1256 #endif 1255 #endif
1257 } 1256 }
1258 1257
1259 void InstantController::ResetNTP(bool ignore_blacklist, bool use_local_ntp) { 1258 void InstantController::ResetNTP(bool ignore_blacklist, bool use_local_ntp) {
1260 ntp_.reset();
1261 std::string instant_url; 1259 std::string instant_url;
1262 if (use_local_ntp || 1260 if (use_local_ntp ||
1263 !GetInstantURL(browser_->profile(), ignore_blacklist, &instant_url)) 1261 !GetInstantURL(browser_->profile(), ignore_blacklist, &instant_url))
1264 instant_url = chrome::kChromeSearchLocalNtpUrl; 1262 instant_url = chrome::kChromeSearchLocalNtpUrl;
1265 ntp_.reset(new InstantNTP(this, instant_url)); 1263 ntp_.reset(new InstantNTP(this, instant_url));
1266 ntp_->InitContents(browser_->profile(), browser_->GetActiveWebContents(), 1264 ntp_->InitContents(browser_->profile(), browser_->GetActiveWebContents(),
1267 base::Bind(&InstantController::ResetNTP, 1265 base::Bind(&InstantController::ResetNTP,
1268 base::Unretained(this), false, false)); 1266 base::Unretained(this), false, false));
1269 } 1267 }
1270 1268
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 1622
1625 // If this is not window startup, switch. 1623 // If this is not window startup, switch.
1626 // TODO(shishir): This is not completely reliable. Find a better way to detect 1624 // TODO(shishir): This is not completely reliable. Find a better way to detect
1627 // startup time. 1625 // startup time.
1628 if (browser_->GetActiveWebContents()) 1626 if (browser_->GetActiveWebContents())
1629 return true; 1627 return true;
1630 1628
1631 return chrome::IsAggressiveLocalNTPFallbackEnabled(); 1629 return chrome::IsAggressiveLocalNTPFallbackEnabled();
1632 } 1630 }
1633 1631
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698