Merge pull request #1660 from deepak1556/filesysem_patch

browser: create quota permission context to allow quota request
This commit is contained in:
Cheng Zhao 2015-05-20 14:05:53 +08:00
commit b238ac5981
7 changed files with 77 additions and 0 deletions

View file

@ -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");

View file

@ -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"
@ -221,6 +222,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.

View file

@ -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(

View file

@ -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

View file

@ -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_

View file

@ -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',

View file

@ -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()