| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 #include "chrome/browser/user_style_sheet_watcher.h" | 73 #include "chrome/browser/user_style_sheet_watcher.h" |
| 74 #include "chrome/browser/user_style_sheet_watcher_factory.h" | 74 #include "chrome/browser/user_style_sheet_watcher_factory.h" |
| 75 #include "chrome/browser/view_type_utils.h" | 75 #include "chrome/browser/view_type_utils.h" |
| 76 #include "chrome/common/child_process_logging.h" | 76 #include "chrome/common/child_process_logging.h" |
| 77 #include "chrome/common/chrome_constants.h" | 77 #include "chrome/common/chrome_constants.h" |
| 78 #include "chrome/common/chrome_paths.h" | 78 #include "chrome/common/chrome_paths.h" |
| 79 #include "chrome/common/chrome_switches.h" | 79 #include "chrome/common/chrome_switches.h" |
| 80 #include "chrome/common/extensions/extension.h" | 80 #include "chrome/common/extensions/extension.h" |
| 81 #include "chrome/common/extensions/extension_process_policy.h" | 81 #include "chrome/common/extensions/extension_process_policy.h" |
| 82 #include "chrome/common/extensions/extension_set.h" | 82 #include "chrome/common/extensions/extension_set.h" |
| 83 #include "chrome/common/extensions/permissions/socket_permission.h" |
| 83 #include "chrome/common/logging_chrome.h" | 84 #include "chrome/common/logging_chrome.h" |
| 84 #include "chrome/common/pref_names.h" | 85 #include "chrome/common/pref_names.h" |
| 85 #include "chrome/common/render_messages.h" | 86 #include "chrome/common/render_messages.h" |
| 86 #include "chrome/common/url_constants.h" | 87 #include "chrome/common/url_constants.h" |
| 87 #include "content/public/browser/browser_child_process_host.h" | 88 #include "content/public/browser/browser_child_process_host.h" |
| 88 #include "content/public/browser/browser_main_parts.h" | 89 #include "content/public/browser/browser_main_parts.h" |
| 89 #include "content/public/browser/browser_ppapi_host.h" | 90 #include "content/public/browser/browser_ppapi_host.h" |
| 90 #include "content/public/browser/browser_url_handler.h" | 91 #include "content/public/browser/browser_url_handler.h" |
| 91 #include "content/public/browser/child_process_security_policy.h" | 92 #include "content/public/browser/child_process_security_policy.h" |
| 92 #include "content/public/browser/render_process_host.h" | 93 #include "content/public/browser/render_process_host.h" |
| (...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 } | 1693 } |
| 1693 | 1694 |
| 1694 void ChromeContentBrowserClient::DidCreatePpapiPlugin( | 1695 void ChromeContentBrowserClient::DidCreatePpapiPlugin( |
| 1695 content::BrowserPpapiHost* browser_host) { | 1696 content::BrowserPpapiHost* browser_host) { |
| 1696 browser_host->GetPpapiHost()->AddHostFactoryFilter( | 1697 browser_host->GetPpapiHost()->AddHostFactoryFilter( |
| 1697 scoped_ptr<ppapi::host::HostFactory>( | 1698 scoped_ptr<ppapi::host::HostFactory>( |
| 1698 new ChromeBrowserPepperHostFactory(browser_host))); | 1699 new ChromeBrowserPepperHostFactory(browser_host))); |
| 1699 } | 1700 } |
| 1700 | 1701 |
| 1701 bool ChromeContentBrowserClient::AllowPepperSocketAPI( | 1702 bool ChromeContentBrowserClient::AllowPepperSocketAPI( |
| 1702 content::BrowserContext* browser_context, const GURL& url) { | 1703 content::BrowserContext* browser_context, |
| 1704 const GURL& url, |
| 1705 const content::SocketPermissionRequest& params) { |
| 1703 if (!url.is_valid()) | 1706 if (!url.is_valid()) |
| 1704 return false; | 1707 return false; |
| 1705 | 1708 |
| 1706 std::string host = url.host(); | 1709 std::string host = url.host(); |
| 1707 if (url.SchemeIs(kExtensionScheme) && allowed_socket_origins_.count(host)) | 1710 if (url.SchemeIs(kExtensionScheme) && allowed_socket_origins_.count(host)) |
| 1708 return true; | 1711 return true; |
| 1709 | 1712 |
| 1710 Profile* profile = Profile::FromBrowserContext(browser_context); | 1713 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 1711 const Extension* extension = NULL; | 1714 const Extension* extension = NULL; |
| 1712 if (profile && profile->GetExtensionService()) { | 1715 if (profile && profile->GetExtensionService()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1728 StringTokenizer t(allowed_list, ","); | 1731 StringTokenizer t(allowed_list, ","); |
| 1729 while (t.GetNext()) { | 1732 while (t.GetNext()) { |
| 1730 if (t.token() == host) | 1733 if (t.token() == host) |
| 1731 return true; | 1734 return true; |
| 1732 } | 1735 } |
| 1733 } | 1736 } |
| 1734 | 1737 |
| 1735 if (!extension) | 1738 if (!extension) |
| 1736 return false; | 1739 return false; |
| 1737 | 1740 |
| 1738 if (extension->HasAPIPermission(APIPermission::kSocket)) | 1741 extensions::SocketPermission::CheckParam extension_params( |
| 1742 params.type, params.host, params.port); |
| 1743 if (extension->CheckAPIPermissionWithParam(APIPermission::kSocket, |
| 1744 &extension_params)) |
| 1739 return true; | 1745 return true; |
| 1740 | 1746 |
| 1741 return false; | 1747 return false; |
| 1742 } | 1748 } |
| 1743 | 1749 |
| 1744 bool ChromeContentBrowserClient::AllowPepperPrivateFileAPI() { | 1750 bool ChromeContentBrowserClient::AllowPepperPrivateFileAPI() { |
| 1745 return CommandLine::ForCurrentProcess()->HasSwitch( | 1751 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 1746 switches::kPpapiFlashInProcess); | 1752 switches::kPpapiFlashInProcess); |
| 1747 } | 1753 } |
| 1748 | 1754 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 partition_id = extension->id(); | 1852 partition_id = extension->id(); |
| 1847 } | 1853 } |
| 1848 | 1854 |
| 1849 // Enforce that IsValidStoragePartitionId() implementation stays in sync. | 1855 // Enforce that IsValidStoragePartitionId() implementation stays in sync. |
| 1850 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); | 1856 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); |
| 1851 return partition_id; | 1857 return partition_id; |
| 1852 } | 1858 } |
| 1853 | 1859 |
| 1854 | 1860 |
| 1855 } // namespace chrome | 1861 } // namespace chrome |
| OLD | NEW |