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

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

Issue 10993078: Use extensions socket permission for TCP/UDP socket APIs in Pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed Android build 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/compositor_util.h" 93 #include "content/public/browser/compositor_util.h"
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 } 1707 }
1707 1708
1708 void ChromeContentBrowserClient::DidCreatePpapiPlugin( 1709 void ChromeContentBrowserClient::DidCreatePpapiPlugin(
1709 content::BrowserPpapiHost* browser_host) { 1710 content::BrowserPpapiHost* browser_host) {
1710 browser_host->GetPpapiHost()->AddHostFactoryFilter( 1711 browser_host->GetPpapiHost()->AddHostFactoryFilter(
1711 scoped_ptr<ppapi::host::HostFactory>( 1712 scoped_ptr<ppapi::host::HostFactory>(
1712 new ChromeBrowserPepperHostFactory(browser_host))); 1713 new ChromeBrowserPepperHostFactory(browser_host)));
1713 } 1714 }
1714 1715
1715 bool ChromeContentBrowserClient::AllowPepperSocketAPI( 1716 bool ChromeContentBrowserClient::AllowPepperSocketAPI(
1716 content::BrowserContext* browser_context, const GURL& url) { 1717 content::BrowserContext* browser_context,
1718 const GURL& url,
1719 const content::SocketPermissionRequest& params) {
1717 if (!url.is_valid()) 1720 if (!url.is_valid())
1718 return false; 1721 return false;
1719 1722
1720 std::string host = url.host(); 1723 std::string host = url.host();
1721 if (url.SchemeIs(kExtensionScheme) && allowed_socket_origins_.count(host)) 1724 if (url.SchemeIs(kExtensionScheme) && allowed_socket_origins_.count(host))
1722 return true; 1725 return true;
1723 1726
1724 Profile* profile = Profile::FromBrowserContext(browser_context); 1727 Profile* profile = Profile::FromBrowserContext(browser_context);
1725 const Extension* extension = NULL; 1728 const Extension* extension = NULL;
1726 if (profile && profile->GetExtensionService()) { 1729 if (profile && profile->GetExtensionService()) {
(...skipping 15 matching lines...) Expand all
1742 StringTokenizer t(allowed_list, ","); 1745 StringTokenizer t(allowed_list, ",");
1743 while (t.GetNext()) { 1746 while (t.GetNext()) {
1744 if (t.token() == host) 1747 if (t.token() == host)
1745 return true; 1748 return true;
1746 } 1749 }
1747 } 1750 }
1748 1751
1749 if (!extension) 1752 if (!extension)
1750 return false; 1753 return false;
1751 1754
1752 if (extension->HasAPIPermission(APIPermission::kSocket)) 1755 extensions::SocketPermission::CheckParam extension_params(
1756 params.type, params.host, params.port);
1757 if (extension->CheckAPIPermissionWithParam(APIPermission::kSocket,
1758 &extension_params))
1753 return true; 1759 return true;
1754 1760
1755 return false; 1761 return false;
1756 } 1762 }
1757 1763
1758 bool ChromeContentBrowserClient::AllowPepperPrivateFileAPI() { 1764 bool ChromeContentBrowserClient::AllowPepperPrivateFileAPI() {
1759 return CommandLine::ForCurrentProcess()->HasSwitch( 1765 return CommandLine::ForCurrentProcess()->HasSwitch(
1760 switches::kPpapiFlashInProcess); 1766 switches::kPpapiFlashInProcess);
1761 } 1767 }
1762 1768
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 partition_id = extension->id(); 1887 partition_id = extension->id();
1882 } 1888 }
1883 1889
1884 // Enforce that IsValidStoragePartitionId() implementation stays in sync. 1890 // Enforce that IsValidStoragePartitionId() implementation stays in sync.
1885 DCHECK(IsValidStoragePartitionId(browser_context, partition_id)); 1891 DCHECK(IsValidStoragePartitionId(browser_context, partition_id));
1886 return partition_id; 1892 return partition_id;
1887 } 1893 }
1888 1894
1889 1895
1890 } // namespace chrome 1896 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/browser/extensions/api/socket/socket_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698