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

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

Issue 10967003: Add desktop type context to most existing instances of FindTabbedBrowser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pre-review pass. Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/browser_commands.h" 5 #include "chrome/browser/ui/browser_commands.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_editor.h" 10 #include "chrome/browser/bookmarks/bookmark_editor.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 browser->window()->Show(); 276 browser->window()->Show();
277 return browser; 277 return browser;
278 } 278 }
279 279
280 void OpenWindowWithRestoredTabs(Profile* profile) { 280 void OpenWindowWithRestoredTabs(Profile* profile) {
281 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); 281 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile);
282 if (service) 282 if (service)
283 service->RestoreMostRecentEntry(NULL); 283 service->RestoreMostRecentEntry(NULL);
284 } 284 }
285 285
286 void OpenURLOffTheRecord(Profile* profile, const GURL& url) { 286 void OpenURLOffTheRecord(Profile* profile,
287 const GURL& url,
288 chrome::HostDesktopType desktop_type) {
287 Browser* browser = browser::FindOrCreateTabbedBrowser( 289 Browser* browser = browser::FindOrCreateTabbedBrowser(
288 profile->GetOffTheRecordProfile()); 290 profile->GetOffTheRecordProfile(), desktop_type);
289 AddSelectedTabWithURL(browser, url, content::PAGE_TRANSITION_LINK); 291 AddSelectedTabWithURL(browser, url, content::PAGE_TRANSITION_LINK);
290 browser->window()->Show(); 292 browser->window()->Show();
291 } 293 }
292 294
293 bool CanGoBack(const Browser* browser) { 295 bool CanGoBack(const Browser* browser) {
294 return GetActiveWebContents(browser)->GetController().CanGoBack(); 296 return GetActiveWebContents(browser)->GetController().CanGoBack();
295 } 297 }
296 298
297 void GoBack(Browser* browser, WindowOpenDisposition disposition) { 299 void GoBack(Browser* browser, WindowOpenDisposition disposition) {
298 content::RecordAction(UserMetricsAction("Back")); 300 content::RecordAction(UserMetricsAction("Back"));
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // TODO(asvitkine): This is invoked programmatically from several places. 429 // TODO(asvitkine): This is invoked programmatically from several places.
428 // Audit the code and change it so that the histogram only gets collected for 430 // Audit the code and change it so that the histogram only gets collected for
429 // user-initiated commands. 431 // user-initiated commands.
430 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_COMMAND, 432 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_COMMAND,
431 TabStripModel::NEW_TAB_ENUM_COUNT); 433 TabStripModel::NEW_TAB_ENUM_COUNT);
432 434
433 if (browser->is_type_tabbed()) { 435 if (browser->is_type_tabbed()) {
434 AddBlankTab(browser, true); 436 AddBlankTab(browser, true);
435 GetActiveWebContents(browser)->GetView()->RestoreFocus(); 437 GetActiveWebContents(browser)->GetView()->RestoreFocus();
436 } else { 438 } else {
437 Browser* b = browser::FindOrCreateTabbedBrowser(browser->profile()); 439 Browser* b =
440 browser::FindOrCreateTabbedBrowser(browser->profile(),
441 browser->host_desktop_type());
438 AddBlankTab(b, true); 442 AddBlankTab(b, true);
439 b->window()->Show(); 443 b->window()->Show();
440 // The call to AddBlankTab above did not set the focus to the tab as its 444 // The call to AddBlankTab above did not set the focus to the tab as its
441 // window was not active, so we have to do it explicitly. 445 // window was not active, so we have to do it explicitly.
442 // See http://crbug.com/6380. 446 // See http://crbug.com/6380.
443 GetActiveWebContents(b)->GetView()->RestoreFocus(); 447 GetActiveWebContents(b)->GetView()->RestoreFocus();
444 } 448 }
445 } 449 }
446 450
447 void CloseTab(Browser* browser) { 451 void CloseTab(Browser* browser) {
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 BrowserCommandsTabContentsCreator::CreateTabContents(contents); 1074 BrowserCommandsTabContentsCreator::CreateTabContents(contents);
1071 } 1075 }
1072 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); 1076 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true);
1073 1077
1074 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1078 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1075 contents->GetRenderViewHost()->SyncRendererPrefs(); 1079 contents->GetRenderViewHost()->SyncRendererPrefs();
1076 app_browser->window()->Show(); 1080 app_browser->window()->Show();
1077 } 1081 }
1078 1082
1079 } // namespace chrome 1083 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698