OLD | NEW |
---|---|
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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
641 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; | 641 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; |
642 } | 642 } |
643 | 643 |
644 #endif // defined(OS_ANDROID) | 644 #endif // defined(OS_ANDROID) |
645 | 645 |
646 } // namespace | 646 } // namespace |
647 | 647 |
648 namespace chrome { | 648 namespace chrome { |
649 | 649 |
650 ChromeContentBrowserClient::ChromeContentBrowserClient() | 650 ChromeContentBrowserClient::ChromeContentBrowserClient() |
651 : prerender_tracker_(NULL) { | 651 : prerender_tracker_(NULL), |
652 weak_factory_(this) { | |
652 #if defined(ENABLE_PLUGINS) | 653 #if defined(ENABLE_PLUGINS) |
653 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) | 654 for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i) |
654 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); | 655 allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]); |
655 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i) | 656 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i) |
656 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); | 657 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); |
657 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) | 658 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
658 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); | 659 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
659 #endif | 660 #endif |
660 | 661 |
661 permissions_policy_delegate_.reset( | 662 permissions_policy_delegate_.reset( |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1812 for (i = render_frames.begin(); i != render_frames.end(); ++i) { | 1813 for (i = render_frames.begin(); i != render_frames.end(); ++i) { |
1813 BrowserThread::PostTask( | 1814 BrowserThread::PostTask( |
1814 BrowserThread::UI, FROM_HERE, | 1815 BrowserThread::UI, FROM_HERE, |
1815 base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed, | 1816 base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed, |
1816 i->first, i->second, url, name, display_name, !allow)); | 1817 i->first, i->second, url, name, display_name, !allow)); |
1817 } | 1818 } |
1818 | 1819 |
1819 return allow; | 1820 return allow; |
1820 } | 1821 } |
1821 | 1822 |
1822 bool ChromeContentBrowserClient::AllowWorkerFileSystem( | 1823 void ChromeContentBrowserClient::AllowWorkerFileSystem( |
1823 const GURL& url, | 1824 const GURL& url, |
1824 content::ResourceContext* context, | 1825 content::ResourceContext* context, |
1825 const std::vector<std::pair<int, int> >& render_frames) { | 1826 const std::vector<std::pair<int, int> >& render_frames, |
1827 base::Callback<void(bool)> callback) { | |
1826 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1828 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1827 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 1829 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
1828 CookieSettings* cookie_settings = io_data->GetCookieSettings(); | 1830 CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
1829 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); | 1831 bool allow = cookie_settings->IsSettingCookieAllowed(url, url); |
1830 | 1832 |
1833 #if defined(ENABLE_EXTENSIONS) | |
1834 GuestPermissionRequestHelper(url, render_frames, callback, allow); | |
1835 #else | |
1836 FileSystemAccessed(url, render_frames, callback, allow); | |
1837 #endif | |
1838 } | |
1839 | |
1840 #if defined(ENABLE_EXTENSIONS) | |
1841 void ChromeContentBrowserClient::GuestPermissionRequestHelper( | |
1842 const GURL& url, | |
1843 const std::vector<std::pair<int, int> >& render_frames, | |
1844 base::Callback<void(bool)> callback, | |
1845 bool allow) { | |
1846 DCHECK(BrowserThread:: CurrentlyOn(BrowserThread::IO)); | |
1847 std::vector<std::pair<int, int> >::const_iterator i; | |
1848 std::map<int, int> process_map; | |
1849 std::map<int, int>::const_iterator it; | |
1850 bool has_web_view_guest = false; | |
1851 // Record access to file system for potential display in UI. | |
1852 for (i = render_frames.begin(); i != render_frames.end(); ++i) { | |
1853 if (process_map.find(i->first) != process_map.end()) | |
1854 continue; | |
1855 | |
1856 process_map.insert(std::pair<int, int>(i->first, i->second)); | |
1857 | |
1858 if (WebViewRendererState::GetInstance()->IsGuest(i->first)) { | |
Fady Samuel
2014/07/09 21:08:32
Remove block.
| |
1859 has_web_view_guest = true; | |
1860 } | |
1861 } | |
1862 | |
1863 if (!has_web_view_guest) { | |
1864 FileSystemAccessed(url, render_frames, callback, allow); | |
1865 return; | |
1866 } | |
1867 DCHECK(process_map.size() == 1); | |
1868 it = process_map.begin(); | |
1869 BrowserThread::PostTask( | |
1870 BrowserThread::UI, | |
1871 FROM_HERE, | |
1872 base::Bind(&ChromeContentBrowserClient:: | |
1873 RequestFileSystemPermissionOnUIThread, | |
1874 it->first, | |
1875 it->second, | |
1876 url, | |
1877 allow, | |
1878 base::Bind(&ChromeContentBrowserClient::FileSystemAccessed, | |
1879 weak_factory_.GetWeakPtr(), | |
1880 url, | |
1881 render_frames, | |
1882 callback))); | |
1883 } | |
1884 | |
1885 void ChromeContentBrowserClient::RequestFileSystemPermissionOnUIThread( | |
1886 int render_process_id, | |
1887 int render_frame_id, | |
1888 const GURL& url, | |
1889 bool allowed_by_default, | |
1890 const base::Callback<void(bool)>& callback) { | |
1891 DCHECK(BrowserThread:: CurrentlyOn(BrowserThread::UI)); | |
1892 WebViewGuest* guest = WebViewGuest::FromFrameID(render_process_id, | |
1893 render_frame_id); | |
1894 guest->RequestFileSystemPermission(url, allowed_by_default, callback); | |
1895 } | |
1896 #endif | |
1897 | |
1898 void ChromeContentBrowserClient::FileSystemAccessed( | |
1899 const GURL& url, | |
1900 const std::vector<std::pair<int, int> >& render_frames, | |
1901 base::Callback<void(bool)> callback, | |
1902 bool allow) { | |
1831 // Record access to file system for potential display in UI. | 1903 // Record access to file system for potential display in UI. |
1832 std::vector<std::pair<int, int> >::const_iterator i; | 1904 std::vector<std::pair<int, int> >::const_iterator i; |
1833 for (i = render_frames.begin(); i != render_frames.end(); ++i) { | 1905 for (i = render_frames.begin(); i != render_frames.end(); ++i) { |
1834 BrowserThread::PostTask( | 1906 BrowserThread::PostTask( |
1835 BrowserThread::UI, FROM_HERE, | 1907 BrowserThread::UI, |
1908 FROM_HERE, | |
1836 base::Bind(&TabSpecificContentSettings::FileSystemAccessed, | 1909 base::Bind(&TabSpecificContentSettings::FileSystemAccessed, |
1837 i->first, i->second, url, !allow)); | 1910 i->first, i->second, url, !allow)); |
1838 } | 1911 } |
1839 | 1912 callback.Run(allow); |
1840 return allow; | |
1841 } | 1913 } |
1842 | 1914 |
1843 bool ChromeContentBrowserClient::AllowWorkerIndexedDB( | 1915 bool ChromeContentBrowserClient::AllowWorkerIndexedDB( |
1844 const GURL& url, | 1916 const GURL& url, |
1845 const base::string16& name, | 1917 const base::string16& name, |
1846 content::ResourceContext* context, | 1918 content::ResourceContext* context, |
1847 const std::vector<std::pair<int, int> >& render_frames) { | 1919 const std::vector<std::pair<int, int> >& render_frames) { |
1848 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1920 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1849 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 1921 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
1850 CookieSettings* cookie_settings = io_data->GetCookieSettings(); | 1922 CookieSettings* cookie_settings = io_data->GetCookieSettings(); |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2806 switches::kDisableWebRtcEncryption, | 2878 switches::kDisableWebRtcEncryption, |
2807 }; | 2879 }; |
2808 to_command_line->CopySwitchesFrom(from_command_line, | 2880 to_command_line->CopySwitchesFrom(from_command_line, |
2809 kWebRtcDevSwitchNames, | 2881 kWebRtcDevSwitchNames, |
2810 arraysize(kWebRtcDevSwitchNames)); | 2882 arraysize(kWebRtcDevSwitchNames)); |
2811 } | 2883 } |
2812 } | 2884 } |
2813 #endif // defined(ENABLE_WEBRTC) | 2885 #endif // defined(ENABLE_WEBRTC) |
2814 | 2886 |
2815 } // namespace chrome | 2887 } // namespace chrome |
OLD | NEW |