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

Side by Side Diff: chrome/common/chrome_paths_win.cc

Issue 10392094: Add PathService::Get(chrome::DIR_USER_PICTURES). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: merge Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/chrome_paths_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/chrome_paths_internal.h" 5 #include "chrome/common/chrome_paths_internal.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <knownfolders.h> 8 #include <knownfolders.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
11 #include <shobjidl.h> 11 #include <shobjidl.h>
12 12
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/path_service.h"
14 #include "base/win/metro.h" 15 #include "base/win/metro.h"
15 #include "base/path_service.h"
16 #include "base/win/scoped_co_mem.h" 16 #include "base/win/scoped_co_mem.h"
17 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
18 #include "chrome/installer/util/browser_distribution.h" 18 #include "chrome/installer/util/browser_distribution.h"
19 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
20 20
21 namespace chrome { 21 namespace chrome {
22 22
23 bool GetDefaultUserDataDirectory(FilePath* result) { 23 bool GetDefaultUserDataDirectory(FilePath* result) {
24 if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result)) 24 if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result))
25 return false; 25 return false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 GetKnownFolderPath f = reinterpret_cast<GetKnownFolderPath>( 76 GetKnownFolderPath f = reinterpret_cast<GetKnownFolderPath>(
77 GetProcAddress(GetModuleHandle(L"shell32.dll"), "SHGetKnownFolderPath")); 77 GetProcAddress(GetModuleHandle(L"shell32.dll"), "SHGetKnownFolderPath"));
78 base::win::ScopedCoMem<wchar_t> path_buf; 78 base::win::ScopedCoMem<wchar_t> path_buf;
79 if (f && SUCCEEDED(f(FOLDERID_Downloads, 0, NULL, &path_buf))) { 79 if (f && SUCCEEDED(f(FOLDERID_Downloads, 0, NULL, &path_buf))) {
80 *result = FilePath(std::wstring(path_buf)); 80 *result = FilePath(std::wstring(path_buf));
81 return true; 81 return true;
82 } 82 }
83 return GetUserDownloadsDirectorySafe(result); 83 return GetUserDownloadsDirectorySafe(result);
84 } 84 }
85 85
86 bool GetUserPicturesDirectory(FilePath* result) {
87 wchar_t path_buf[MAX_PATH];
88 if (FAILED(SHGetFolderPath(NULL, CSIDL_MYPICTURES, NULL,
89 SHGFP_TYPE_CURRENT, path_buf))) {
90 return false;
91 }
92 *result = FilePath(path_buf);
93 return true;
94 }
95
86 bool GetUserDesktop(FilePath* result) { 96 bool GetUserDesktop(FilePath* result) {
87 // We need to go compute the value. It would be nice to support paths 97 // We need to go compute the value. It would be nice to support paths
88 // with names longer than MAX_PATH, but the system functions don't seem 98 // with names longer than MAX_PATH, but the system functions don't seem
89 // to be designed for it either, with the exception of GetTempPath 99 // to be designed for it either, with the exception of GetTempPath
90 // (but other things will surely break if the temp path is too long, 100 // (but other things will surely break if the temp path is too long,
91 // so we don't bother handling it. 101 // so we don't bother handling it.
92 wchar_t system_buffer[MAX_PATH]; 102 wchar_t system_buffer[MAX_PATH];
93 system_buffer[0] = 0; 103 system_buffer[0] = 0;
94 if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 104 if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL,
95 SHGFP_TYPE_CURRENT, system_buffer))) 105 SHGFP_TYPE_CURRENT, system_buffer))) {
96 return false; 106 return false;
107 }
97 *result = FilePath(system_buffer); 108 *result = FilePath(system_buffer);
98 return true; 109 return true;
99 } 110 }
100 111
101 bool ProcessNeedsProfileDir(const std::string& process_type) { 112 bool ProcessNeedsProfileDir(const std::string& process_type) {
102 // On windows we don't want subprocesses other than the browser process and 113 // On windows we don't want subprocesses other than the browser process and
103 // service processes to be able to use the profile directory because if it 114 // service processes to be able to use the profile directory because if it
104 // lies on a network share the sandbox will prevent us from accessing it. 115 // lies on a network share the sandbox will prevent us from accessing it.
105 // TODO(pastarmovj): For now gpu and plugin broker processes are whitelisted 116 // TODO(pastarmovj): For now gpu and plugin broker processes are whitelisted
106 // too because they do use the profile dir in some way but this must be 117 // too because they do use the profile dir in some way but this must be
107 // investigated and fixed if possible. 118 // investigated and fixed if possible.
108 return process_type.empty() || 119 return process_type.empty() ||
109 process_type == switches::kServiceProcess || 120 process_type == switches::kServiceProcess ||
110 process_type == switches::kGpuProcess || 121 process_type == switches::kGpuProcess ||
111 process_type == switches::kNaClBrokerProcess || 122 process_type == switches::kNaClBrokerProcess ||
112 process_type == switches::kNaClLoaderProcess || 123 process_type == switches::kNaClLoaderProcess ||
113 process_type == switches::kPpapiBrokerProcess; 124 process_type == switches::kPpapiBrokerProcess;
114 } 125 }
115 126
116 } // namespace chrome 127 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/common/chrome_paths_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698