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

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

Issue 10831116: Move SessionStorageNamespace entirely into NavigationController and support StoragePartitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 8 years, 4 months 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 406
407 std::string ChromeContentBrowserClient::GetStoragePartitionIdForChildProcess( 407 std::string ChromeContentBrowserClient::GetStoragePartitionIdForChildProcess(
408 content::BrowserContext* browser_context, 408 content::BrowserContext* browser_context,
409 int child_process_id) { 409 int child_process_id) {
410 // In chrome, we use the extension ID as the partition ID. This works well 410 // In chrome, we use the extension ID as the partition ID. This works well
411 // because the extension ID fits the partition ID pattern and currently only 411 // because the extension ID fits the partition ID pattern and currently only
412 // apps can designate that storage should be isolated. 412 // apps can designate that storage should be isolated.
413 Profile* profile = Profile::FromBrowserContext(browser_context); 413 Profile* profile = Profile::FromBrowserContext(browser_context);
414 ExtensionService* extension_service = 414 ExtensionService* extension_service =
415 extensions::ExtensionSystem::Get(profile)->extension_service(); 415 extensions::ExtensionSystem::Get(profile)->extension_service();
416 std::string partition_id;
416 if (extension_service) { 417 if (extension_service) {
417 const extensions::Extension* installed_app = extension_service-> 418 const extensions::Extension* extension = extension_service->
418 GetInstalledAppForRenderer(child_process_id); 419 GetInstalledAppForRenderer(child_process_id);
419 if (installed_app && installed_app->is_storage_isolated()) { 420 if (extension && extension->is_storage_isolated()) {
420 return installed_app->id(); 421 partition_id = extension->id();
421 } 422 }
422 } 423 }
423 return std::string(); 424
425 // Enforce that IsValidStoragePartitionId() implementation stays in sync.
426 DCHECK(IsValidStoragePartitionId(browser_context, partition_id));
427 return partition_id;
428 }
429
430 std::string ChromeContentBrowserClient::GetStoragePartitionIdForSiteInstance(
431 content::BrowserContext* browser_context,
432 SiteInstance* instance) {
433 // In chrome, we use the extension ID as the partition ID. This works well
434 // because the extension ID fits the partition ID pattern and currently only
435 // apps can designate that storage should be isolated.
436 Profile* profile = Profile::FromBrowserContext(browser_context);
437 ExtensionService* extension_service =
438 extensions::ExtensionSystem::Get(profile)->extension_service();
439 std::string partition_id;
440 if (extension_service) {
441 const Extension* extension = extension_service->extensions()->
442 GetExtensionOrAppByURL(ExtensionURLInfo(instance->GetSite()));
443 if (extension && extension->is_storage_isolated()) {
Charlie Reis 2012/08/13 19:39:22 As mentioned, please share from here down in a hel
awong 2012/08/13 21:29:19 Done.
444 partition_id = extension->id();
445 }
446 }
447
448 // Enforce that IsValidStoragePartitionId() implementation stays in sync.
449 DCHECK(IsValidStoragePartitionId(browser_context, partition_id));
450 return partition_id;
451 }
452
453 bool ChromeContentBrowserClient::IsValidStoragePartitionId(
454 content::BrowserContext* browser_context,
455 const std::string& partition_id) {
456 // The default ID is empty which is always allowed.
457 if (partition_id.empty())
458 return true;
459
460 // If it isn't empty, then it must belong to an extension of some sort. Parse
461 // out the extension ID and make sure it is still installed.
462 Profile* profile = Profile::FromBrowserContext(browser_context);
463 ExtensionService* extension_service =
464 extensions::ExtensionSystem::Get(profile)->extension_service();
465 if (!extension_service) {
466 // No extension service means no storage partitions in Chrome.
467 return false;
468 }
469
470 // See if we can find an extension. The |partition_id| is the extension ID so
471 // no parsing needed to be done.
472 return extension_service->GetExtensionById(partition_id, false) != NULL;
424 } 473 }
425 474
426 content::WebContentsViewDelegate* 475 content::WebContentsViewDelegate*
427 ChromeContentBrowserClient::GetWebContentsViewDelegate( 476 ChromeContentBrowserClient::GetWebContentsViewDelegate(
428 content::WebContents* web_contents) { 477 content::WebContents* web_contents) {
429 return chrome::CreateWebContentsViewDelegate(web_contents); 478 return chrome::CreateWebContentsViewDelegate(web_contents);
430 } 479 }
431 480
432 void ChromeContentBrowserClient::RenderViewHostCreated( 481 void ChromeContentBrowserClient::RenderViewHostCreated(
433 RenderViewHost* render_view_host) { 482 RenderViewHost* render_view_host) {
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 io_thread_application_locale_ = locale; 1730 io_thread_application_locale_ = locale;
1682 } 1731 }
1683 1732
1684 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( 1733 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread(
1685 const std::string& locale) { 1734 const std::string& locale) {
1686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1735 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1687 io_thread_application_locale_ = locale; 1736 io_thread_application_locale_ = locale;
1688 } 1737 }
1689 1738
1690 } // namespace chrome 1739 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698