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

Unified Diff: chrome/browser/browser.cc

Issue 3415026: Makes instant support other open dispositions. (Closed)
Patch Set: Merge and prune Created 10 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/tab_contents/match_preview.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser.cc
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index bf50bdd8f5953d8478eb020b79c2bb2d3983d826..426d54f7aecfc3f2ff58b0ed6d9bdaed29980df0 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1238,12 +1238,8 @@ void Browser::OpenCurrentURL() {
LocationBar* location_bar = window_->GetLocationBar();
WindowOpenDisposition open_disposition =
location_bar->GetWindowOpenDisposition();
- // TODO(sky): support other dispositions.
- if (open_disposition == CURRENT_TAB && match_preview() &&
- match_preview()->is_active()) {
- match_preview()->CommitCurrentPreview(MatchPreview::COMMIT_PRESSED_ENTER);
+ if (OpenMatchPreview(open_disposition))
return;
- }
GURL url(WideToUTF8(location_bar->GetInputString()));
@@ -4106,3 +4102,31 @@ void Browser::TabRestoreServiceDestroyed(TabRestoreService* service) {
tab_restore_service_->RemoveObserver(this);
tab_restore_service_ = NULL;
}
+
+bool Browser::OpenMatchPreview(WindowOpenDisposition disposition) {
+ if (!match_preview() || !match_preview()->is_active())
+ return false;
+
+ if (disposition == CURRENT_TAB) {
+ match_preview()->CommitCurrentPreview(MatchPreview::COMMIT_PRESSED_ENTER);
+ return true;
+ }
+ if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) {
+ HideMatchPreview();
+ TabContents* preview_contents = match_preview()->ReleasePreviewContents(
+ MatchPreview::COMMIT_PRESSED_ENTER);
+ preview_contents->controller().PruneAllButActive();
+ tabstrip_model_->AddTabContents(
+ preview_contents,
+ -1,
+ match_preview()->last_transition_type(),
+ disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_SELECTED :
+ TabStripModel::ADD_NONE);
+ return true;
+ }
+ // The omnibox currently doesn't use other dispositions, so we don't attempt
+ // to handle them. If you hit this NOTREACHED file a bug and I'll (sky) add
+ // support for the new disposition.
+ NOTREACHED();
+ return false;
+}
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/tab_contents/match_preview.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698