1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h"
7 #include "apps/app_window_registry.h"
8 #include "apps/ui/native_app_window.h"
9 #include "ash/keyboard_overlay/keyboard_overlay_view.h"
10 #include "chrome/browser/chromeos/file_manager/app_id.h"
11 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_util.h"
14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/extensions/application_launch.h"
18 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
19 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
20 #include "chrome/common/url_constants.h"
21 #include "content/public/browser/web_contents.h"
22 #include "extensions/browser/extension_system.h"
24 ChromeNewWindowDelegateChromeos::ChromeNewWindowDelegateChromeos() {}
25 ChromeNewWindowDelegateChromeos::~ChromeNewWindowDelegateChromeos() {}
27 void ChromeNewWindowDelegateChromeos::OpenFileManager() {
28 using file_manager::kFileManagerAppId
;
29 Profile
* const profile
= ProfileManager::GetActiveUserProfile();
30 const ExtensionService
* const service
=
31 extensions::ExtensionSystem::Get(profile
)->extension_service();
33 !extensions::util::IsAppLaunchableWithoutEnabling(kFileManagerAppId
,
38 const extensions::Extension
* const extension
=
39 service
->GetInstalledExtension(kFileManagerAppId
);
40 // event_flags = 0 means this invokes the same behavior as the launcher
41 // item is clicked without any keyboard modifiers.
42 OpenApplication(AppLaunchParams(profile
,
45 chrome::HOST_DESKTOP_TYPE_ASH
));
48 void ChromeNewWindowDelegateChromeos::OpenCrosh() {
49 Profile
* profile
= ProfileManager::GetActiveUserProfile();
50 GURL crosh_url
= extensions::TerminalExtensionHelper::GetCroshExtensionURL(
52 if (!crosh_url
.is_valid())
54 chrome::ScopedTabbedBrowserDisplayer
displayer(
56 chrome::HOST_DESKTOP_TYPE_ASH
);
57 Browser
* browser
= displayer
.browser();
58 content::WebContents
* page
= browser
->OpenURL(
59 content::OpenURLParams(crosh_url
,
62 content::PAGE_TRANSITION_GENERATED
,
64 browser
->window()->Show();
65 browser
->window()->Activate();
69 void ChromeNewWindowDelegateChromeos::ShowKeyboardOverlay() {
70 // TODO(mazda): Move the show logic to ash (http://crbug.com/124222).
71 Profile
* profile
= ProfileManager::GetActiveUserProfile();
72 std::string
url(chrome::kChromeUIKeyboardOverlayURL
);
73 ash::KeyboardOverlayView::ShowDialog(profile
,
74 new ChromeWebContentsHandler
,