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

Side by Side Diff: chrome/browser/browser.cc

Issue 3415026: Makes instant support other open dispositions. (Closed)
Patch Set: Merge and prune Created 10 years, 2 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
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/tab_contents/match_preview.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser.h" 5 #include "chrome/browser/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <windows.h> 9 #include <windows.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 void Browser::Home(WindowOpenDisposition disposition) { 1231 void Browser::Home(WindowOpenDisposition disposition) {
1232 UserMetrics::RecordAction(UserMetricsAction("Home"), profile_); 1232 UserMetrics::RecordAction(UserMetricsAction("Home"), profile_);
1233 OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); 1233 OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK);
1234 } 1234 }
1235 1235
1236 void Browser::OpenCurrentURL() { 1236 void Browser::OpenCurrentURL() {
1237 UserMetrics::RecordAction(UserMetricsAction("LoadURL"), profile_); 1237 UserMetrics::RecordAction(UserMetricsAction("LoadURL"), profile_);
1238 LocationBar* location_bar = window_->GetLocationBar(); 1238 LocationBar* location_bar = window_->GetLocationBar();
1239 WindowOpenDisposition open_disposition = 1239 WindowOpenDisposition open_disposition =
1240 location_bar->GetWindowOpenDisposition(); 1240 location_bar->GetWindowOpenDisposition();
1241 // TODO(sky): support other dispositions. 1241 if (OpenMatchPreview(open_disposition))
1242 if (open_disposition == CURRENT_TAB && match_preview() &&
1243 match_preview()->is_active()) {
1244 match_preview()->CommitCurrentPreview(MatchPreview::COMMIT_PRESSED_ENTER);
1245 return; 1242 return;
1246 }
1247 1243
1248 GURL url(WideToUTF8(location_bar->GetInputString())); 1244 GURL url(WideToUTF8(location_bar->GetInputString()));
1249 1245
1250 // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least 1246 // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least
1251 // inherit the opener. In some cases the tabstrip will determine the group 1247 // inherit the opener. In some cases the tabstrip will determine the group
1252 // should be inherited, in which case the group is inherited instead of the 1248 // should be inherited, in which case the group is inherited instead of the
1253 // opener. 1249 // opener.
1254 OpenURLAtIndex(NULL, url, GURL(), open_disposition, 1250 OpenURLAtIndex(NULL, url, GURL(), open_disposition,
1255 location_bar->GetPageTransition(), -1, 1251 location_bar->GetPageTransition(), -1,
1256 TabStripModel::ADD_FORCE_INDEX | 1252 TabStripModel::ADD_FORCE_INDEX |
(...skipping 2842 matching lines...) Expand 10 before | Expand all | Expand 10 after
4099 } 4095 }
4100 4096
4101 void Browser::TabRestoreServiceDestroyed(TabRestoreService* service) { 4097 void Browser::TabRestoreServiceDestroyed(TabRestoreService* service) {
4102 if (!tab_restore_service_) 4098 if (!tab_restore_service_)
4103 return; 4099 return;
4104 4100
4105 DCHECK_EQ(tab_restore_service_, service); 4101 DCHECK_EQ(tab_restore_service_, service);
4106 tab_restore_service_->RemoveObserver(this); 4102 tab_restore_service_->RemoveObserver(this);
4107 tab_restore_service_ = NULL; 4103 tab_restore_service_ = NULL;
4108 } 4104 }
4105
4106 bool Browser::OpenMatchPreview(WindowOpenDisposition disposition) {
4107 if (!match_preview() || !match_preview()->is_active())
4108 return false;
4109
4110 if (disposition == CURRENT_TAB) {
4111 match_preview()->CommitCurrentPreview(MatchPreview::COMMIT_PRESSED_ENTER);
4112 return true;
4113 }
4114 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) {
4115 HideMatchPreview();
4116 TabContents* preview_contents = match_preview()->ReleasePreviewContents(
4117 MatchPreview::COMMIT_PRESSED_ENTER);
4118 preview_contents->controller().PruneAllButActive();
4119 tabstrip_model_->AddTabContents(
4120 preview_contents,
4121 -1,
4122 match_preview()->last_transition_type(),
4123 disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_SELECTED :
4124 TabStripModel::ADD_NONE);
4125 return true;
4126 }
4127 // The omnibox currently doesn't use other dispositions, so we don't attempt
4128 // to handle them. If you hit this NOTREACHED file a bug and I'll (sky) add
4129 // support for the new disposition.
4130 NOTREACHED();
4131 return false;
4132 }
OLDNEW
« 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