Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: chrome/browser/ui/ash/chrome_new_window_delegate.cc

Issue 1960293003: Remove OS_CHROMEOS from ui/ash code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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/ash/chrome_new_window_delegate.h" 5 #include "chrome/browser/ui/ash/chrome_new_window_delegate.h"
6 6
7 #include "ash/content/keyboard_overlay/keyboard_overlay_view.h"
7 #include "ash/wm/window_util.h" 8 #include "ash/wm/window_util.h"
8 #include "base/macros.h" 9 #include "base/macros.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"
9 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/sessions/tab_restore_service_factory.h" 15 #include "chrome/browser/sessions/tab_restore_service_factory.h"
11 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" 16 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
12 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_commands.h" 18 #include "chrome/browser/ui/browser_commands.h"
14 #include "chrome/browser/ui/browser_finder.h" 19 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/browser_window.h" 20 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/browser/ui/chrome_pages.h"
22 #include "chrome/browser/ui/extensions/app_launch_params.h"
23 #include "chrome/browser/ui/extensions/application_launch.h"
16 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 24 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
25 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
26 #include "chrome/common/url_constants.h"
17 #include "components/sessions/core/tab_restore_service.h" 27 #include "components/sessions/core/tab_restore_service.h"
18 #include "components/sessions/core/tab_restore_service_observer.h" 28 #include "components/sessions/core/tab_restore_service_observer.h"
29 #include "content/public/browser/web_contents.h"
30 #include "extensions/browser/extension_system.h"
31 #include "extensions/common/constants.h"
32 #include "ui/base/window_open_disposition.h"
19 33
20 namespace { 34 namespace {
21 35
22 void RestoreTabUsingProfile(Profile* profile) { 36 void RestoreTabUsingProfile(Profile* profile) {
23 sessions::TabRestoreService* service = 37 sessions::TabRestoreService* service =
24 TabRestoreServiceFactory::GetForProfile(profile); 38 TabRestoreServiceFactory::GetForProfile(profile);
25 service->RestoreMostRecentEntry(nullptr); 39 service->RestoreMostRecentEntry(nullptr);
26 } 40 }
27 41
28 // Returns the browser for the active window, if any. 42 // Returns the browser for the active window, if any.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 112
99 void ChromeNewWindowDelegate::NewWindow(bool is_incognito) { 113 void ChromeNewWindowDelegate::NewWindow(bool is_incognito) {
100 Browser* browser = GetBrowserForActiveWindow(); 114 Browser* browser = GetBrowserForActiveWindow();
101 Profile* profile = (browser && browser->profile()) 115 Profile* profile = (browser && browser->profile())
102 ? browser->profile()->GetOriginalProfile() 116 ? browser->profile()->GetOriginalProfile()
103 : ProfileManager::GetActiveUserProfile(); 117 : ProfileManager::GetActiveUserProfile();
104 chrome::NewEmptyWindow(is_incognito ? profile->GetOffTheRecordProfile() 118 chrome::NewEmptyWindow(is_incognito ? profile->GetOffTheRecordProfile()
105 : profile); 119 : profile);
106 } 120 }
107 121
122 void ChromeNewWindowDelegate::OpenFileManager() {
123 using file_manager::kFileManagerAppId;
124 Profile* const profile = ProfileManager::GetActiveUserProfile();
125 const ExtensionService* const service =
126 extensions::ExtensionSystem::Get(profile)->extension_service();
127 if (!service ||
128 !extensions::util::IsAppLaunchableWithoutEnabling(kFileManagerAppId,
129 profile)) {
130 return;
131 }
132
133 const extensions::Extension* const extension =
134 service->GetInstalledExtension(kFileManagerAppId);
135 OpenApplication(CreateAppLaunchParamsUserContainer(
136 profile, extension, NEW_FOREGROUND_TAB, extensions::SOURCE_KEYBOARD));
137 }
138
139 void ChromeNewWindowDelegate::OpenCrosh() {
140 Profile* profile = ProfileManager::GetActiveUserProfile();
141 GURL crosh_url =
142 extensions::TerminalExtensionHelper::GetCroshExtensionURL(profile);
143 if (!crosh_url.is_valid())
144 return;
145 chrome::ScopedTabbedBrowserDisplayer displayer(profile);
146 Browser* browser = displayer.browser();
147 content::WebContents* page = browser->OpenURL(
148 content::OpenURLParams(crosh_url, content::Referrer(), NEW_FOREGROUND_TAB,
149 ui::PAGE_TRANSITION_GENERATED, false));
150 browser->window()->Show();
151 browser->window()->Activate();
152 page->Focus();
153 }
154
155 void ChromeNewWindowDelegate::OpenGetHelp() {
156 Profile* const profile = ProfileManager::GetActiveUserProfile();
157 chrome::ShowHelpForProfile(profile, chrome::HELP_SOURCE_KEYBOARD);
158 }
159
108 void ChromeNewWindowDelegate::RestoreTab() { 160 void ChromeNewWindowDelegate::RestoreTab() {
109 if (tab_restore_helper_.get()) { 161 if (tab_restore_helper_.get()) {
110 DCHECK(!tab_restore_helper_->tab_restore_service()->IsLoaded()); 162 DCHECK(!tab_restore_helper_->tab_restore_service()->IsLoaded());
111 return; 163 return;
112 } 164 }
113 165
114 Browser* browser = GetBrowserForActiveWindow(); 166 Browser* browser = GetBrowserForActiveWindow();
115 Profile* profile = browser ? browser->profile() : NULL; 167 Profile* profile = browser ? browser->profile() : NULL;
116 if (!profile) 168 if (!profile)
117 profile = ProfileManager::GetActiveUserProfile(); 169 profile = ProfileManager::GetActiveUserProfile();
118 if (profile->IsOffTheRecord()) 170 if (profile->IsOffTheRecord())
119 return; 171 return;
120 sessions::TabRestoreService* service = 172 sessions::TabRestoreService* service =
121 TabRestoreServiceFactory::GetForProfile(profile); 173 TabRestoreServiceFactory::GetForProfile(profile);
122 if (!service) 174 if (!service)
123 return; 175 return;
124 176
125 if (service->IsLoaded()) { 177 if (service->IsLoaded()) {
126 RestoreTabUsingProfile(profile); 178 RestoreTabUsingProfile(profile);
127 } else { 179 } else {
128 tab_restore_helper_.reset(new TabRestoreHelper(this, profile, service)); 180 tab_restore_helper_.reset(new TabRestoreHelper(this, profile, service));
129 service->LoadTabsFromLastSession(); 181 service->LoadTabsFromLastSession();
130 } 182 }
131 } 183 }
132 184
185 void ChromeNewWindowDelegate::ShowKeyboardOverlay() {
186 // TODO(mazda): Move the show logic to ash (http://crbug.com/124222).
187 Profile* profile = ProfileManager::GetActiveUserProfile();
188 std::string url(chrome::kChromeUIKeyboardOverlayURL);
189 ash::KeyboardOverlayView::ShowDialog(profile, new ChromeWebContentsHandler,
190 GURL(url));
191 }
192
133 void ChromeNewWindowDelegate::ShowTaskManager() { 193 void ChromeNewWindowDelegate::ShowTaskManager() {
134 chrome::OpenTaskManager(NULL); 194 chrome::OpenTaskManager(NULL);
135 } 195 }
136 196
137 void ChromeNewWindowDelegate::OpenFeedbackPage() { 197 void ChromeNewWindowDelegate::OpenFeedbackPage() {
138 chrome::OpenFeedbackDialog(GetBrowserForActiveWindow()); 198 chrome::OpenFeedbackDialog(GetBrowserForActiveWindow());
139 } 199 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/chrome_new_window_delegate.h ('k') | chrome/browser/ui/ash/chrome_new_window_delegate_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698