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

Unified Diff: chrome/browser/ui/views/ash/chrome_shell_delegate.cc

Issue 10545025: Open tabs in the incognito window with accelerators when it's active. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/ash/chrome_shell_delegate.cc
diff --git a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
index 33d092d5f5b399ee9f4d9b39a86fbb17b963e15f..108fc112b7043ce7ce9adac8a756ce34cc87485b 100644
--- a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
+++ b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
@@ -48,6 +48,19 @@
#include "chromeos/dbus/power_manager_client.h"
#endif
+namespace {
+
+// Returns the browser that should handle accelerators.
+Browser* GetTargetBrowser() {
+ Browser* browser = browser::FindBrowserWithWindow(ash::wm::GetActiveWindow());
+ if (browser)
+ return browser;
+ return browser::FindOrCreateTabbedBrowser(
+ ProfileManager::GetDefaultProfileOrOffTheRecord());
+}
+
+} // namespace
+
// static
ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL;
@@ -119,8 +132,7 @@ void ChromeShellDelegate::Exit() {
}
void ChromeShellDelegate::NewTab() {
- Browser* browser = browser::FindOrCreateTabbedBrowser(
- ProfileManager::GetDefaultProfileOrOffTheRecord());
+ Browser* browser = GetTargetBrowser();
browser->NewTab();
browser->window()->Show();
}
@@ -139,8 +151,7 @@ void ChromeShellDelegate::OpenFileManager() {
void ChromeShellDelegate::OpenCrosh() {
#if defined(OS_CHROMEOS)
- Browser* browser = browser::FindOrCreateTabbedBrowser(
- ProfileManager::GetDefaultProfileOrOffTheRecord());
+ Browser* browser = GetTargetBrowser();
GURL crosh_url = TerminalExtensionHelper::GetCroshExtensionURL(
browser->profile());
if (!crosh_url.is_valid())
@@ -156,8 +167,7 @@ void ChromeShellDelegate::OpenCrosh() {
void ChromeShellDelegate::OpenMobileSetup(const std::string& service_path) {
#if defined(OS_CHROMEOS)
- Browser* browser = browser::FindOrCreateTabbedBrowser(
- ProfileManager::GetDefaultProfileOrOffTheRecord());
+ Browser* browser = GetTargetBrowser();
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableMobileSetupDialog)) {
MobileSetupDialog::Show(service_path);
@@ -176,13 +186,15 @@ void ChromeShellDelegate::OpenMobileSetup(const std::string& service_path) {
}
void ChromeShellDelegate::RestoreTab() {
- Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
+ Browser* browser = GetTargetBrowser();
+ // Do not restore tabs while in the incognito mode.
+ if (browser->profile()->IsOffTheRecord())
+ return;
TabRestoreService* service =
- TabRestoreServiceFactory::GetForProfile(profile);
+ TabRestoreServiceFactory::GetForProfile(browser->profile());
if (!service)
return;
if (service->IsLoaded()) {
- Browser* browser = browser::FindOrCreateTabbedBrowser(profile);
browser->RestoreTab();
} else {
service->LoadTabsFromLastSession();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698