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/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_finder.h" |
16 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
17 #include "chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h" | 18 #include "chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h" |
18 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" | 19 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" |
19 #include "chrome/browser/ui/views/ash/window_positioner.h" | 20 #include "chrome/browser/ui/views/ash/window_positioner.h" |
20 #include "chrome/browser/ui/views/frame/browser_view.h" | 21 #include "chrome/browser/ui/views/frame/browser_view.h" |
21 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
24 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/user_metrics.h" | 26 #include "content/public/browser/user_metrics.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // ToggleFullscreenMode is asynchronous, so we don't have omnibox | 129 // ToggleFullscreenMode is asynchronous, so we don't have omnibox |
129 // visible at this point. Wait for next event cycle which toggles | 130 // visible at this point. Wait for next event cycle which toggles |
130 // the visibility of omnibox before creating new tab. | 131 // the visibility of omnibox before creating new tab. |
131 MessageLoop::current()->PostTask( | 132 MessageLoop::current()->PostTask( |
132 FROM_HERE, base::Bind(&ChromeShellDelegate::Search, | 133 FROM_HERE, base::Bind(&ChromeShellDelegate::Search, |
133 weak_factory_.GetWeakPtr())); | 134 weak_factory_.GetWeakPtr())); |
134 return; | 135 return; |
135 } | 136 } |
136 } | 137 } |
137 | 138 |
138 Browser* target_browser = Browser::GetOrCreateTabbedBrowser( | 139 Browser* target_browser = browser::FindOrCreateTabbedBrowser( |
139 last_active ? last_active->profile() : | 140 last_active ? last_active->profile() : |
140 ProfileManager::GetDefaultProfileOrOffTheRecord()); | 141 ProfileManager::GetDefaultProfileOrOffTheRecord()); |
141 const GURL& url = target_browser->GetSelectedWebContents() ? | 142 const GURL& url = target_browser->GetSelectedWebContents() ? |
142 target_browser->GetSelectedWebContents()->GetURL() : GURL(); | 143 target_browser->GetSelectedWebContents()->GetURL() : GURL(); |
143 if (url.SchemeIs(chrome::kChromeUIScheme) && | 144 if (url.SchemeIs(chrome::kChromeUIScheme) && |
144 url.host() == chrome::kChromeUINewTabHost) { | 145 url.host() == chrome::kChromeUINewTabHost) { |
145 // If the NTP is showing, focus the omnibox. | 146 // If the NTP is showing, focus the omnibox. |
146 target_browser->window()->SetFocusToLocationBar(true); | 147 target_browser->window()->SetFocusToLocationBar(true); |
147 } else { | 148 } else { |
148 target_browser->NewTab(); | 149 target_browser->NewTab(); |
149 } | 150 } |
150 target_browser->window()->Show(); | 151 target_browser->window()->Show(); |
151 } | 152 } |
152 | 153 |
153 void ChromeShellDelegate::OpenFileManager() { | 154 void ChromeShellDelegate::OpenFileManager() { |
154 #if defined(OS_CHROMEOS) | 155 #if defined(OS_CHROMEOS) |
155 file_manager_util::OpenApplication(); | 156 file_manager_util::OpenApplication(); |
156 #endif | 157 #endif |
157 } | 158 } |
158 | 159 |
159 void ChromeShellDelegate::OpenCrosh() { | 160 void ChromeShellDelegate::OpenCrosh() { |
160 #if defined(OS_CHROMEOS) | 161 #if defined(OS_CHROMEOS) |
161 Browser* browser = Browser::GetOrCreateTabbedBrowser( | 162 Browser* browser = browser::FindOrCreateTabbedBrowser( |
162 ProfileManager::GetDefaultProfileOrOffTheRecord()); | 163 ProfileManager::GetDefaultProfileOrOffTheRecord()); |
163 GURL crosh_url = TerminalExtensionHelper::GetCroshExtensionURL( | 164 GURL crosh_url = TerminalExtensionHelper::GetCroshExtensionURL( |
164 browser->profile()); | 165 browser->profile()); |
165 if (!crosh_url.is_valid()) | 166 if (!crosh_url.is_valid()) |
166 return; | 167 return; |
167 browser->OpenURL( | 168 browser->OpenURL( |
168 content::OpenURLParams(crosh_url, | 169 content::OpenURLParams(crosh_url, |
169 content::Referrer(), | 170 content::Referrer(), |
170 NEW_FOREGROUND_TAB, | 171 NEW_FOREGROUND_TAB, |
171 content::PAGE_TRANSITION_GENERATED, | 172 content::PAGE_TRANSITION_GENERATED, |
172 false)); | 173 false)); |
173 #endif | 174 #endif |
174 } | 175 } |
175 | 176 |
176 void ChromeShellDelegate::OpenMobileSetup() { | 177 void ChromeShellDelegate::OpenMobileSetup() { |
177 #if defined(OS_CHROMEOS) | 178 #if defined(OS_CHROMEOS) |
178 Browser* browser = Browser::GetOrCreateTabbedBrowser( | 179 Browser* browser = browser::FindOrCreateTabbedBrowser( |
179 ProfileManager::GetDefaultProfileOrOffTheRecord()); | 180 ProfileManager::GetDefaultProfileOrOffTheRecord()); |
180 if (CommandLine::ForCurrentProcess()->HasSwitch( | 181 if (CommandLine::ForCurrentProcess()->HasSwitch( |
181 switches::kEnableMobileSetupDialog)) { | 182 switches::kEnableMobileSetupDialog)) { |
182 MobileSetupDialog::Show(); | 183 MobileSetupDialog::Show(); |
183 } else { | 184 } else { |
184 browser->OpenURL( | 185 browser->OpenURL( |
185 content::OpenURLParams(GURL(chrome::kChromeUIMobileSetupURL), | 186 content::OpenURLParams(GURL(chrome::kChromeUIMobileSetupURL), |
186 content::Referrer(), | 187 content::Referrer(), |
187 NEW_FOREGROUND_TAB, | 188 NEW_FOREGROUND_TAB, |
188 content::PAGE_TRANSITION_LINK, | 189 content::PAGE_TRANSITION_LINK, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 ash::Shell::GetInstance()->CreateLauncher(); | 260 ash::Shell::GetInstance()->CreateLauncher(); |
260 break; | 261 break; |
261 default: | 262 default: |
262 NOTREACHED() << "Unexpected notification " << type; | 263 NOTREACHED() << "Unexpected notification " << type; |
263 } | 264 } |
264 #else | 265 #else |
265 // MSVC++ warns about switch statements without any cases. | 266 // MSVC++ warns about switch statements without any cases. |
266 NOTREACHED() << "Unexpected notification " << type; | 267 NOTREACHED() << "Unexpected notification " << type; |
267 #endif | 268 #endif |
268 } | 269 } |
OLD | NEW |