| 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" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 browser->NewTab(); | 125 browser->NewTab(); |
| 126 browser->window()->Show(); | 126 browser->window()->Show(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void ChromeShellDelegate::NewWindow(bool is_incognito) { | 129 void ChromeShellDelegate::NewWindow(bool is_incognito) { |
| 130 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 130 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
| 131 Browser::NewEmptyWindow( | 131 Browser::NewEmptyWindow( |
| 132 is_incognito ? profile->GetOffTheRecordProfile() : profile); | 132 is_incognito ? profile->GetOffTheRecordProfile() : profile); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ChromeShellDelegate::Search() { | |
| 136 // Exit fullscreen to show omnibox. | |
| 137 Browser* last_active = BrowserList::GetLastActive(); | |
| 138 if (last_active) { | |
| 139 if (last_active->window()->IsFullscreen()) { | |
| 140 last_active->ToggleFullscreenMode(); | |
| 141 // ToggleFullscreenMode is asynchronous, so we don't have omnibox | |
| 142 // visible at this point. Wait for next event cycle which toggles | |
| 143 // the visibility of omnibox before creating new tab. | |
| 144 MessageLoop::current()->PostTask( | |
| 145 FROM_HERE, base::Bind(&ChromeShellDelegate::Search, | |
| 146 weak_factory_.GetWeakPtr())); | |
| 147 return; | |
| 148 } | |
| 149 } | |
| 150 | |
| 151 Browser* target_browser = browser::FindOrCreateTabbedBrowser( | |
| 152 last_active ? last_active->profile() : | |
| 153 ProfileManager::GetDefaultProfileOrOffTheRecord()); | |
| 154 const GURL& url = target_browser->GetSelectedWebContents() ? | |
| 155 target_browser->GetSelectedWebContents()->GetURL() : GURL(); | |
| 156 if (url.SchemeIs(chrome::kChromeUIScheme) && | |
| 157 url.host() == chrome::kChromeUINewTabHost) { | |
| 158 // If the NTP is showing, focus the omnibox. | |
| 159 target_browser->window()->SetFocusToLocationBar(true); | |
| 160 } else { | |
| 161 target_browser->NewTab(); | |
| 162 } | |
| 163 target_browser->window()->Show(); | |
| 164 } | |
| 165 | |
| 166 void ChromeShellDelegate::OpenFileManager() { | 135 void ChromeShellDelegate::OpenFileManager() { |
| 167 #if defined(OS_CHROMEOS) | 136 #if defined(OS_CHROMEOS) |
| 168 file_manager_util::OpenApplication(); | 137 file_manager_util::OpenApplication(); |
| 169 #endif | 138 #endif |
| 170 } | 139 } |
| 171 | 140 |
| 172 void ChromeShellDelegate::OpenCrosh() { | 141 void ChromeShellDelegate::OpenCrosh() { |
| 173 #if defined(OS_CHROMEOS) | 142 #if defined(OS_CHROMEOS) |
| 174 Browser* browser = browser::FindOrCreateTabbedBrowser( | 143 Browser* browser = browser::FindOrCreateTabbedBrowser( |
| 175 ProfileManager::GetDefaultProfileOrOffTheRecord()); | 144 ProfileManager::GetDefaultProfileOrOffTheRecord()); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 ash::Shell::GetInstance()->CreateLauncher(); | 274 ash::Shell::GetInstance()->CreateLauncher(); |
| 306 break; | 275 break; |
| 307 default: | 276 default: |
| 308 NOTREACHED() << "Unexpected notification " << type; | 277 NOTREACHED() << "Unexpected notification " << type; |
| 309 } | 278 } |
| 310 #else | 279 #else |
| 311 // MSVC++ warns about switch statements without any cases. | 280 // MSVC++ warns about switch statements without any cases. |
| 312 NOTREACHED() << "Unexpected notification " << type; | 281 NOTREACHED() << "Unexpected notification " << type; |
| 313 #endif | 282 #endif |
| 314 } | 283 } |
| OLD | NEW |