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

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

Issue 2807016: Make pinned tabs a little stickier. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: review comments Created 10 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
« no previous file with comments | « no previous file | chrome/browser/browser_unittest.cc » ('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 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 selected_contents->GetURL().GetOrigin() == 1226 selected_contents->GetURL().GetOrigin() ==
1227 GURL(chrome::kChromeUINewTabURL).GetOrigin()) { 1227 GURL(chrome::kChromeUINewTabURL).GetOrigin()) {
1228 // If the |url| is within an app's web extent and it was typed into the 1228 // If the |url| is within an app's web extent and it was typed into the
1229 // omnibox of an NTP page, interpret as an app launch and close the NTP 1229 // omnibox of an NTP page, interpret as an app launch and close the NTP
1230 // tab. 1230 // tab.
1231 Browser::OpenApplication(profile(), extension, 1231 Browser::OpenApplication(profile(), extension,
1232 extension->launch_container()); 1232 extension->launch_container());
1233 CloseTabContents(selected_contents); 1233 CloseTabContents(selected_contents);
1234 return; 1234 return;
1235 } 1235 }
1236
1237 if (selected_contents) {
1238 // For the purposes of changing the window open disposition, the referrer
1239 // is the current tab's URL.
1240 open_disposition = AdjustWindowOpenDispositionForTab(
1241 IsPinned(selected_contents),
1242 url,
1243 selected_contents->GetURL(),
1244 location_bar->GetPageTransition(),
1245 open_disposition);
1246 }
1236 } 1247 }
1237 1248
1238 OpenURLAtIndex(NULL, url, GURL(), 1249 OpenURLAtIndex(NULL, url, GURL(),
1239 open_disposition, 1250 open_disposition,
1240 location_bar->GetPageTransition(), -1, true); 1251 location_bar->GetPageTransition(), -1, true);
1241 } 1252 }
1242 1253
1243 void Browser::Stop() { 1254 void Browser::Stop() {
1244 UserMetrics::RecordAction(UserMetricsAction("Stop"), profile_); 1255 UserMetrics::RecordAction(UserMetricsAction("Stop"), profile_);
1245 GetSelectedTabContents()->Stop(); 1256 GetSelectedTabContents()->Stop();
(...skipping 2382 matching lines...) Expand 10 before | Expand all | Expand 10 after
3628 // static 3639 // static
3629 WindowOpenDisposition Browser::AdjustWindowOpenDispositionForTab( 3640 WindowOpenDisposition Browser::AdjustWindowOpenDispositionForTab(
3630 bool is_pinned, 3641 bool is_pinned,
3631 const GURL& url, 3642 const GURL& url,
3632 const GURL& referrer, 3643 const GURL& referrer,
3633 PageTransition::Type transition, 3644 PageTransition::Type transition,
3634 WindowOpenDisposition original_disposition) { 3645 WindowOpenDisposition original_disposition) {
3635 if (!is_pinned || 3646 if (!is_pinned ||
3636 original_disposition != CURRENT_TAB || 3647 original_disposition != CURRENT_TAB ||
3637 (transition != PageTransition::AUTO_BOOKMARK && 3648 (transition != PageTransition::AUTO_BOOKMARK &&
3638 transition != PageTransition::LINK)) { 3649 transition != PageTransition::LINK &&
3650 transition != PageTransition::TYPED)) {
3639 return original_disposition; 3651 return original_disposition;
3640 } 3652 }
3641 3653
3642 bool url_is_http_or_https = 3654 bool url_is_http_or_https =
3643 url.SchemeIs(chrome::kHttpScheme) || 3655 url.SchemeIs(chrome::kHttpScheme) ||
3644 url.SchemeIs(chrome::kHttpsScheme); 3656 url.SchemeIs(chrome::kHttpsScheme);
3645 bool referrer_is_http_or_https = 3657 bool referrer_is_http_or_https =
3646 referrer.SchemeIs(chrome::kHttpScheme) || 3658 referrer.SchemeIs(chrome::kHttpScheme) ||
3647 referrer.SchemeIs(chrome::kHttpsScheme); 3659 referrer.SchemeIs(chrome::kHttpsScheme);
3648 bool scheme_matches = 3660 bool scheme_matches =
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
3943 } 3955 }
3944 3956
3945 bool Browser::IsPinned(TabContents* source) { 3957 bool Browser::IsPinned(TabContents* source) {
3946 int index = tabstrip_model_.GetIndexOfTabContents(source); 3958 int index = tabstrip_model_.GetIndexOfTabContents(source);
3947 if (index == TabStripModel::kNoTab) { 3959 if (index == TabStripModel::kNoTab) {
3948 NOTREACHED() << "IsPinned called for tab not in our strip"; 3960 NOTREACHED() << "IsPinned called for tab not in our strip";
3949 return false; 3961 return false;
3950 } 3962 }
3951 return tabstrip_model_.IsTabPinned(index); 3963 return tabstrip_model_.IsTabPinned(index);
3952 } 3964 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698