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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 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/views/ash/chrome_shell_delegate.h" 5 #include "chrome/browser/ui/views/ash/chrome_shell_delegate.h"
6 6
7 #include "ash/launcher/launcher_types.h" 7 #include "ash/launcher/launcher_types.h"
8 #include "ash/system/tray/system_tray_delegate.h" 8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "ash/wm/partial_screenshot_view.h" 9 #include "ash/wm/partial_screenshot_view.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
(...skipping 30 matching lines...) Expand all
41 #include "chrome/browser/chromeos/login/webui_login_display_host.h" 41 #include "chrome/browser/chromeos/login/webui_login_display_host.h"
42 #include "chrome/browser/chromeos/login/user_manager.h" 42 #include "chrome/browser/chromeos/login/user_manager.h"
43 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" 43 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h"
44 #include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h" 44 #include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h"
45 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 45 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
46 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" 46 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
47 #include "chromeos/dbus/dbus_thread_manager.h" 47 #include "chromeos/dbus/dbus_thread_manager.h"
48 #include "chromeos/dbus/power_manager_client.h" 48 #include "chromeos/dbus/power_manager_client.h"
49 #endif 49 #endif
50 50
51 namespace {
52
53 // Returns the browser that should handle accelerators.
54 Browser* GetTargetBrowser() {
55 Browser* browser = browser::FindBrowserWithWindow(ash::wm::GetActiveWindow());
56 if (browser)
57 return browser;
58 return browser::FindOrCreateTabbedBrowser(
59 ProfileManager::GetDefaultProfileOrOffTheRecord());
60 }
61
62 } // namespace
63
51 // static 64 // static
52 ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL; 65 ChromeShellDelegate* ChromeShellDelegate::instance_ = NULL;
53 66
54 ChromeShellDelegate::ChromeShellDelegate() 67 ChromeShellDelegate::ChromeShellDelegate()
55 : window_positioner_(new WindowPositioner()), 68 : window_positioner_(new WindowPositioner()),
56 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 69 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
57 instance_ = this; 70 instance_ = this;
58 #if defined(OS_CHROMEOS) 71 #if defined(OS_CHROMEOS)
59 registrar_.Add( 72 registrar_.Add(
60 this, 73 this,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 125 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
113 RequestShutdown(); 126 RequestShutdown();
114 #endif 127 #endif
115 } 128 }
116 129
117 void ChromeShellDelegate::Exit() { 130 void ChromeShellDelegate::Exit() {
118 browser::AttemptUserExit(); 131 browser::AttemptUserExit();
119 } 132 }
120 133
121 void ChromeShellDelegate::NewTab() { 134 void ChromeShellDelegate::NewTab() {
122 Browser* browser = browser::FindOrCreateTabbedBrowser( 135 Browser* browser = GetTargetBrowser();
123 ProfileManager::GetDefaultProfileOrOffTheRecord());
124 browser->NewTab(); 136 browser->NewTab();
125 browser->window()->Show(); 137 browser->window()->Show();
126 } 138 }
127 139
128 void ChromeShellDelegate::NewWindow(bool is_incognito) { 140 void ChromeShellDelegate::NewWindow(bool is_incognito) {
129 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); 141 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
130 Browser::NewEmptyWindow( 142 Browser::NewEmptyWindow(
131 is_incognito ? profile->GetOffTheRecordProfile() : profile); 143 is_incognito ? profile->GetOffTheRecordProfile() : profile);
132 } 144 }
133 145
134 void ChromeShellDelegate::OpenFileManager() { 146 void ChromeShellDelegate::OpenFileManager() {
135 #if defined(OS_CHROMEOS) 147 #if defined(OS_CHROMEOS)
136 file_manager_util::OpenApplication(); 148 file_manager_util::OpenApplication();
137 #endif 149 #endif
138 } 150 }
139 151
140 void ChromeShellDelegate::OpenCrosh() { 152 void ChromeShellDelegate::OpenCrosh() {
141 #if defined(OS_CHROMEOS) 153 #if defined(OS_CHROMEOS)
142 Browser* browser = browser::FindOrCreateTabbedBrowser( 154 Browser* browser = GetTargetBrowser();
143 ProfileManager::GetDefaultProfileOrOffTheRecord());
144 GURL crosh_url = TerminalExtensionHelper::GetCroshExtensionURL( 155 GURL crosh_url = TerminalExtensionHelper::GetCroshExtensionURL(
145 browser->profile()); 156 browser->profile());
146 if (!crosh_url.is_valid()) 157 if (!crosh_url.is_valid())
147 return; 158 return;
148 browser->OpenURL( 159 browser->OpenURL(
149 content::OpenURLParams(crosh_url, 160 content::OpenURLParams(crosh_url,
150 content::Referrer(), 161 content::Referrer(),
151 NEW_FOREGROUND_TAB, 162 NEW_FOREGROUND_TAB,
152 content::PAGE_TRANSITION_GENERATED, 163 content::PAGE_TRANSITION_GENERATED,
153 false)); 164 false));
154 #endif 165 #endif
155 } 166 }
156 167
157 void ChromeShellDelegate::OpenMobileSetup(const std::string& service_path) { 168 void ChromeShellDelegate::OpenMobileSetup(const std::string& service_path) {
158 #if defined(OS_CHROMEOS) 169 #if defined(OS_CHROMEOS)
159 Browser* browser = browser::FindOrCreateTabbedBrowser( 170 Browser* browser = GetTargetBrowser();
160 ProfileManager::GetDefaultProfileOrOffTheRecord());
161 if (CommandLine::ForCurrentProcess()->HasSwitch( 171 if (CommandLine::ForCurrentProcess()->HasSwitch(
162 switches::kEnableMobileSetupDialog)) { 172 switches::kEnableMobileSetupDialog)) {
163 MobileSetupDialog::Show(service_path); 173 MobileSetupDialog::Show(service_path);
164 } else { 174 } else {
165 std::string url(chrome::kChromeUIMobileSetupURL); 175 std::string url(chrome::kChromeUIMobileSetupURL);
166 url.append(service_path); 176 url.append(service_path);
167 browser->OpenURL( 177 browser->OpenURL(
168 content::OpenURLParams(GURL(url), 178 content::OpenURLParams(GURL(url),
169 content::Referrer(), 179 content::Referrer(),
170 NEW_FOREGROUND_TAB, 180 NEW_FOREGROUND_TAB,
171 content::PAGE_TRANSITION_LINK, 181 content::PAGE_TRANSITION_LINK,
172 false)); 182 false));
173 browser->window()->Activate(); 183 browser->window()->Activate();
174 } 184 }
175 #endif 185 #endif
176 } 186 }
177 187
178 void ChromeShellDelegate::RestoreTab() { 188 void ChromeShellDelegate::RestoreTab() {
179 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); 189 Browser* browser = GetTargetBrowser();
190 // Do not restore tabs while in the incognito mode.
191 if (browser->profile()->IsOffTheRecord())
192 return;
180 TabRestoreService* service = 193 TabRestoreService* service =
181 TabRestoreServiceFactory::GetForProfile(profile); 194 TabRestoreServiceFactory::GetForProfile(browser->profile());
182 if (!service) 195 if (!service)
183 return; 196 return;
184 if (service->IsLoaded()) { 197 if (service->IsLoaded()) {
185 Browser* browser = browser::FindOrCreateTabbedBrowser(profile);
186 browser->RestoreTab(); 198 browser->RestoreTab();
187 } else { 199 } else {
188 service->LoadTabsFromLastSession(); 200 service->LoadTabsFromLastSession();
189 // LoadTabsFromLastSession is asynchronous, so TabRestoreService has not 201 // LoadTabsFromLastSession is asynchronous, so TabRestoreService has not
190 // finished loading the entries at this point. Wait for next event cycle 202 // finished loading the entries at this point. Wait for next event cycle
191 // which loads the restored tab entries. 203 // which loads the restored tab entries.
192 MessageLoop::current()->PostTask( 204 MessageLoop::current()->PostTask(
193 FROM_HERE, 205 FROM_HERE,
194 base::Bind(&ChromeShellDelegate::RestoreTab, 206 base::Bind(&ChromeShellDelegate::RestoreTab,
195 weak_factory_.GetWeakPtr())); 207 weak_factory_.GetWeakPtr()));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 ash::Shell::GetInstance()->CreateLauncher(); 285 ash::Shell::GetInstance()->CreateLauncher();
274 break; 286 break;
275 default: 287 default:
276 NOTREACHED() << "Unexpected notification " << type; 288 NOTREACHED() << "Unexpected notification " << type;
277 } 289 }
278 #else 290 #else
279 // MSVC++ warns about switch statements without any cases. 291 // MSVC++ warns about switch statements without any cases.
280 NOTREACHED() << "Unexpected notification " << type; 292 NOTREACHED() << "Unexpected notification " << type;
281 #endif 293 #endif
282 } 294 }
OLDNEW
« 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