Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(827)

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 11320018: Fixing guest processes to use the proper storage partition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 if (web_prefs->default_encoding.empty()) { 1599 if (web_prefs->default_encoding.empty()) {
1597 prefs->ClearPref(prefs::kDefaultCharset); 1600 prefs->ClearPref(prefs::kDefaultCharset);
1598 web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset); 1601 web_prefs->default_encoding = prefs->GetString(prefs::kDefaultCharset);
1599 } 1602 }
1600 DCHECK(!web_prefs->default_encoding.empty()); 1603 DCHECK(!web_prefs->default_encoding.empty());
1601 1604
1602 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); 1605 WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
1603 chrome::ViewType view_type = chrome::GetViewType(web_contents); 1606 chrome::ViewType view_type = chrome::GetViewType(web_contents);
1604 ExtensionService* service = profile->GetExtensionService(); 1607 ExtensionService* service = profile->GetExtensionService();
1605 if (service) { 1608 if (service) {
1606 const Extension* extension = service->extensions()->GetByID( 1609 const GURL& url = rvh->GetSiteInstance()->GetSiteURL();
1607 rvh->GetSiteInstance()->GetSiteURL().host()); 1610 const Extension* extension = service->extensions()->GetByID(url.host());
1608 extension_webkit_preferences::SetPreferences( 1611 // Guests are not extensions, so they should not be given any extra
1609 extension, view_type, web_prefs); 1612 // privileges.
1613 if (!url.SchemeIs(chrome::kGuestScheme)) {
awong 2012/10/27 00:10:52 Should this be whitelist instead? SchemeIs(chrome
nasko 2012/10/27 00:28:12 Since this is very rushed CL, I'd rather be more d
1614 extension_webkit_preferences::SetPreferences(
1615 extension, view_type, web_prefs);
1616 }
1610 } 1617 }
1611 1618
1612 if (content::IsForceCompositingModeEnabled()) 1619 if (content::IsForceCompositingModeEnabled())
1613 web_prefs->force_compositing_mode = true; 1620 web_prefs->force_compositing_mode = true;
1614 1621
1615 if (view_type == chrome::VIEW_TYPE_NOTIFICATION) { 1622 if (view_type == chrome::VIEW_TYPE_NOTIFICATION) {
1616 web_prefs->allow_scripts_to_close_windows = true; 1623 web_prefs->allow_scripts_to_close_windows = true;
1617 } else if (view_type == chrome::VIEW_TYPE_BACKGROUND_CONTENTS) { 1624 } else if (view_type == chrome::VIEW_TYPE_BACKGROUND_CONTENTS) {
1618 // Disable all kinds of acceleration for background pages. 1625 // Disable all kinds of acceleration for background pages.
1619 // See http://crbug.com/96005 and http://crbug.com/96006 1626 // See http://crbug.com/96005 and http://crbug.com/96006
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 partition_id = extension->id(); 1883 partition_id = extension->id();
1877 } 1884 }
1878 1885
1879 // Enforce that IsValidStoragePartitionId() implementation stays in sync. 1886 // Enforce that IsValidStoragePartitionId() implementation stays in sync.
1880 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); 1887 DCHECK(IsValidStoragePartitionId(browser_context, partition_id));
1881 return partition_id; 1888 return partition_id;
1882 } 1889 }
1883 1890
1884 1891
1885 } // namespace chrome 1892 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/web_view_browsertest.cc » ('j') | chrome/browser/extensions/web_view_browsertest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698