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

Side by Side Diff: chrome/browser/guest_view/web_view/web_view_guest.cc

Issue 338353007: Implementation of shared worker code path for WebView file system permission. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_sharedworker
Patch Set: Rename + changes are made. Created 6 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/guest_view/web_view/web_view_guest.h" 5 #include "chrome/browser/guest_view/web_view/web_view_guest.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, 881 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
882 GURL(), 882 GURL(),
883 content::StoragePartition::OriginMatcherFunction(), 883 content::StoragePartition::OriginMatcherFunction(),
884 remove_since, 884 remove_since,
885 base::Time::Now(), 885 base::Time::Now(),
886 callback); 886 callback);
887 return true; 887 return true;
888 } 888 }
889 889
890 // static 890 // static
891 void WebViewGuest::FileSystemAccessedAsync(int render_process_id, 891 void WebViewGuest::FileSystemAccessed(int render_process_id,
892 int render_frame_id, 892 int render_frame_id,
893 int request_id, 893 const GURL& url,
894 const GURL& url, 894 bool blocked_by_policy,
895 bool blocked_by_policy) { 895 base::Callback<void(bool)> callback) {
896 WebViewGuest* guest = 896 WebViewGuest* guest =
897 WebViewGuest::FromFrameID(render_process_id, render_frame_id); 897 WebViewGuest::FromFrameID(render_process_id, render_frame_id);
898 DCHECK(guest); 898 DCHECK(guest);
899 guest->RequestFileSystemPermission( 899 guest->RequestFileSystemPermission(
900 url, 900 url,
901 !blocked_by_policy, 901 !blocked_by_policy,
902 base::Bind(&WebViewGuest::FileSystemAccessedAsyncResponse, 902 base::Bind(&WebViewGuest::FileSystemAccessedResponse,
903 render_process_id, 903 render_process_id,
904 render_frame_id, 904 render_frame_id,
905 request_id, 905 url,
906 url)); 906 callback));
907 } 907 }
908 908
909 // static 909 // static
910 void WebViewGuest::FileSystemAccessedAsyncResponse(int render_process_id, 910 void WebViewGuest::FileSystemAccessedResponse(
911 int render_frame_id, 911 int render_process_id,
912 int request_id, 912 int render_frame_id,
913 const GURL& url, 913 const GURL& url,
914 bool allowed) { 914 base::Callback<void(bool)> callback,
915 bool allowed) {
915 TabSpecificContentSettings::FileSystemAccessed( 916 TabSpecificContentSettings::FileSystemAccessed(
916 render_process_id, render_frame_id, url, !allowed); 917 render_process_id, render_frame_id, url, !allowed);
917 content::RenderFrameHost* render_frame_host = 918 callback.Run(allowed);
918 content::RenderFrameHost::FromID(render_process_id, render_frame_id);
919 if (!render_frame_host)
920 return;
921 render_frame_host->Send(
922 new ChromeViewMsg_RequestFileSystemAccessAsyncResponse(
923 render_frame_id, request_id, allowed));
924 }
925
926 // static
927 void WebViewGuest::FileSystemAccessedSync(int render_process_id,
928 int render_frame_id,
929 const GURL& url,
930 bool blocked_by_policy,
931 IPC::Message* reply_msg) {
932 WebViewGuest* guest =
933 WebViewGuest::FromFrameID(render_process_id, render_frame_id);
934 DCHECK(guest);
935 guest->RequestFileSystemPermission(
936 url,
937 !blocked_by_policy,
938 base::Bind(&WebViewGuest::FileSystemAccessedSyncResponse,
939 render_process_id,
940 render_frame_id,
941 url,
942 reply_msg));
943 }
944
945 // static
946 void WebViewGuest::FileSystemAccessedSyncResponse(int render_process_id,
947 int render_frame_id,
948 const GURL& url,
949 IPC::Message* reply_msg,
950 bool allowed) {
951 TabSpecificContentSettings::FileSystemAccessed(
952 render_process_id, render_frame_id, url, !allowed);
953 ChromeViewHostMsg_RequestFileSystemAccessSync::WriteReplyParams(reply_msg,
954 allowed);
955 content::RenderFrameHost* render_frame_host =
956 content::RenderFrameHost::FromID(render_process_id, render_frame_id);
957 if (!render_frame_id)
958 return;
959 render_frame_host->Send(reply_msg);
960 } 919 }
961 920
962 WebViewGuest::~WebViewGuest() { 921 WebViewGuest::~WebViewGuest() {
963 } 922 }
964 923
965 void WebViewGuest::DidCommitProvisionalLoadForFrame( 924 void WebViewGuest::DidCommitProvisionalLoadForFrame(
966 int64 frame_id, 925 int64 frame_id,
967 const base::string16& frame_unique_name, 926 const base::string16& frame_unique_name,
968 bool is_main_frame, 927 bool is_main_frame,
969 const GURL& url, 928 const GURL& url,
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 bool allow, 1550 bool allow,
1592 const std::string& user_input) { 1551 const std::string& user_input) {
1593 WebViewGuest* guest = 1552 WebViewGuest* guest =
1594 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); 1553 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id);
1595 if (!guest) 1554 if (!guest)
1596 return; 1555 return;
1597 1556
1598 if (!allow) 1557 if (!allow)
1599 guest->Destroy(); 1558 guest->Destroy();
1600 } 1559 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698