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 "ash/keyboard_overlay/keyboard_overlay_view.h"
8 #include "chrome/browser/chromeos/file_manager/app_id.h"
9 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_util.h"
12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/extensions/application_launch.h"
16 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
17 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
18 #include "chrome/common/url_constants.h"
19 #include "content/public/browser/web_contents.h"
20 #include "extensions/browser/extension_system.h"
22 ChromeNewWindowDelegateChromeos::ChromeNewWindowDelegateChromeos() {}
23 ChromeNewWindowDelegateChromeos::~ChromeNewWindowDelegateChromeos() {}
25 void ChromeNewWindowDelegateChromeos::OpenFileManager() {
26 using file_manager::kFileManagerAppId
;
27 Profile
* const profile
= ProfileManager::GetActiveUserProfile();
28 const ExtensionService
* const service
=
29 extensions::ExtensionSystem::Get(profile
)->extension_service();
31 !extensions::util::IsAppLaunchableWithoutEnabling(kFileManagerAppId
,
36 const extensions::Extension
* const extension
=
37 service
->GetInstalledExtension(kFileManagerAppId
);
38 // event_flags = 0 means this invokes the same behavior as the launcher
39 // item is clicked without any keyboard modifiers.
40 OpenApplication(AppLaunchParams(profile
,
43 chrome::HOST_DESKTOP_TYPE_ASH
));
46 void ChromeNewWindowDelegateChromeos::OpenCrosh() {
47 Profile
* profile
= ProfileManager::GetActiveUserProfile();
48 GURL crosh_url
= extensions::TerminalExtensionHelper::GetCroshExtensionURL(
50 if (!crosh_url
.is_valid())
52 chrome::ScopedTabbedBrowserDisplayer
displayer(
54 chrome::HOST_DESKTOP_TYPE_ASH
);
55 Browser
* browser
= displayer
.browser();
56 content::WebContents
* page
= browser
->OpenURL(
57 content::OpenURLParams(crosh_url
,
60 content::PAGE_TRANSITION_GENERATED
,
62 browser
->window()->Show();
63 browser
->window()->Activate();
67 void ChromeNewWindowDelegateChromeos::ShowKeyboardOverlay() {
68 // TODO(mazda): Move the show logic to ash (http://crbug.com/124222).
69 Profile
* profile
= ProfileManager::GetActiveUserProfile();
70 std::string
url(chrome::kChromeUIKeyboardOverlayURL
);
71 ash::KeyboardOverlayView::ShowDialog(profile
,
72 new ChromeWebContentsHandler
,