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 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, | 924 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, |
925 GURL(), | 925 GURL(), |
926 content::StoragePartition::OriginMatcherFunction(), | 926 content::StoragePartition::OriginMatcherFunction(), |
927 remove_since, | 927 remove_since, |
928 base::Time::Now(), | 928 base::Time::Now(), |
929 callback); | 929 callback); |
930 return true; | 930 return true; |
931 } | 931 } |
932 | 932 |
933 // static | 933 // static |
934 void WebViewGuest::FileSystemAccessedAsync(int render_process_id, | 934 void WebViewGuest::FileSystemAccessed(int render_process_id, |
935 int render_frame_id, | 935 int render_frame_id, |
936 int request_id, | 936 const GURL& url, |
937 const GURL& url, | 937 bool blocked_by_policy, |
938 bool blocked_by_policy) { | 938 base::Callback<void(bool)> callback) { |
939 WebViewGuest* guest = | 939 WebViewGuest* guest = |
940 WebViewGuest::FromFrameID(render_process_id, render_frame_id); | 940 WebViewGuest::FromFrameID(render_process_id, render_frame_id); |
941 DCHECK(guest); | 941 DCHECK(guest); |
942 guest->RequestFileSystemPermission( | 942 guest->RequestFileSystemPermission( |
943 url, | 943 url, |
944 !blocked_by_policy, | 944 !blocked_by_policy, |
945 base::Bind(&WebViewGuest::FileSystemAccessedAsyncResponse, | 945 base::Bind(&WebViewGuest::FileSystemAccessedResponse, |
946 render_process_id, | 946 render_process_id, |
947 render_frame_id, | 947 render_frame_id, |
948 request_id, | 948 url, |
949 url)); | 949 callback)); |
950 } | 950 } |
951 | 951 |
952 // static | 952 // static |
953 void WebViewGuest::FileSystemAccessedAsyncResponse(int render_process_id, | 953 void WebViewGuest::FileSystemAccessedResponse( |
954 int render_frame_id, | 954 int render_process_id, |
955 int request_id, | 955 int render_frame_id, |
956 const GURL& url, | 956 const GURL& url, |
957 bool allowed) { | 957 base::Callback<void(bool)> callback, |
| 958 bool allowed) { |
958 TabSpecificContentSettings::FileSystemAccessed( | 959 TabSpecificContentSettings::FileSystemAccessed( |
959 render_process_id, render_frame_id, url, !allowed); | 960 render_process_id, render_frame_id, url, !allowed); |
960 content::RenderFrameHost* render_frame_host = | 961 callback.Run(allowed); |
961 content::RenderFrameHost::FromID(render_process_id, render_frame_id); | |
962 if (!render_frame_host) | |
963 return; | |
964 render_frame_host->Send( | |
965 new ChromeViewMsg_RequestFileSystemAccessAsyncResponse( | |
966 render_frame_id, request_id, allowed)); | |
967 } | |
968 | |
969 // static | |
970 void WebViewGuest::FileSystemAccessedSync(int render_process_id, | |
971 int render_frame_id, | |
972 const GURL& url, | |
973 bool blocked_by_policy, | |
974 IPC::Message* reply_msg) { | |
975 WebViewGuest* guest = | |
976 WebViewGuest::FromFrameID(render_process_id, render_frame_id); | |
977 DCHECK(guest); | |
978 guest->RequestFileSystemPermission( | |
979 url, | |
980 !blocked_by_policy, | |
981 base::Bind(&WebViewGuest::FileSystemAccessedSyncResponse, | |
982 render_process_id, | |
983 render_frame_id, | |
984 url, | |
985 reply_msg)); | |
986 } | |
987 | |
988 // static | |
989 void WebViewGuest::FileSystemAccessedSyncResponse(int render_process_id, | |
990 int render_frame_id, | |
991 const GURL& url, | |
992 IPC::Message* reply_msg, | |
993 bool allowed) { | |
994 TabSpecificContentSettings::FileSystemAccessed( | |
995 render_process_id, render_frame_id, url, !allowed); | |
996 ChromeViewHostMsg_RequestFileSystemAccessSync::WriteReplyParams(reply_msg, | |
997 allowed); | |
998 content::RenderFrameHost* render_frame_host = | |
999 content::RenderFrameHost::FromID(render_process_id, render_frame_id); | |
1000 if (!render_frame_id) | |
1001 return; | |
1002 render_frame_host->Send(reply_msg); | |
1003 } | 962 } |
1004 | 963 |
1005 WebViewGuest::~WebViewGuest() { | 964 WebViewGuest::~WebViewGuest() { |
1006 } | 965 } |
1007 | 966 |
1008 void WebViewGuest::DidCommitProvisionalLoadForFrame( | 967 void WebViewGuest::DidCommitProvisionalLoadForFrame( |
1009 int64 frame_id, | 968 int64 frame_id, |
1010 const base::string16& frame_unique_name, | 969 const base::string16& frame_unique_name, |
1011 bool is_main_frame, | 970 bool is_main_frame, |
1012 const GURL& url, | 971 const GURL& url, |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1650 bool allow, | 1609 bool allow, |
1651 const std::string& user_input) { | 1610 const std::string& user_input) { |
1652 WebViewGuest* guest = | 1611 WebViewGuest* guest = |
1653 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1612 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1654 if (!guest) | 1613 if (!guest) |
1655 return; | 1614 return; |
1656 | 1615 |
1657 if (!allow) | 1616 if (!allow) |
1658 guest->Destroy(); | 1617 guest->Destroy(); |
1659 } | 1618 } |
OLD | NEW |