diff options
author | nbegley <nbegley@google.com> | 2015-04-09 15:37:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-09 22:38:26 +0000 |
commit | 0a93e2940da1f112af4994d3680fcc57be06a595 (patch) | |
tree | bcfe3c4e9b854305b63b70139ca5a3f1eb27c6d6 /chromecast | |
parent | c0b2fa5d0ad1a266234240d9fac20be93b5ca0fc (diff) | |
download | chromium_src-0a93e2940da1f112af4994d3680fcc57be06a595.zip chromium_src-0a93e2940da1f112af4994d3680fcc57be06a595.tar.gz chromium_src-0a93e2940da1f112af4994d3680fcc57be06a595.tar.bz2 |
Replace file access def checks with a switch check.
Instead of checking ANDROID_OS defininition, check the
kEnableLocalFileAccesses chromecast switch.
BUG=20032653
Review URL: https://codereview.chromium.org/1070353002
Cr-Commit-Position: refs/heads/master@{#324527}
Diffstat (limited to 'chromecast')
-rw-r--r-- | chromecast/browser/cast_content_browser_client.cc | 9 | ||||
-rw-r--r-- | chromecast/browser/cast_network_delegate.cc | 2 | ||||
-rw-r--r-- | chromecast/browser/url_request_context_factory.cc | 21 | ||||
-rw-r--r-- | chromecast/common/chromecast_switches.cc | 2 | ||||
-rw-r--r-- | chromecast/common/chromecast_switches.h | 2 |
5 files changed, 18 insertions, 18 deletions
diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc index 9fe57ce..fc25b1b 100644 --- a/chromecast/browser/cast_content_browser_client.cc +++ b/chromecast/browser/cast_content_browser_client.cc @@ -106,9 +106,6 @@ bool CastContentBrowserClient::IsHandledURL(const GURL& url) { content::kChromeUIScheme, content::kChromeDevToolsScheme, url::kDataScheme, -#if defined(OS_ANDROID) - url::kFileScheme, -#endif // defined(OS_ANDROID) }; const std::string& scheme = url.scheme(); @@ -116,6 +113,12 @@ bool CastContentBrowserClient::IsHandledURL(const GURL& url) { if (scheme == kProtocolList[i]) return true; } + + if (scheme == url::kFileScheme) { + return base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableLocalFileAccesses); + } + return false; } diff --git a/chromecast/browser/cast_network_delegate.cc b/chromecast/browser/cast_network_delegate.cc index ff0fcc9..cc3e893 100644 --- a/chromecast/browser/cast_network_delegate.cc +++ b/chromecast/browser/cast_network_delegate.cc @@ -20,13 +20,11 @@ CastNetworkDelegate::~CastNetworkDelegate() { bool CastNetworkDelegate::OnCanAccessFile(const net::URLRequest& request, const base::FilePath& path) const { -#if defined(OS_ANDROID) // On Chromecast, there's no reason to allow local file access. if (base::CommandLine::ForCurrentProcess()-> HasSwitch(switches::kEnableLocalFileAccesses)) { return true; } -#endif // defined(OS_ANDROID) LOG(WARNING) << "Could not access file " << path.value() << ". All file accesses are forbidden."; diff --git a/chromecast/browser/url_request_context_factory.cc b/chromecast/browser/url_request_context_factory.cc index 5ac347b..1337fc8 100644 --- a/chromecast/browser/url_request_context_factory.cc +++ b/chromecast/browser/url_request_context_factory.cc @@ -10,6 +10,7 @@ #include "base/threading/worker_pool.h" #include "chromecast/browser/cast_http_user_agent_settings.h" #include "chromecast/browser/cast_network_delegate.h" +#include "chromecast/common/chromecast_switches.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cookie_store_factory.h" @@ -242,15 +243,17 @@ void URLRequestContextFactory::InitializeMainContextDependencies( url::kDataScheme, new net::DataProtocolHandler); DCHECK(set_protocol); -#if defined(OS_ANDROID) - set_protocol = job_factory->SetProtocolHandler( - url::kFileScheme, - new net::FileProtocolHandler( - content::BrowserThread::GetBlockingPool()-> - GetTaskRunnerWithShutdownBehavior( - base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); - DCHECK(set_protocol); -#endif // defined(OS_ANDROID) + + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableLocalFileAccesses)) { + set_protocol = job_factory->SetProtocolHandler( + url::kFileScheme, + new net::FileProtocolHandler( + content::BrowserThread::GetBlockingPool()-> + GetTaskRunnerWithShutdownBehavior( + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); + DCHECK(set_protocol); + } // Set up interceptors in the reverse order. scoped_ptr<net::URLRequestJobFactory> top_job_factory = job_factory.Pass(); diff --git a/chromecast/common/chromecast_switches.cc b/chromecast/common/chromecast_switches.cc index fe16627..29068ec 100644 --- a/chromecast/common/chromecast_switches.cc +++ b/chromecast/common/chromecast_switches.cc @@ -12,10 +12,8 @@ const char kEnableCmaMediaPipeline[] = "enable-cma-media-pipeline"; // The bitmask of codecs (media_caps.h) supported by the current HDMI sink. const char kHdmiSinkSupportedCodecs[] = "hdmi-sink-supported-codecs"; -#if defined(OS_ANDROID) // Enable file accesses for debug. const char kEnableLocalFileAccesses[] = "enable-local-file-accesses"; -#endif // defined(OS_ANDROID) // Override the URL to which metrics logs are sent for debugging. const char kOverrideMetricsUploadUrl[] = "override-metrics-upload-url"; diff --git a/chromecast/common/chromecast_switches.h b/chromecast/common/chromecast_switches.h index 5840d45..697a8a1 100644 --- a/chromecast/common/chromecast_switches.h +++ b/chromecast/common/chromecast_switches.h @@ -13,10 +13,8 @@ namespace switches { extern const char kEnableCmaMediaPipeline[]; extern const char kHdmiSinkSupportedCodecs[]; -#if defined(OS_ANDROID) // Content-implementation switches extern const char kEnableLocalFileAccesses[]; -#endif // defined(OS_ANDROID) // Metrics switches extern const char kOverrideMetricsUploadUrl[]; |