| 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/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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "chrome/browser/chromeos/login/screen_locker.h" | 12 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 13 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h" | 13 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h" |
| 14 #include "chrome/browser/lifetime/application_lifetime.h" | 14 #include "chrome/browser/lifetime/application_lifetime.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/browser/sessions/tab_restore_service.h" |
| 17 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 16 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
| 18 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
| 19 #include "chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h" | 21 #include "chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h" |
| 20 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" | 22 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" |
| 21 #include "chrome/browser/ui/views/ash/window_positioner.h" | 23 #include "chrome/browser/ui/views/ash/window_positioner.h" |
| 22 #include "chrome/browser/ui/views/frame/browser_view.h" | 24 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 content::RecordAction(content::UserMetricsAction("Shutdown")); | 110 content::RecordAction(content::UserMetricsAction("Shutdown")); |
| 109 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 111 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 110 RequestShutdown(); | 112 RequestShutdown(); |
| 111 #endif | 113 #endif |
| 112 } | 114 } |
| 113 | 115 |
| 114 void ChromeShellDelegate::Exit() { | 116 void ChromeShellDelegate::Exit() { |
| 115 browser::AttemptUserExit(); | 117 browser::AttemptUserExit(); |
| 116 } | 118 } |
| 117 | 119 |
| 120 void ChromeShellDelegate::NewTab() { |
| 121 Browser* browser = browser::FindOrCreateTabbedBrowser( |
| 122 ProfileManager::GetDefaultProfileOrOffTheRecord()); |
| 123 browser->NewTab(); |
| 124 browser->window()->Show(); |
| 125 } |
| 126 |
| 118 void ChromeShellDelegate::NewWindow(bool is_incognito) { | 127 void ChromeShellDelegate::NewWindow(bool is_incognito) { |
| 119 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 128 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
| 120 Browser::NewEmptyWindow( | 129 Browser::NewEmptyWindow( |
| 121 is_incognito ? profile->GetOffTheRecordProfile() : profile); | 130 is_incognito ? profile->GetOffTheRecordProfile() : profile); |
| 122 } | 131 } |
| 123 | 132 |
| 124 void ChromeShellDelegate::Search() { | 133 void ChromeShellDelegate::Search() { |
| 125 // Exit fullscreen to show omnibox. | 134 // Exit fullscreen to show omnibox. |
| 126 Browser* last_active = BrowserList::GetLastActive(); | 135 Browser* last_active = BrowserList::GetLastActive(); |
| 127 if (last_active) { | 136 if (last_active) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 content::OpenURLParams(GURL(chrome::kChromeUIMobileSetupURL), | 196 content::OpenURLParams(GURL(chrome::kChromeUIMobileSetupURL), |
| 188 content::Referrer(), | 197 content::Referrer(), |
| 189 NEW_FOREGROUND_TAB, | 198 NEW_FOREGROUND_TAB, |
| 190 content::PAGE_TRANSITION_LINK, | 199 content::PAGE_TRANSITION_LINK, |
| 191 false)); | 200 false)); |
| 192 browser->window()->Activate(); | 201 browser->window()->Activate(); |
| 193 } | 202 } |
| 194 #endif | 203 #endif |
| 195 } | 204 } |
| 196 | 205 |
| 206 void ChromeShellDelegate::RestoreTab() { |
| 207 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
| 208 TabRestoreService* service = |
| 209 TabRestoreServiceFactory::GetForProfile(profile); |
| 210 if (!service) |
| 211 return; |
| 212 if (service->IsLoaded()) { |
| 213 Browser* browser = browser::FindOrCreateTabbedBrowser(profile); |
| 214 browser->RestoreTab(); |
| 215 } else { |
| 216 service->LoadTabsFromLastSession(); |
| 217 // LoadTabsFromLastSession is asynchronous, so TabRestoreService has not |
| 218 // finished loading the entries at this point. Wait for next event cycle |
| 219 // which loads the restored tab entries. |
| 220 MessageLoop::current()->PostTask( |
| 221 FROM_HERE, |
| 222 base::Bind(&ChromeShellDelegate::RestoreTab, |
| 223 weak_factory_.GetWeakPtr())); |
| 224 } |
| 225 } |
| 226 |
| 197 void ChromeShellDelegate::ShowKeyboardOverlay() { | 227 void ChromeShellDelegate::ShowKeyboardOverlay() { |
| 198 #if defined(OS_CHROMEOS) | 228 #if defined(OS_CHROMEOS) |
| 199 KeyboardOverlayDialogView::ShowDialog(); | 229 KeyboardOverlayDialogView::ShowDialog(); |
| 200 #endif | 230 #endif |
| 201 } | 231 } |
| 202 | 232 |
| 233 void ChromeShellDelegate::ShowTaskManager() { |
| 234 Browser* browser = browser::FindOrCreateTabbedBrowser( |
| 235 ProfileManager::GetDefaultProfileOrOffTheRecord()); |
| 236 browser->OpenTaskManager(false); |
| 237 } |
| 238 |
| 203 content::BrowserContext* ChromeShellDelegate::GetCurrentBrowserContext() { | 239 content::BrowserContext* ChromeShellDelegate::GetCurrentBrowserContext() { |
| 204 return ProfileManager::GetDefaultProfile(); | 240 return ProfileManager::GetDefaultProfile(); |
| 205 } | 241 } |
| 206 | 242 |
| 207 void ChromeShellDelegate::ToggleSpokenFeedback() { | 243 void ChromeShellDelegate::ToggleSpokenFeedback() { |
| 208 #if defined(OS_CHROMEOS) | 244 #if defined(OS_CHROMEOS) |
| 209 content::WebUI* login_screen_web_ui = NULL; | 245 content::WebUI* login_screen_web_ui = NULL; |
| 210 chromeos::WebUILoginDisplayHost* host = | 246 chromeos::WebUILoginDisplayHost* host = |
| 211 static_cast<chromeos::WebUILoginDisplayHost*>( | 247 static_cast<chromeos::WebUILoginDisplayHost*>( |
| 212 chromeos::BaseLoginDisplayHost::default_host()); | 248 chromeos::BaseLoginDisplayHost::default_host()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 ash::Shell::GetInstance()->CreateLauncher(); | 297 ash::Shell::GetInstance()->CreateLauncher(); |
| 262 break; | 298 break; |
| 263 default: | 299 default: |
| 264 NOTREACHED() << "Unexpected notification " << type; | 300 NOTREACHED() << "Unexpected notification " << type; |
| 265 } | 301 } |
| 266 #else | 302 #else |
| 267 // MSVC++ warns about switch statements without any cases. | 303 // MSVC++ warns about switch statements without any cases. |
| 268 NOTREACHED() << "Unexpected notification " << type; | 304 NOTREACHED() << "Unexpected notification " << type; |
| 269 #endif | 305 #endif |
| 270 } | 306 } |
| OLD | NEW |