From 2785a4cc480fc9cde00fae46bc7d5772f0631d61 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Tue, 12 May 2015 17:52:30 +0530 Subject: [PATCH 1/3] browser: create quota permission context to allow quota request --- atom/browser/atom_browser_client.cc | 7 +++++ atom/browser/atom_browser_client.h | 5 +++ atom/browser/atom_quota_permission_context.cc | 24 ++++++++++++++ atom/browser/atom_quota_permission_context.h | 31 +++++++++++++++++++ filenames.gypi | 2 ++ 5 files changed, 69 insertions(+) create mode 100644 atom/browser/atom_quota_permission_context.cc create mode 100644 atom/browser/atom_quota_permission_context.h diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index fbc09d9fe15f..633cc6accd06 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -7,6 +7,7 @@ #include "atom/browser/atom_access_token_store.h" #include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_main_parts.h" +#include "atom/browser/atom_quota_permission_context.h" #include "atom/browser/atom_resource_dispatcher_host_delegate.h" #include "atom/browser/atom_speech_recognition_manager_delegate.h" #include "atom/browser/native_window.h" @@ -19,6 +20,7 @@ #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h" #include "chrome/browser/speech/tts_message_filter.h" #include "content/public/browser/browser_ppapi_host.h" +#include "content/public/browser/quota_permission_context.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/resource_dispatcher_host.h" @@ -222,6 +224,11 @@ void AtomBrowserClient::DidCreatePpapiPlugin( new chrome::ChromeBrowserPepperHostFactory(browser_host))); } +content::QuotaPermissionContext* + AtomBrowserClient::CreateQuotaPermissionContext() { + return new AtomQuotaPermissionContext; +} + brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts( const content::MainFunctionParams&) { v8::V8::Initialize(); // Init V8 before creating main parts. diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index cc69a1e12de8..6d77eabc5a99 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -9,6 +9,10 @@ #include "brightray/browser/browser_client.h" +namespace content { +class QuotaPermissionContext; +} + namespace atom { class AtomResourceDispatcherHostDelegate; @@ -39,6 +43,7 @@ class AtomBrowserClient : public brightray::BrowserClient { void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) override; void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override; + content::QuotaPermissionContext* CreateQuotaPermissionContext() override; private: brightray::BrowserMainParts* OverrideCreateBrowserMainParts( diff --git a/atom/browser/atom_quota_permission_context.cc b/atom/browser/atom_quota_permission_context.cc new file mode 100644 index 000000000000..8775f950ca9a --- /dev/null +++ b/atom/browser/atom_quota_permission_context.cc @@ -0,0 +1,24 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "atom/browser/atom_quota_permission_context.h" + +#include "storage/common/quota/quota_types.h" + +namespace atom { + +AtomQuotaPermissionContext::AtomQuotaPermissionContext() { +} + +AtomQuotaPermissionContext::~AtomQuotaPermissionContext() { +} + +void AtomQuotaPermissionContext::RequestQuotaPermission( + const content::StorageQuotaParams& params, + int render_process_id, + const PermissionCallback& callback) { + callback.Run(response::QUOTA_PERMISSION_RESPONSE_ALLOW); +} + +} // namespace atom diff --git a/atom/browser/atom_quota_permission_context.h b/atom/browser/atom_quota_permission_context.h new file mode 100644 index 000000000000..1246ea7bad58 --- /dev/null +++ b/atom/browser/atom_quota_permission_context.h @@ -0,0 +1,31 @@ +// Copyright (c) 2015 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef ATOM_BROWSER_ATOM_QUOTA_PERMISSION_CONTEXT_H_ +#define ATOM_BROWSER_ATOM_QUOTA_PERMISSION_CONTEXT_H_ + +#include "content/public/browser/quota_permission_context.h" + +namespace atom { + +class AtomQuotaPermissionContext : public content::QuotaPermissionContext { + public: + typedef content::QuotaPermissionContext::QuotaPermissionResponse response; + + AtomQuotaPermissionContext(); + virtual ~AtomQuotaPermissionContext(); + + // content::QuotaPermissionContext: + void RequestQuotaPermission( + const content::StorageQuotaParams& params, + int render_process_id, + const PermissionCallback& callback) override; + + private: + DISALLOW_COPY_AND_ASSIGN(AtomQuotaPermissionContext); +}; + +} // namespace atom + +#endif // ATOM_BROWSER_ATOM_QUOTA_PERMISSION_CONTEXT_H_ diff --git a/filenames.gypi b/filenames.gypi index ebd1fb41aaf2..c97e39f80ccc 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -114,6 +114,8 @@ 'atom/browser/atom_browser_main_parts_mac.mm', 'atom/browser/atom_javascript_dialog_manager.cc', 'atom/browser/atom_javascript_dialog_manager.h', + 'atom/browser/atom_quota_permission_context.cc', + 'atom/browser/atom_quota_permission_context.h', 'atom/browser/atom_resource_dispatcher_host_delegate.cc', 'atom/browser/atom_resource_dispatcher_host_delegate.h', 'atom/browser/atom_speech_recognition_manager_delegate.cc', From add7f8a4aae7199d942b1f85a4f9a3b2465ef035 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Tue, 12 May 2015 18:03:00 +0530 Subject: [PATCH 2/3] add test --- atom/browser/atom_browser_client.cc | 1 - spec/chromium-spec.coffee | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 633cc6accd06..cf656d4a7cd8 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -20,7 +20,6 @@ #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h" #include "chrome/browser/speech/tts_message_filter.h" #include "content/public/browser/browser_ppapi_host.h" -#include "content/public/browser/quota_permission_context.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/resource_dispatcher_host.h" diff --git a/spec/chromium-spec.coffee b/spec/chromium-spec.coffee index d39183576b40..88a3487cc9d2 100644 --- a/spec/chromium-spec.coffee +++ b/spec/chromium-spec.coffee @@ -82,3 +82,9 @@ describe 'chromium feature', -> iframe.onload = -> assert.equal iframe.contentWindow.test, 'undefined undefined undefined' done() + + describe 'storage', -> + it 'requesting persitent quota works', (done) -> + navigator.webkitPersistentStorage.requestQuota 1024 * 1024, (grantedBytes) -> + assert.equal grantedBytes, 1048576 + done() From 32ba219146c06aac844732aaccef064744a397cf Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Tue, 12 May 2015 18:21:48 +0530 Subject: [PATCH 3/3] allowing file:// URI to access other file:// URIs for filesytem api use --- atom/app/atom_main_delegate.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/atom/app/atom_main_delegate.cc b/atom/app/atom_main_delegate.cc index c9cdc77e1173..e73cc06bc464 100644 --- a/atom/app/atom_main_delegate.cc +++ b/atom/app/atom_main_delegate.cc @@ -78,6 +78,9 @@ void AtomMainDelegate::PreSandboxStartup() { // Disable renderer sandbox for most of node's functions. command_line->AppendSwitch(switches::kNoSandbox); + // Allow file:// URIs to read other file:// URIs by default. + command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); + #if defined(OS_MACOSX) // Enable AVFoundation. command_line->AppendSwitch("enable-avfoundation");