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