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 <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 AfterStartupTaskUtils::PostTask(from_here, task_runner, task); | 800 AfterStartupTaskUtils::PostTask(from_here, task_runner, task); |
801 } | 801 } |
802 | 802 |
803 std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( | 803 std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( |
804 content::BrowserContext* browser_context, | 804 content::BrowserContext* browser_context, |
805 const GURL& site) { | 805 const GURL& site) { |
806 std::string partition_id; | 806 std::string partition_id; |
807 | 807 |
808 // The partition ID for webview guest processes is the string value of its | 808 // The partition ID for webview guest processes is the string value of its |
809 // SiteInstance URL - "chrome-guest://app_id/persist?partition". | 809 // SiteInstance URL - "chrome-guest://app_id/persist?partition". |
810 if (site.SchemeIs(content::kGuestScheme)) { | 810 if (site.SchemeIs(content::kGuestScheme)) |
811 partition_id = site.spec(); | 811 partition_id = site.spec(); |
812 } else if (!switches::IsEnableWebviewBasedSignin() && | |
813 site.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL) { | |
814 // The non-webview Chrome signin page has an embedded iframe of extension | |
815 // and web content, thus it must be isolated from other webUI pages. | |
816 partition_id = site.GetOrigin().spec(); | |
817 } | |
818 | 812 |
819 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); | 813 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); |
820 return partition_id; | 814 return partition_id; |
821 } | 815 } |
822 | 816 |
823 bool ChromeContentBrowserClient::IsValidStoragePartitionId( | 817 bool ChromeContentBrowserClient::IsValidStoragePartitionId( |
824 content::BrowserContext* browser_context, | 818 content::BrowserContext* browser_context, |
825 const std::string& partition_id) { | 819 const std::string& partition_id) { |
826 // The default ID is empty and is always valid. | 820 // The default ID is empty and is always valid. |
827 if (partition_id.empty()) | 821 if (partition_id.empty()) |
828 return true; | 822 return true; |
829 | 823 |
830 return GURL(partition_id).is_valid(); | 824 return GURL(partition_id).is_valid(); |
831 } | 825 } |
832 | 826 |
833 void ChromeContentBrowserClient::GetStoragePartitionConfigForSite( | 827 void ChromeContentBrowserClient::GetStoragePartitionConfigForSite( |
834 content::BrowserContext* browser_context, | 828 content::BrowserContext* browser_context, |
835 const GURL& site, | 829 const GURL& site, |
836 bool can_be_default, | 830 bool can_be_default, |
837 std::string* partition_domain, | 831 std::string* partition_domain, |
838 std::string* partition_name, | 832 std::string* partition_name, |
839 bool* in_memory) { | 833 bool* in_memory) { |
840 // Default to the browser-wide storage partition and override based on |site| | 834 // Default to the browser-wide storage partition and override based on |site| |
841 // below. | 835 // below. |
842 partition_domain->clear(); | 836 partition_domain->clear(); |
843 partition_name->clear(); | 837 partition_name->clear(); |
844 *in_memory = false; | 838 *in_memory = false; |
845 | 839 |
846 bool success = false; | |
847 #if defined(ENABLE_EXTENSIONS) | 840 #if defined(ENABLE_EXTENSIONS) |
848 success = extensions::WebViewGuest::GetGuestPartitionConfigForSite( | 841 bool success = extensions::WebViewGuest::GetGuestPartitionConfigForSite( |
849 site, partition_domain, partition_name, in_memory); | 842 site, partition_domain, partition_name, in_memory); |
850 | 843 |
851 if (!success && site.SchemeIs(extensions::kExtensionScheme)) { | 844 if (!success && site.SchemeIs(extensions::kExtensionScheme)) { |
852 // If |can_be_default| is false, the caller is stating that the |site| | 845 // If |can_be_default| is false, the caller is stating that the |site| |
853 // should be parsed as if it had isolated storage. In particular it is | 846 // should be parsed as if it had isolated storage. In particular it is |
854 // important to NOT check ExtensionService for the is_storage_isolated() | 847 // important to NOT check ExtensionService for the is_storage_isolated() |
855 // attribute because this code path is run during Extension uninstall | 848 // attribute because this code path is run during Extension uninstall |
856 // to do cleanup after the Extension has already been unloaded from the | 849 // to do cleanup after the Extension has already been unloaded from the |
857 // ExtensionService. | 850 // ExtensionService. |
858 bool is_isolated = !can_be_default; | 851 bool is_isolated = !can_be_default; |
859 if (can_be_default) { | 852 if (can_be_default) { |
860 if (extensions::util::SiteHasIsolatedStorage(site, browser_context)) | 853 if (extensions::util::SiteHasIsolatedStorage(site, browser_context)) |
861 is_isolated = true; | 854 is_isolated = true; |
862 } | 855 } |
863 | 856 |
864 if (is_isolated) { | 857 if (is_isolated) { |
865 CHECK(site.has_host()); | 858 CHECK(site.has_host()); |
866 // For extensions with isolated storage, the the host of the |site| is | 859 // For extensions with isolated storage, the the host of the |site| is |
867 // the |partition_domain|. The |in_memory| and |partition_name| are only | 860 // the |partition_domain|. The |in_memory| and |partition_name| are only |
868 // used in guest schemes so they are cleared here. | 861 // used in guest schemes so they are cleared here. |
869 *partition_domain = site.host(); | 862 *partition_domain = site.host(); |
870 *in_memory = false; | 863 *in_memory = false; |
871 partition_name->clear(); | 864 partition_name->clear(); |
872 } | 865 } |
873 success = true; | 866 success = true; |
874 } | 867 } |
875 #endif | 868 #endif |
876 | 869 |
877 if (!success && | |
878 (!switches::IsEnableWebviewBasedSignin() && | |
879 site.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL)) { | |
880 // The non-webview Chrome signin page has an embedded iframe of extension | |
881 // and web content, thus it must be isolated from other webUI pages. | |
882 *partition_domain = chrome::kChromeUIChromeSigninHost; | |
883 } | |
884 | |
885 // Assert that if |can_be_default| is false, the code above must have found a | 870 // Assert that if |can_be_default| is false, the code above must have found a |
886 // non-default partition. If this fails, the caller has a serious logic | 871 // non-default partition. If this fails, the caller has a serious logic |
887 // error about which StoragePartition they expect to be in and it is not | 872 // error about which StoragePartition they expect to be in and it is not |
888 // safe to continue. | 873 // safe to continue. |
889 CHECK(can_be_default || !partition_domain->empty()); | 874 CHECK(can_be_default || !partition_domain->empty()); |
890 } | 875 } |
891 | 876 |
892 content::WebContentsViewDelegate* | 877 content::WebContentsViewDelegate* |
893 ChromeContentBrowserClient::GetWebContentsViewDelegate( | 878 ChromeContentBrowserClient::GetWebContentsViewDelegate( |
894 content::WebContents* web_contents) { | 879 content::WebContents* web_contents) { |
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2810 if (channel <= kMaxDisableEncryptionChannel) { | 2795 if (channel <= kMaxDisableEncryptionChannel) { |
2811 static const char* const kWebRtcDevSwitchNames[] = { | 2796 static const char* const kWebRtcDevSwitchNames[] = { |
2812 switches::kDisableWebRtcEncryption, | 2797 switches::kDisableWebRtcEncryption, |
2813 }; | 2798 }; |
2814 to_command_line->CopySwitchesFrom(from_command_line, | 2799 to_command_line->CopySwitchesFrom(from_command_line, |
2815 kWebRtcDevSwitchNames, | 2800 kWebRtcDevSwitchNames, |
2816 arraysize(kWebRtcDevSwitchNames)); | 2801 arraysize(kWebRtcDevSwitchNames)); |
2817 } | 2802 } |
2818 } | 2803 } |
2819 #endif // defined(ENABLE_WEBRTC) | 2804 #endif // defined(ENABLE_WEBRTC) |
OLD | NEW |