Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / ui / ash / chrome_new_window_delegate_chromeos.cc
blob8aad0a401d942adc9770f233ca529a3e7d3bb8ba
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/chrome_pages.h"
16 #include "chrome/browser/ui/extensions/app_launch_params.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"
23 #include "extensions/common/constants.h"
24 #include "ui/base/window_open_disposition.h"
26 ChromeNewWindowDelegateChromeos::ChromeNewWindowDelegateChromeos() {}
27 ChromeNewWindowDelegateChromeos::~ChromeNewWindowDelegateChromeos() {}
29 void ChromeNewWindowDelegateChromeos::OpenFileManager() {
30 using file_manager::kFileManagerAppId;
31 Profile* const profile = ProfileManager::GetActiveUserProfile();
32 const ExtensionService* const service =
33 extensions::ExtensionSystem::Get(profile)->extension_service();
34 if (!service ||
35 !extensions::util::IsAppLaunchableWithoutEnabling(kFileManagerAppId,
36 profile)) {
37 return;
40 const extensions::Extension* const extension =
41 service->GetInstalledExtension(kFileManagerAppId);
42 OpenApplication(AppLaunchParams(profile, extension, CURRENT_TAB,
43 chrome::HOST_DESKTOP_TYPE_ASH,
44 extensions::SOURCE_KEYBOARD));
47 void ChromeNewWindowDelegateChromeos::OpenGetHelp() {
48 Profile* const profile = ProfileManager::GetActiveUserProfile();
49 chrome::ShowHelpForProfile(
50 profile, chrome::HOST_DESKTOP_TYPE_ASH, chrome::HELP_SOURCE_KEYBOARD);
53 void ChromeNewWindowDelegateChromeos::OpenCrosh() {
54 Profile* profile = ProfileManager::GetActiveUserProfile();
55 GURL crosh_url = extensions::TerminalExtensionHelper::GetCroshExtensionURL(
56 profile);
57 if (!crosh_url.is_valid())
58 return;
59 chrome::ScopedTabbedBrowserDisplayer displayer(
60 profile,
61 chrome::HOST_DESKTOP_TYPE_ASH);
62 Browser* browser = displayer.browser();
63 content::WebContents* page = browser->OpenURL(
64 content::OpenURLParams(crosh_url,
65 content::Referrer(),
66 NEW_FOREGROUND_TAB,
67 ui::PAGE_TRANSITION_GENERATED,
68 false));
69 browser->window()->Show();
70 browser->window()->Activate();
71 page->Focus();
74 void ChromeNewWindowDelegateChromeos::ShowKeyboardOverlay() {
75 // TODO(mazda): Move the show logic to ash (http://crbug.com/124222).
76 Profile* profile = ProfileManager::GetActiveUserProfile();
77 std::string url(chrome::kChromeUIKeyboardOverlayURL);
78 ash::KeyboardOverlayView::ShowDialog(profile,
79 new ChromeWebContentsHandler,
80 GURL(url));