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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 281 } |
282 } | 282 } |
283 | 283 |
284 } // namespace | 284 } // namespace |
285 | 285 |
286 namespace chrome { | 286 namespace chrome { |
287 | 287 |
288 ChromeContentBrowserClient::ChromeContentBrowserClient() { | 288 ChromeContentBrowserClient::ChromeContentBrowserClient() { |
289 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) | 289 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
290 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); | 290 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
291 | |
292 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
293 std::string allowed_list = | |
294 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI); | |
295 if (!allowed_list.empty()) { | |
296 StringTokenizer t(allowed_list, ","); | |
297 while (t.GetNext()) { | |
298 allowed_socket_origins_.insert(t.token()); | |
299 } | |
300 } | |
301 } | 291 } |
302 | 292 |
303 ChromeContentBrowserClient::~ChromeContentBrowserClient() { | 293 ChromeContentBrowserClient::~ChromeContentBrowserClient() { |
304 } | 294 } |
305 | 295 |
306 content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts( | 296 content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts( |
307 const content::MainFunctionParams& parameters) { | 297 const content::MainFunctionParams& parameters) { |
308 ChromeBrowserMainParts* main_parts; | 298 ChromeBrowserMainParts* main_parts; |
309 // Construct the Main browser parts based on the OS type. | 299 // Construct the Main browser parts based on the OS type. |
310 #if defined(OS_WIN) | 300 #if defined(OS_WIN) |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 | 1520 |
1531 bool ChromeContentBrowserClient::AllowSocketAPI( | 1521 bool ChromeContentBrowserClient::AllowSocketAPI( |
1532 content::BrowserContext* browser_context, const GURL& url) { | 1522 content::BrowserContext* browser_context, const GURL& url) { |
1533 if (!url.is_valid()) | 1523 if (!url.is_valid()) |
1534 return false; | 1524 return false; |
1535 | 1525 |
1536 std::string host = url.host(); | 1526 std::string host = url.host(); |
1537 if (allowed_socket_origins_.count(host)) | 1527 if (allowed_socket_origins_.count(host)) |
1538 return true; | 1528 return true; |
1539 | 1529 |
| 1530 // Need to check this now and not on construction because otherwise it won't |
| 1531 // work with browser_tests. |
| 1532 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 1533 std::string allowed_list = |
| 1534 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI); |
| 1535 if (!allowed_list.empty()) { |
| 1536 StringTokenizer t(allowed_list, ","); |
| 1537 while (t.GetNext()) { |
| 1538 if (t.token() == host) |
| 1539 return true; |
| 1540 } |
| 1541 } |
| 1542 |
1540 Profile* profile = Profile::FromBrowserContext(browser_context); | 1543 Profile* profile = Profile::FromBrowserContext(browser_context); |
1541 if (!profile || !profile->GetExtensionService()) | 1544 if (!profile || !profile->GetExtensionService()) |
1542 return false; | 1545 return false; |
1543 | 1546 |
1544 const Extension* extension = profile->GetExtensionService()->extensions()-> | 1547 const Extension* extension = profile->GetExtensionService()->extensions()-> |
1545 GetExtensionOrAppByURL(ExtensionURLInfo(url)); | 1548 GetExtensionOrAppByURL(ExtensionURLInfo(url)); |
1546 if (!extension) | 1549 if (!extension) |
1547 return false; | 1550 return false; |
1548 | 1551 |
1549 if (extension->HasAPIPermission(ExtensionAPIPermission::kSocket)) | 1552 if (extension->HasAPIPermission(ExtensionAPIPermission::kSocket)) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 #if defined(USE_NSS) | 1598 #if defined(USE_NSS) |
1596 crypto::CryptoModuleBlockingPasswordDelegate* | 1599 crypto::CryptoModuleBlockingPasswordDelegate* |
1597 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 1600 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
1598 const GURL& url) { | 1601 const GURL& url) { |
1599 return browser::NewCryptoModuleBlockingDialogDelegate( | 1602 return browser::NewCryptoModuleBlockingDialogDelegate( |
1600 browser::kCryptoModulePasswordKeygen, url.host()); | 1603 browser::kCryptoModulePasswordKeygen, url.host()); |
1601 } | 1604 } |
1602 #endif | 1605 #endif |
1603 | 1606 |
1604 } // namespace chrome | 1607 } // namespace chrome |
OLD | NEW |