Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/browser/net/chrome_network_delegate.h" | 5 #include "chrome/browser/net/chrome_network_delegate.h" |
| 6 | 6 |
| 7 #include "base/chromeos/chromeos_version.h" | |
|
achuithb
2012/04/19 20:05:56
Shouldn't this be under #if defined(OS_CHROMEOS)?
Greg Spencer (Chromium)
2012/04/19 20:51:17
Whoops. Yep. Done.
| |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/content_settings/cookie_settings.h" | 10 #include "chrome/browser/content_settings/cookie_settings.h" |
| 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 11 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 12 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 12 #include "chrome/browser/extensions/api/proxy/proxy_api.h" | 13 #include "chrome/browser/extensions/api/proxy/proxy_api.h" |
| 13 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 14 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 14 #include "chrome/browser/extensions/extension_event_router_forwarder.h" | 15 #include "chrome/browser/extensions/extension_event_router_forwarder.h" |
| 15 #include "chrome/browser/extensions/extension_info_map.h" | 16 #include "chrome/browser/extensions/extension_info_map.h" |
| 16 #include "chrome/browser/extensions/extension_process_manager.h" | 17 #include "chrome/browser/extensions/extension_process_manager.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 BrowserThread::PostTask( | 298 BrowserThread::PostTask( |
| 298 BrowserThread::UI, FROM_HERE, | 299 BrowserThread::UI, FROM_HERE, |
| 299 base::Bind(&TabSpecificContentSettings::CookieChanged, | 300 base::Bind(&TabSpecificContentSettings::CookieChanged, |
| 300 render_process_id, render_view_id, | 301 render_process_id, render_view_id, |
| 301 request->url(), request->first_party_for_cookies(), | 302 request->url(), request->first_party_for_cookies(), |
| 302 cookie_line, *options, !allow)); | 303 cookie_line, *options, !allow)); |
| 303 } | 304 } |
| 304 | 305 |
| 305 return allow; | 306 return allow; |
| 306 } | 307 } |
| 308 | |
| 309 bool ChromeNetworkDelegate::CanAccessFile(const net::URLRequest* request, | |
| 310 const FilePath& path) { | |
| 311 #if defined(OS_CHROMEOS) | |
| 312 static const char* const kLocalAccessWhiteList[] = { | |
|
achuithb
2012/04/19 20:05:56
Could you please add a comment here stating that w
Greg Spencer (Chromium)
2012/04/19 20:51:17
Done.
| |
| 313 "/home/chronos/user/Downloads", | |
| 314 "/home/chronos/user/log", | |
| 315 "/media", | |
| 316 "/opt/oem", | |
| 317 "/usr/share/chromeos-assets", | |
| 318 "/tmp", | |
| 319 "/var/log", | |
| 320 }; | |
| 321 | |
| 322 // If we're running Chrome for ChromeOS on Linux, we want to allow files | |
| 323 // within the user's Downloads directory. | |
| 324 if (!base::chromeos::IsRunningOnChromeOS()) { | |
| 325 const char* home = getenv("HOME"); | |
|
achuithb
2012/04/19 20:05:56
I think you should just return true here. We only
Greg Spencer (Chromium)
2012/04/19 20:51:17
Done. I do worry a bit that making it act differe
| |
| 326 if (home && strlen(home) > 0) { | |
| 327 FilePath home_path(home); | |
| 328 home_path = home_path.AppendASCII("Downloads"); | |
| 329 if (home_path.IsParent(path)) | |
| 330 return true; | |
| 331 } | |
| 332 } | |
| 333 | |
| 334 for (size_t i = 0; i < arraysize(kLocalAccessWhiteList); ++i) { | |
| 335 const FilePath white_listed_path(kLocalAccessWhiteList[i]); | |
| 336 // FilePath::operator== should probably handle trailing separators. | |
| 337 if (white_listed_path == path.StripTrailingSeparators() || | |
| 338 white_listed_path.IsParent(path)) { | |
| 339 return true; | |
| 340 } | |
| 341 } | |
| 342 return false; | |
| 343 #else // !defined(OS_CHROMEOS) | |
| 344 // On other platforms we allow file:// access by default. | |
| 345 return true; | |
| 346 #endif | |
| 347 } | |
| OLD | NEW |