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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 // we can pick any of them to retrieve the storage partition id. | 484 // we can pick any of them to retrieve the storage partition id. |
485 extension = | 485 extension = |
486 extension_service->extensions()->GetByID(*(extension_ids.begin())); | 486 extension_service->extensions()->GetByID(*(extension_ids.begin())); |
487 } | 487 } |
488 return GetStoragePartitionIdForExtension(browser_context, extension); | 488 return GetStoragePartitionIdForExtension(browser_context, extension); |
489 } | 489 } |
490 | 490 |
491 std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( | 491 std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( |
492 content::BrowserContext* browser_context, | 492 content::BrowserContext* browser_context, |
493 const GURL& site) { | 493 const GURL& site) { |
| 494 if (site.SchemeIs(chrome::kGuestScheme)) |
| 495 return "guest-" + site.host(); |
| 496 |
494 const Extension* extension = NULL; | 497 const Extension* extension = NULL; |
495 Profile* profile = Profile::FromBrowserContext(browser_context); | 498 Profile* profile = Profile::FromBrowserContext(browser_context); |
496 ExtensionService* extension_service = | 499 ExtensionService* extension_service = |
497 extensions::ExtensionSystem::Get(profile)->extension_service(); | 500 extensions::ExtensionSystem::Get(profile)->extension_service(); |
498 if (extension_service) { | 501 if (extension_service) { |
499 extension = extension_service->extensions()-> | 502 extension = extension_service->extensions()-> |
500 GetExtensionOrAppByURL(ExtensionURLInfo(site)); | 503 GetExtensionOrAppByURL(ExtensionURLInfo(site)); |
501 } | 504 } |
502 | 505 |
503 return GetStoragePartitionIdForExtension(browser_context, extension); | 506 return GetStoragePartitionIdForExtension(browser_context, extension); |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 if (web_prefs->default_encoding.empty()) { | 1600 if (web_prefs->default_encoding.empty()) { |
1598 prefs->ClearPref(prefs::kDefaultCharset); | 1601 prefs->ClearPref(prefs::kDefaultCharset); |
1599 web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset); | 1602 web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset); |
1600 } | 1603 } |
1601 DCHECK(!web_prefs->default_encoding.empty()); | 1604 DCHECK(!web_prefs->default_encoding.empty()); |
1602 | 1605 |
1603 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); | 1606 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); |
1604 chrome::ViewType view_type = chrome::GetViewType(web_contents); | 1607 chrome::ViewType view_type = chrome::GetViewType(web_contents); |
1605 ExtensionService* service = profile->GetExtensionService(); | 1608 ExtensionService* service = profile->GetExtensionService(); |
1606 if (service) { | 1609 if (service) { |
1607 const Extension* extension = service->extensions()->GetByID( | 1610 const GURL& url = rvh->GetSiteInstance()->GetSiteURL(); |
1608 rvh->GetSiteInstance()->GetSiteURL().host()); | 1611 // Ensure that we are only granting extension preferences to URLs with the |
1609 extension_webkit_preferences::SetPreferences( | 1612 // correct scheme. Without this check, guest:// schemes used by webview |
1610 extension, view_type, web_prefs); | 1613 // tags as well as hosts that happen to match the id of an install extension |
| 1614 // would get the wrong preferences. |
| 1615 if (url.SchemeIs(chrome::kExtensionScheme)) { |
| 1616 const Extension* extension = service->extensions()->GetByID(url.host()); |
| 1617 extension_webkit_preferences::SetPreferences( |
| 1618 extension, view_type, web_prefs); |
| 1619 } |
1611 } | 1620 } |
1612 | 1621 |
1613 if (content::IsForceCompositingModeEnabled()) | 1622 if (content::IsForceCompositingModeEnabled()) |
1614 web_prefs->force_compositing_mode = true; | 1623 web_prefs->force_compositing_mode = true; |
1615 | 1624 |
1616 if (view_type == chrome::VIEW_TYPE_NOTIFICATION) { | 1625 if (view_type == chrome::VIEW_TYPE_NOTIFICATION) { |
1617 web_prefs->allow_scripts_to_close_windows = true; | 1626 web_prefs->allow_scripts_to_close_windows = true; |
1618 } else if (view_type == chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { | 1627 } else if (view_type == chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { |
1619 // Disable all kinds of acceleration for background pages. | 1628 // Disable all kinds of acceleration for background pages. |
1620 // See http://crbug.com/96005 and http://crbug.com/96006 | 1629 // See http://crbug.com/96005 and http://crbug.com/96006 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 partition_id = extension->id(); | 1886 partition_id = extension->id(); |
1878 } | 1887 } |
1879 | 1888 |
1880 // Enforce that IsValidStoragePartitionId() implementation stays in sync. | 1889 // Enforce that IsValidStoragePartitionId() implementation stays in sync. |
1881 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); | 1890 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); |
1882 return partition_id; | 1891 return partition_id; |
1883 } | 1892 } |
1884 | 1893 |
1885 | 1894 |
1886 } // namespace chrome | 1895 } // namespace chrome |
OLD | NEW |