| OLD | NEW |
| 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_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 void NewEmptyWindow(Profile* profile) { | 304 void NewEmptyWindow(Profile* profile) { |
| 305 NewEmptyWindow(profile, HOST_DESKTOP_TYPE_NATIVE); | 305 NewEmptyWindow(profile, HOST_DESKTOP_TYPE_NATIVE); |
| 306 } | 306 } |
| 307 | 307 |
| 308 Browser* OpenEmptyWindow(Profile* profile, HostDesktopType desktop_type) { | 308 Browser* OpenEmptyWindow(Profile* profile, HostDesktopType desktop_type) { |
| 309 Browser* browser = new Browser( | 309 Browser* browser = new Browser( |
| 310 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); | 310 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); |
| 311 AddBlankTab(browser, true); | 311 AddBlankTabAt(browser, -1, true); |
| 312 browser->window()->Show(); | 312 browser->window()->Show(); |
| 313 return browser; | 313 return browser; |
| 314 } | 314 } |
| 315 | 315 |
| 316 Browser* OpenEmptyWindow(Profile* profile) { | 316 Browser* OpenEmptyWindow(Profile* profile) { |
| 317 return OpenEmptyWindow(profile, HOST_DESKTOP_TYPE_NATIVE); | 317 return OpenEmptyWindow(profile, HOST_DESKTOP_TYPE_NATIVE); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void OpenWindowWithRestoredTabs(Profile* profile) { | 320 void OpenWindowWithRestoredTabs(Profile* profile) { |
| 321 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); | 321 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 | 466 |
| 467 void NewTab(Browser* browser) { | 467 void NewTab(Browser* browser) { |
| 468 content::RecordAction(UserMetricsAction("NewTab")); | 468 content::RecordAction(UserMetricsAction("NewTab")); |
| 469 // TODO(asvitkine): This is invoked programmatically from several places. | 469 // TODO(asvitkine): This is invoked programmatically from several places. |
| 470 // Audit the code and change it so that the histogram only gets collected for | 470 // Audit the code and change it so that the histogram only gets collected for |
| 471 // user-initiated commands. | 471 // user-initiated commands. |
| 472 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_COMMAND, | 472 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_COMMAND, |
| 473 TabStripModel::NEW_TAB_ENUM_COUNT); | 473 TabStripModel::NEW_TAB_ENUM_COUNT); |
| 474 | 474 |
| 475 if (browser->is_type_tabbed()) { | 475 if (browser->is_type_tabbed()) { |
| 476 AddBlankTab(browser, true); | 476 AddBlankTabAt(browser, -1, true); |
| 477 GetActiveWebContents(browser)->GetView()->RestoreFocus(); | 477 GetActiveWebContents(browser)->GetView()->RestoreFocus(); |
| 478 } else { | 478 } else { |
| 479 Browser* b = | 479 Browser* b = |
| 480 browser::FindOrCreateTabbedBrowser(browser->profile(), | 480 browser::FindOrCreateTabbedBrowser(browser->profile(), |
| 481 browser->host_desktop_type()); | 481 browser->host_desktop_type()); |
| 482 AddBlankTab(b, true); | 482 AddBlankTabAt(b, -1, true); |
| 483 b->window()->Show(); | 483 b->window()->Show(); |
| 484 // The call to AddBlankTab above did not set the focus to the tab as its | 484 // The call to AddBlankTabAt above did not set the focus to the tab as its |
| 485 // window was not active, so we have to do it explicitly. | 485 // window was not active, so we have to do it explicitly. |
| 486 // See http://crbug.com/6380. | 486 // See http://crbug.com/6380. |
| 487 GetActiveWebContents(b)->GetView()->RestoreFocus(); | 487 GetActiveWebContents(b)->GetView()->RestoreFocus(); |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 | 490 |
| 491 void CloseTab(Browser* browser) { | 491 void CloseTab(Browser* browser) { |
| 492 content::RecordAction(UserMetricsAction("CloseTab_Accelerator")); | 492 content::RecordAction(UserMetricsAction("CloseTab_Accelerator")); |
| 493 browser->tab_strip_model()->CloseSelectedTabs(); | 493 browser->tab_strip_model()->CloseSelectedTabs(); |
| 494 } | 494 } |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 BrowserCommandsTabContentsCreator::CreateTabContents(contents); | 1084 BrowserCommandsTabContentsCreator::CreateTabContents(contents); |
| 1085 } | 1085 } |
| 1086 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); | 1086 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); |
| 1087 | 1087 |
| 1088 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1088 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1089 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1089 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1090 app_browser->window()->Show(); | 1090 app_browser->window()->Show(); |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 } // namespace chrome | 1093 } // namespace chrome |
| OLD | NEW |