OLD | NEW |
---|---|
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 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
928 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, | 928 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, |
929 GURL(), | 929 GURL(), |
930 content::StoragePartition::OriginMatcherFunction(), | 930 content::StoragePartition::OriginMatcherFunction(), |
931 remove_since, | 931 remove_since, |
932 base::Time::Now(), | 932 base::Time::Now(), |
933 callback); | 933 callback); |
934 return true; | 934 return true; |
935 } | 935 } |
936 | 936 |
937 // static | 937 // static |
938 void WebViewGuest::FileSystemAccessedAsync(int render_process_id, | 938 void WebViewGuest::FileSystemAccessed(int render_process_id, |
939 int render_frame_id, | 939 int render_frame_id, |
940 int request_id, | 940 const GURL& url, |
941 const GURL& url, | 941 bool blocked_by_policy, |
942 bool blocked_by_policy) { | 942 base::Callback<void(bool)> callback) { |
943 WebViewGuest* guest = | 943 WebViewGuest* guest = |
944 WebViewGuest::FromFrameID(render_process_id, render_frame_id); | 944 WebViewGuest::FromFrameID(render_process_id, render_frame_id); |
945 DCHECK(guest); | 945 DCHECK(guest); |
946 guest->RequestFileSystemPermission( | 946 guest->RequestFileSystemPermission( |
947 url, | 947 url, |
948 !blocked_by_policy, | 948 !blocked_by_policy, |
949 base::Bind(&WebViewGuest::FileSystemAccessedAsyncResponse, | 949 base::Bind(&WebViewGuest::FileSystemAccessedResponse, |
950 render_process_id, | 950 render_process_id, |
951 render_frame_id, | 951 render_frame_id, |
952 request_id, | 952 url, |
953 url)); | 953 callback)); |
954 } | 954 } |
955 | 955 |
956 // static | 956 // static |
957 void WebViewGuest::FileSystemAccessedAsyncResponse(int render_process_id, | 957 void WebViewGuest::FileSystemAccessedResponse( |
958 int render_frame_id, | 958 int render_process_id, |
959 int request_id, | 959 int render_frame_id, |
960 const GURL& url, | 960 const GURL& url, |
961 bool allowed) { | 961 base::Callback<void(bool)> callback, |
962 bool allowed) { | |
962 TabSpecificContentSettings::FileSystemAccessed( | 963 TabSpecificContentSettings::FileSystemAccessed( |
963 render_process_id, render_frame_id, url, !allowed); | 964 render_process_id, render_frame_id, url, !allowed); |
964 content::RenderFrameHost* render_frame_host = | 965 callback.Run(allowed); |
Fady Samuel
2014/07/08 14:42:46
attached() && allowed
Xi Han
2014/07/08 21:28:24
The attached() && allowed is done in WebViewGuest:
| |
965 content::RenderFrameHost::FromID(render_process_id, render_frame_id); | |
966 if (!render_frame_host) | |
967 return; | |
968 render_frame_host->Send( | |
969 new ChromeViewMsg_RequestFileSystemAccessAsyncResponse( | |
970 render_frame_id, request_id, allowed)); | |
971 } | 966 } |
972 | 967 |
973 // static | 968 // static |
974 void WebViewGuest::FileSystemAccessedSync(int render_process_id, | 969 void WebViewGuest::RequestFileSystemAccessPermission( |
Fady Samuel
2014/07/08 14:42:46
RequestFileSystemPermissionFromIOThread
Do the th
Xi Han
2014/07/08 21:28:24
Done.
| |
975 int render_frame_id, | 970 int render_process_id, |
976 const GURL& url, | 971 int render_frame_id, |
977 bool blocked_by_policy, | 972 const GURL& url, |
978 IPC::Message* reply_msg) { | 973 bool blocked_by_policy, |
Fady Samuel
2014/07/08 14:42:46
Can we reduce "blocked_by_policy"? Replace instanc
Xi Han
2014/07/08 21:28:24
Done.
| |
974 base::Callback<void(bool)> callback) { | |
979 WebViewGuest* guest = | 975 WebViewGuest* guest = |
980 WebViewGuest::FromFrameID(render_process_id, render_frame_id); | 976 WebViewGuest::FromFrameID(render_process_id, render_frame_id); |
981 DCHECK(guest); | 977 DCHECK(guest); |
982 guest->RequestFileSystemPermission( | 978 guest->RequestFileSystemPermission( |
983 url, | 979 url, |
984 !blocked_by_policy, | 980 !blocked_by_policy, |
985 base::Bind(&WebViewGuest::FileSystemAccessedSyncResponse, | 981 callback); |
986 render_process_id, | |
987 render_frame_id, | |
988 url, | |
989 reply_msg)); | |
990 } | |
991 | |
992 // static | |
993 void WebViewGuest::FileSystemAccessedSyncResponse(int render_process_id, | |
994 int render_frame_id, | |
995 const GURL& url, | |
996 IPC::Message* reply_msg, | |
997 bool allowed) { | |
998 TabSpecificContentSettings::FileSystemAccessed( | |
999 render_process_id, render_frame_id, url, !allowed); | |
1000 ChromeViewHostMsg_RequestFileSystemAccessSync::WriteReplyParams(reply_msg, | |
1001 allowed); | |
1002 content::RenderFrameHost* render_frame_host = | |
1003 content::RenderFrameHost::FromID(render_process_id, render_frame_id); | |
1004 if (!render_frame_id) | |
1005 return; | |
1006 render_frame_host->Send(reply_msg); | |
1007 } | 982 } |
1008 | 983 |
1009 WebViewGuest::~WebViewGuest() { | 984 WebViewGuest::~WebViewGuest() { |
1010 } | 985 } |
1011 | 986 |
1012 void WebViewGuest::DidCommitProvisionalLoadForFrame( | 987 void WebViewGuest::DidCommitProvisionalLoadForFrame( |
1013 content::RenderFrameHost* render_frame_host, | 988 content::RenderFrameHost* render_frame_host, |
1014 const GURL& url, | 989 const GURL& url, |
1015 content::PageTransition transition_type) { | 990 content::PageTransition transition_type) { |
1016 find_helper_.CancelAllFindSessions(); | 991 find_helper_.CancelAllFindSessions(); |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1646 bool allow, | 1621 bool allow, |
1647 const std::string& user_input) { | 1622 const std::string& user_input) { |
1648 WebViewGuest* guest = | 1623 WebViewGuest* guest = |
1649 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1624 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1650 if (!guest) | 1625 if (!guest) |
1651 return; | 1626 return; |
1652 | 1627 |
1653 if (!allow) | 1628 if (!allow) |
1654 guest->Destroy(); | 1629 guest->Destroy(); |
1655 } | 1630 } |
OLD | NEW |