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

Side by Side Diff: chrome/browser/chrome_content_browser_client.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: Update thread hops. Created 6 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; 639 return ratio * (kMaxFSM - kMinFSM) + kMinFSM;
640 } 640 }
641 641
642 #endif // defined(OS_ANDROID) 642 #endif // defined(OS_ANDROID)
643 643
644 } // namespace 644 } // namespace
645 645
646 namespace chrome { 646 namespace chrome {
647 647
648 ChromeContentBrowserClient::ChromeContentBrowserClient() 648 ChromeContentBrowserClient::ChromeContentBrowserClient()
649 : prerender_tracker_(NULL) { 649 : prerender_tracker_(NULL),
650 weak_factory_(this) {
650 #if defined(ENABLE_PLUGINS) 651 #if defined(ENABLE_PLUGINS)
651 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) 652 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i)
652 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); 653 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]);
653 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i) 654 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i)
654 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); 655 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]);
655 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) 656 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
656 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); 657 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
657 #endif 658 #endif
658 659
659 permissions_policy_delegate_.reset( 660 permissions_policy_delegate_.reset(
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 for (i = render_frames.begin(); i != render_frames.end(); ++i) { 1811 for (i = render_frames.begin(); i != render_frames.end(); ++i) {
1811 BrowserThread::PostTask( 1812 BrowserThread::PostTask(
1812 BrowserThread::UI, FROM_HERE, 1813 BrowserThread::UI, FROM_HERE,
1813 base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed, 1814 base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed,
1814 i->first, i->second, url, name, display_name, !allow)); 1815 i->first, i->second, url, name, display_name, !allow));
1815 } 1816 }
1816 1817
1817 return allow; 1818 return allow;
1818 } 1819 }
1819 1820
1820 bool ChromeContentBrowserClient::AllowWorkerFileSystem( 1821 void ChromeContentBrowserClient::AllowWorkerFileSystem(
1821 const GURL& url, 1822 const GURL& url,
1822 content::ResourceContext* context, 1823 content::ResourceContext* context,
1823 const std::vector<std::pair<int, int> >& render_frames) { 1824 const std::vector<std::pair<int, int> >& render_frames,
1825 base::Callback<void(bool)> callback) {
1824 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1826 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1825 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1827 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1826 CookieSettings* cookie_settings = io_data->GetCookieSettings(); 1828 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1827 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); 1829 bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
1828 1830
1831 #if defined(ENABLE_EXTENSIONS)
1832 // Record access to file system for potential display in UI.
1833 std::vector<std::pair<int, int> >::const_iterator i;
1834 for (i = render_frames.begin(); i != render_frames.end(); ++i) {
1835 bool is_web_view_guest =
1836 WebViewRendererState::GetInstance()->IsGuest(i->first);
Fady Samuel 2014/07/08 21:49:11 This code doesn't make sense to me. If there are t
Xi Han 2014/07/09 15:28:33 Done.
1837 if (is_web_view_guest) {
1838 BrowserThread::PostTask(
1839 BrowserThread::UI,
1840 FROM_HERE,
1841 base::Bind(&ChromeContentBrowserClient::
1842 RequestFileSystemPermissionOnUIThread,
1843 i->first,
1844 i->second,
1845 url,
1846 allow,
1847 base::Bind(&ChromeContentBrowserClient::FileSystemAccessed,
1848 weak_factory_.GetWeakPtr(),
1849 url,
1850 render_frames,
1851 callback)));
1852 break;
1853 }
1854 }
1855 #else
1856 FileSystemAccessed(url, render_frames, callback, allow);
1857 #endif
1858 }
1859
1860 #if defined(ENABLE_EXTENSIONS)
1861 void ChromeContentBrowserClient::RequestFileSystemPermissionOnUIThread(
1862 int render_process_id,
1863 int render_frame_id,
1864 const GURL& url,
1865 bool allowed_by_default,
1866 const base::Callback<void(bool)>& callback) {
1867 DCHECK(BrowserThread:: CurrentlyOn(BrowserThread::UI));
1868 WebViewGuest* guest = WebViewGuest::FromFrameID(render_process_id,
1869 render_frame_id);
1870 guest->RequestFileSystemPermission(url, allowed_by_default, callback);
1871 }
1872 #endif
1873
1874 void ChromeContentBrowserClient::FileSystemAccessed(
1875 const GURL& url,
1876 const std::vector<std::pair<int, int> >& render_frames,
1877 base::Callback<void(bool)> callback,
1878 bool allow) {
1829 // Record access to file system for potential display in UI. 1879 // Record access to file system for potential display in UI.
1830 std::vector<std::pair<int, int> >::const_iterator i; 1880 std::vector<std::pair<int, int> >::const_iterator i;
1831 for (i = render_frames.begin(); i != render_frames.end(); ++i) { 1881 for (i = render_frames.begin(); i != render_frames.end(); ++i) {
1832 BrowserThread::PostTask( 1882 BrowserThread::PostTask(
1833 BrowserThread::UI, FROM_HERE, 1883 BrowserThread::UI,
1884 FROM_HERE,
1834 base::Bind(&TabSpecificContentSettings::FileSystemAccessed, 1885 base::Bind(&TabSpecificContentSettings::FileSystemAccessed,
1835 i->first, i->second, url, !allow)); 1886 i->first,
1887 i->second,
1888 url,
1889 !allow));
1836 } 1890 }
1837 1891 callback.Run(allow);
1838 return allow;
1839 } 1892 }
1840 1893
1841 bool ChromeContentBrowserClient::AllowWorkerIndexedDB( 1894 bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
1842 const GURL& url, 1895 const GURL& url,
1843 const base::string16& name, 1896 const base::string16& name,
1844 content::ResourceContext* context, 1897 content::ResourceContext* context,
1845 const std::vector<std::pair<int, int> >& render_frames) { 1898 const std::vector<std::pair<int, int> >& render_frames) {
1846 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1899 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1847 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1900 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1848 CookieSettings* cookie_settings = io_data->GetCookieSettings(); 1901 CookieSettings* cookie_settings = io_data->GetCookieSettings();
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
2801 switches::kDisableWebRtcEncryption, 2854 switches::kDisableWebRtcEncryption,
2802 }; 2855 };
2803 to_command_line->CopySwitchesFrom(from_command_line, 2856 to_command_line->CopySwitchesFrom(from_command_line,
2804 kWebRtcDevSwitchNames, 2857 kWebRtcDevSwitchNames,
2805 arraysize(kWebRtcDevSwitchNames)); 2858 arraysize(kWebRtcDevSwitchNames));
2806 } 2859 }
2807 } 2860 }
2808 #endif // defined(ENABLE_WEBRTC) 2861 #endif // defined(ENABLE_WEBRTC)
2809 2862
2810 } // namespace chrome 2863 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/browser/guest_view/web_view/web_view_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698