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

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: mac win compile fixes 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* installed_app = extension_service->
418 GetInstalledAppForRenderer(child_process_id); 419 GetInstalledAppForRenderer(child_process_id);
Charlie Reis 2012/08/06 20:38:30 Huh, this API doesn't make sense. There can be mu
419 if (installed_app && installed_app->is_storage_isolated()) { 420 if (installed_app && installed_app->is_storage_isolated()) {
420 return installed_app->id(); 421 partition_id = installed_app->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()));
Charlie Reis 2012/08/06 20:38:30 These two functions are identical except in how th
awong 2012/08/08 18:08:28 I'm not sure how I'd extract something that wouldn
Charlie Reis 2012/08/13 19:39:21 Even if we're just sharing the last few lines and
awong 2012/08/13 21:29:19 Done.
443 if (extension && extension->is_storage_isolated()) {
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()) {
Charlie Reis 2012/08/06 20:38:30 nit: No braces.
awong 2012/08/08 18:08:28 Done.
458 return true;
459 }
460
461 // If it isn't empty, then it must belong to an extension of some sort. Parse
462 // out the extension ID and make sure it is still installed.
463 Profile* profile = Profile::FromBrowserContext(browser_context);
464 ExtensionService* extension_service =
465 extensions::ExtensionSystem::Get(profile)->extension_service();
466 if (!extension_service) {
467 // No extension service means no storage partitions in Chrome.
468 return false;
469 }
470
471 // See if we can find an extension. The |partition_id| is the extension ID so
472 // no parsing needed to be done.
473 return extension_service->GetExtensionById(partition_id, false) != NULL;
424 } 474 }
425 475
426 content::WebContentsViewDelegate* 476 content::WebContentsViewDelegate*
427 ChromeContentBrowserClient::GetWebContentsViewDelegate( 477 ChromeContentBrowserClient::GetWebContentsViewDelegate(
428 content::WebContents* web_contents) { 478 content::WebContents* web_contents) {
429 return chrome::CreateWebContentsViewDelegate(web_contents); 479 return chrome::CreateWebContentsViewDelegate(web_contents);
430 } 480 }
431 481
432 void ChromeContentBrowserClient::RenderViewHostCreated( 482 void ChromeContentBrowserClient::RenderViewHostCreated(
433 RenderViewHost* render_view_host) { 483 RenderViewHost* render_view_host) {
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 io_thread_application_locale_ = locale; 1731 io_thread_application_locale_ = locale;
1682 } 1732 }
1683 1733
1684 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( 1734 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread(
1685 const std::string& locale) { 1735 const std::string& locale) {
1686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1687 io_thread_application_locale_ = locale; 1737 io_thread_application_locale_ = locale;
1688 } 1738 }
1689 1739
1690 } // namespace chrome 1740 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698