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

Side by Side Diff: chrome/browser/platform_util_win.cc

Issue 431343002: Experimentally isolate OpenItemViaShell in a utility process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a comment. Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/platform_util.h" 5 #include "chrome/browser/platform_util.h"
6 6
7 #include <commdlg.h> 7 #include <commdlg.h>
8 #include <dwmapi.h> 8 #include <dwmapi.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/metrics/field_trial.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/win/registry.h" 19 #include "base/win/registry.h"
19 #include "base/win/scoped_co_mem.h" 20 #include "base/win/scoped_co_mem.h"
20 #include "base/win/scoped_comptr.h" 21 #include "base/win/scoped_comptr.h"
21 #include "base/win/windows_version.h" 22 #include "base/win/windows_version.h"
22 #include "chrome/browser/lifetime/application_lifetime.h" 23 #include "chrome/browser/lifetime/application_lifetime.h"
23 #include "chrome/browser/ui/host_desktop.h" 24 #include "chrome/browser/ui/host_desktop.h"
25 #include "chrome/common/chrome_utility_messages.h"
24 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/utility_process_host.h"
25 #include "ui/base/win/shell.h" 28 #include "ui/base/win/shell.h"
26 #include "ui/gfx/native_widget_types.h" 29 #include "ui/gfx/native_widget_types.h"
27 #include "url/gurl.h" 30 #include "url/gurl.h"
28 31
29 using content::BrowserThread; 32 using content::BrowserThread;
30 33
31 namespace { 34 namespace {
32 35
33 void ShowItemInFolderOnFileThread(const base::FilePath& full_path) { 36 void ShowItemInFolderOnFileThread(const base::FilePath& full_path) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 171 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
169 base::Bind(&ShowItemInFolderOnFileThread, full_path)); 172 base::Bind(&ShowItemInFolderOnFileThread, full_path));
170 } 173 }
171 174
172 void OpenItem(Profile* profile, const base::FilePath& full_path) { 175 void OpenItem(Profile* profile, const base::FilePath& full_path) {
173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
174 177
175 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) 178 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
176 chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING); 179 chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
177 180
178 BrowserThread::PostTask( 181 if (base::FieldTrialList::FindFullName("IsolateShellOperations") ==
179 BrowserThread::FILE, FROM_HERE, 182 "Enabled") {
180 base::Bind(base::IgnoreResult(&ui::win::OpenItemViaShell), full_path)); 183 base::WeakPtr<content::UtilityProcessHost> utility_process_host(
184 content::UtilityProcessHost::Create(NULL, NULL)->AsWeakPtr());
185 utility_process_host->DisableSandbox();
186 utility_process_host->Send(
187 new ChromeUtilityMsg_OpenItemViaShell(full_path));
188 } else {
189 BrowserThread::PostTask(
190 BrowserThread::FILE,
191 FROM_HERE,
192 base::Bind(base::IgnoreResult(&ui::win::OpenItemViaShell), full_path));
193 }
181 } 194 }
182 195
183 void OpenExternal(Profile* profile, const GURL& url) { 196 void OpenExternal(Profile* profile, const GURL& url) {
184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
185 198
186 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH && 199 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH &&
187 !url.SchemeIsHTTPOrHTTPS()) 200 !url.SchemeIsHTTPOrHTTPS())
188 chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING); 201 chrome::ActivateDesktopHelper(chrome::ASH_KEEP_RUNNING);
189 202
190 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 203 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
(...skipping 17 matching lines...) Expand all
208 ::SetForegroundWindow(window); 221 ::SetForegroundWindow(window);
209 } 222 }
210 223
211 bool IsVisible(gfx::NativeView view) { 224 bool IsVisible(gfx::NativeView view) {
212 // MSVC complains if we don't include != 0. 225 // MSVC complains if we don't include != 0.
213 return ::IsWindowVisible(view) != 0; 226 return ::IsWindowVisible(view) != 0;
214 } 227 }
215 #endif 228 #endif
216 229
217 } // namespace platform_util 230 } // namespace platform_util
OLDNEW
« no previous file with comments | « no previous file | chrome/common/chrome_utility_messages.h » ('j') | chrome/utility/sandboxed_shell_handler_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698