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

Unified Diff: chrome/renderer/render_view.cc

Issue 3107026: Add IPC plumbing code for FileSystem API's openFileSystem (Closed)
Patch Set: nits fix + rebase Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_view.cc
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 34a0cdb8697a084d49d4c0064484221a82b7260b..2e66fc777c2da5fcf5a7f239e62527b3313d2958 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -98,6 +98,8 @@
#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
@@ -192,6 +194,8 @@ using WebKit::WebDragOperation;
using WebKit::WebDragOperationsMask;
using WebKit::WebEditingAction;
using WebKit::WebFileChooserCompletion;
+using WebKit::WebFileSystem;
+using WebKit::WebFileSystemCallbacks;
using WebKit::WebFindOptions;
using WebKit::WebFormControlElement;
using WebKit::WebFormElement;
@@ -406,6 +410,17 @@ static std::string DetermineTextLanguage(const string16& text) {
return language;
}
+// Holds pending openFileSystem callbacks.
+struct RenderView::PendingOpenFileSystem {
+ explicit PendingOpenFileSystem(WebFileSystemCallbacks* c) : callbacks(c) {
+ }
+ ~PendingOpenFileSystem() {
+ if (callbacks)
+ callbacks->didFail(WebKit::WebFileErrorAbort);
+ }
+ WebFileSystemCallbacks* callbacks;
+};
+
///////////////////////////////////////////////////////////////////////////////
int32 RenderView::next_page_id_ = 1;
@@ -780,6 +795,8 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus)
IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction,
OnAccessibilityDoDefaultAction)
+ IPC_MESSAGE_HANDLER(ViewMsg_OpenFileSystemRequest_Complete,
+ OnOpenFileSystemRequestComplete)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message))
@@ -3366,6 +3383,28 @@ void RenderView::reportFindInPageSelection(int request_id,
false));
}
+void RenderView::openFileSystem(
+ WebFrame* frame,
+ WebFileSystem::Type type,
+ long long size,
+ WebFileSystemCallbacks* callbacks) {
+ scoped_ptr<PendingOpenFileSystem> request(
+ new PendingOpenFileSystem(callbacks));
+
+ WebSecurityOrigin origin = frame->securityOrigin();
+ if (origin.isEmpty())
+ return; // Uninitialized document?
+
+ ViewHostMsg_OpenFileSystemRequest_Params params;
+ params.routing_id = routing_id_;
+ params.request_id = pending_file_system_requests_.Add(request.release());
+ params.origin_url = GURL(origin.toString());
+ params.type = type;
+ params.requested_size = size;
+
+ Send(new ViewHostMsg_OpenFileSystemRequest(params));
+}
+
// webkit_glue::WebPluginPageDelegate -----------------------------------------
webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate(
@@ -5503,3 +5542,17 @@ bool RenderView::IsNonLocalTopLevelNavigation(
}
return false;
}
+
+void RenderView::OnOpenFileSystemRequestComplete(
+ int request_id, bool accepted, const string16& name,
+ const string16& root_path) {
+ PendingOpenFileSystem* request = pending_file_system_requests_.Lookup(
+ request_id);
+ DCHECK(request);
+ if (accepted)
+ request->callbacks->didOpenFileSystem(name, root_path);
+ else
+ request->callbacks->didFail(WebKit::WebFileErrorSecurity);
+ request->callbacks = NULL;
+ pending_file_system_requests_.Remove(request_id);
+}
« no previous file with comments | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698