| 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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 AfterStartupTaskUtils::PostTask(from_here, task_runner, task); | 763 AfterStartupTaskUtils::PostTask(from_here, task_runner, task); |
| 764 } | 764 } |
| 765 | 765 |
| 766 std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( | 766 std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( |
| 767 content::BrowserContext* browser_context, | 767 content::BrowserContext* browser_context, |
| 768 const GURL& site) { | 768 const GURL& site) { |
| 769 std::string partition_id; | 769 std::string partition_id; |
| 770 | 770 |
| 771 // The partition ID for webview guest processes is the string value of its | 771 // The partition ID for webview guest processes is the string value of its |
| 772 // SiteInstance URL - "chrome-guest://app_id/persist?partition". | 772 // SiteInstance URL - "chrome-guest://app_id/persist?partition". |
| 773 if (site.SchemeIs(content::kGuestScheme)) { | 773 if (site.SchemeIs(content::kGuestScheme)) |
| 774 partition_id = site.spec(); | 774 partition_id = site.spec(); |
| 775 } else if (!switches::IsEnableWebviewBasedSignin() && | |
| 776 site.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL) { | |
| 777 // The non-webview Chrome signin page has an embedded iframe of extension | |
| 778 // and web content, thus it must be isolated from other webUI pages. | |
| 779 partition_id = site.GetOrigin().spec(); | |
| 780 } | |
| 781 | 775 |
| 782 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); | 776 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); |
| 783 return partition_id; | 777 return partition_id; |
| 784 } | 778 } |
| 785 | 779 |
| 786 bool ChromeContentBrowserClient::IsValidStoragePartitionId( | 780 bool ChromeContentBrowserClient::IsValidStoragePartitionId( |
| 787 content::BrowserContext* browser_context, | 781 content::BrowserContext* browser_context, |
| 788 const std::string& partition_id) { | 782 const std::string& partition_id) { |
| 789 // The default ID is empty and is always valid. | 783 // The default ID is empty and is always valid. |
| 790 if (partition_id.empty()) | 784 if (partition_id.empty()) |
| 791 return true; | 785 return true; |
| 792 | 786 |
| 793 return GURL(partition_id).is_valid(); | 787 return GURL(partition_id).is_valid(); |
| 794 } | 788 } |
| 795 | 789 |
| 796 void ChromeContentBrowserClient::GetStoragePartitionConfigForSite( | 790 void ChromeContentBrowserClient::GetStoragePartitionConfigForSite( |
| 797 content::BrowserContext* browser_context, | 791 content::BrowserContext* browser_context, |
| 798 const GURL& site, | 792 const GURL& site, |
| 799 bool can_be_default, | 793 bool can_be_default, |
| 800 std::string* partition_domain, | 794 std::string* partition_domain, |
| 801 std::string* partition_name, | 795 std::string* partition_name, |
| 802 bool* in_memory) { | 796 bool* in_memory) { |
| 803 // Default to the browser-wide storage partition and override based on |site| | 797 // Default to the browser-wide storage partition and override based on |site| |
| 804 // below. | 798 // below. |
| 805 partition_domain->clear(); | 799 partition_domain->clear(); |
| 806 partition_name->clear(); | 800 partition_name->clear(); |
| 807 *in_memory = false; | 801 *in_memory = false; |
| 808 | 802 |
| 809 bool success = false; | |
| 810 #if defined(ENABLE_EXTENSIONS) | 803 #if defined(ENABLE_EXTENSIONS) |
| 811 success = extensions::WebViewGuest::GetGuestPartitionConfigForSite( | 804 bool success = extensions::WebViewGuest::GetGuestPartitionConfigForSite( |
| 812 site, partition_domain, partition_name, in_memory); | 805 site, partition_domain, partition_name, in_memory); |
| 813 | 806 |
| 814 if (!success && site.SchemeIs(extensions::kExtensionScheme)) { | 807 if (!success && site.SchemeIs(extensions::kExtensionScheme)) { |
| 815 // If |can_be_default| is false, the caller is stating that the |site| | 808 // If |can_be_default| is false, the caller is stating that the |site| |
| 816 // should be parsed as if it had isolated storage. In particular it is | 809 // should be parsed as if it had isolated storage. In particular it is |
| 817 // important to NOT check ExtensionService for the is_storage_isolated() | 810 // important to NOT check ExtensionService for the is_storage_isolated() |
| 818 // attribute because this code path is run during Extension uninstall | 811 // attribute because this code path is run during Extension uninstall |
| 819 // to do cleanup after the Extension has already been unloaded from the | 812 // to do cleanup after the Extension has already been unloaded from the |
| 820 // ExtensionService. | 813 // ExtensionService. |
| 821 bool is_isolated = !can_be_default; | 814 bool is_isolated = !can_be_default; |
| 822 if (can_be_default) { | 815 if (can_be_default) { |
| 823 if (extensions::util::SiteHasIsolatedStorage(site, browser_context)) | 816 if (extensions::util::SiteHasIsolatedStorage(site, browser_context)) |
| 824 is_isolated = true; | 817 is_isolated = true; |
| 825 } | 818 } |
| 826 | 819 |
| 827 if (is_isolated) { | 820 if (is_isolated) { |
| 828 CHECK(site.has_host()); | 821 CHECK(site.has_host()); |
| 829 // For extensions with isolated storage, the the host of the |site| is | 822 // For extensions with isolated storage, the the host of the |site| is |
| 830 // the |partition_domain|. The |in_memory| and |partition_name| are only | 823 // the |partition_domain|. The |in_memory| and |partition_name| are only |
| 831 // used in guest schemes so they are cleared here. | 824 // used in guest schemes so they are cleared here. |
| 832 *partition_domain = site.host(); | 825 *partition_domain = site.host(); |
| 833 *in_memory = false; | 826 *in_memory = false; |
| 834 partition_name->clear(); | 827 partition_name->clear(); |
| 835 } | 828 } |
| 836 success = true; | 829 success = true; |
| 837 } | 830 } |
| 838 #endif | 831 #endif |
| 839 | 832 |
| 840 if (!success && | |
| 841 (!switches::IsEnableWebviewBasedSignin() && | |
| 842 site.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL)) { | |
| 843 // The non-webview Chrome signin page has an embedded iframe of extension | |
| 844 // and web content, thus it must be isolated from other webUI pages. | |
| 845 *partition_domain = chrome::kChromeUIChromeSigninHost; | |
| 846 } | |
| 847 | |
| 848 // Assert that if |can_be_default| is false, the code above must have found a | 833 // Assert that if |can_be_default| is false, the code above must have found a |
| 849 // non-default partition. If this fails, the caller has a serious logic | 834 // non-default partition. If this fails, the caller has a serious logic |
| 850 // error about which StoragePartition they expect to be in and it is not | 835 // error about which StoragePartition they expect to be in and it is not |
| 851 // safe to continue. | 836 // safe to continue. |
| 852 CHECK(can_be_default || !partition_domain->empty()); | 837 CHECK(can_be_default || !partition_domain->empty()); |
| 853 } | 838 } |
| 854 | 839 |
| 855 content::WebContentsViewDelegate* | 840 content::WebContentsViewDelegate* |
| 856 ChromeContentBrowserClient::GetWebContentsViewDelegate( | 841 ChromeContentBrowserClient::GetWebContentsViewDelegate( |
| 857 content::WebContents* web_contents) { | 842 content::WebContents* web_contents) { |
| (...skipping 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2769 if (channel <= kMaxDisableEncryptionChannel) { | 2754 if (channel <= kMaxDisableEncryptionChannel) { |
| 2770 static const char* const kWebRtcDevSwitchNames[] = { | 2755 static const char* const kWebRtcDevSwitchNames[] = { |
| 2771 switches::kDisableWebRtcEncryption, | 2756 switches::kDisableWebRtcEncryption, |
| 2772 }; | 2757 }; |
| 2773 to_command_line->CopySwitchesFrom(from_command_line, | 2758 to_command_line->CopySwitchesFrom(from_command_line, |
| 2774 kWebRtcDevSwitchNames, | 2759 kWebRtcDevSwitchNames, |
| 2775 arraysize(kWebRtcDevSwitchNames)); | 2760 arraysize(kWebRtcDevSwitchNames)); |
| 2776 } | 2761 } |
| 2777 } | 2762 } |
| 2778 #endif // defined(ENABLE_WEBRTC) | 2763 #endif // defined(ENABLE_WEBRTC) |
| OLD | NEW |