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" | 16 #include "chrome/browser/sessions/tab_restore_service.h" |
17 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 17 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
20 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
mazda
2012/06/08 16:57:57
This can be removed.
xiyuan
2012/06/08 17:09:18
Right. Good catch.
| |
21 #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" |
22 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" | 22 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" |
23 #include "chrome/browser/ui/views/ash/user_action_handler.h" | 23 #include "chrome/browser/ui/views/ash/user_action_handler.h" |
24 #include "chrome/browser/ui/views/ash/window_positioner.h" | 24 #include "chrome/browser/ui/views/ash/window_positioner.h" |
25 #include "chrome/browser/ui/views/frame/browser_view.h" | 25 #include "chrome/browser/ui/views/frame/browser_view.h" |
26 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
29 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/user_metrics.h" | 30 #include "content/public/browser/user_metrics.h" |
(...skipping 94 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 |