| 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 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 | 1515 |
| 1526 bool ChromeContentBrowserClient::AllowSocketAPI( | 1516 bool ChromeContentBrowserClient::AllowSocketAPI( |
| 1527 content::BrowserContext* browser_context, const GURL& url) { | 1517 content::BrowserContext* browser_context, const GURL& url) { |
| 1528 if (!url.is_valid()) | 1518 if (!url.is_valid()) |
| 1529 return false; | 1519 return false; |
| 1530 | 1520 |
| 1531 std::string host = url.host(); | 1521 std::string host = url.host(); |
| 1532 if (allowed_socket_origins_.count(host)) | 1522 if (allowed_socket_origins_.count(host)) |
| 1533 return true; | 1523 return true; |
| 1534 | 1524 |
| 1525 // Need to check this now and not on construction because otherwise it won't |
| 1526 // work with browser_tests. |
| 1527 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 1528 std::string allowed_list = |
| 1529 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI); |
| 1530 if (!allowed_list.empty()) { |
| 1531 StringTokenizer t(allowed_list, ","); |
| 1532 while (t.GetNext()) { |
| 1533 if (t.token() == host) |
| 1534 return true; |
| 1535 } |
| 1536 } |
| 1537 |
| 1535 Profile* profile = Profile::FromBrowserContext(browser_context); | 1538 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 1536 if (!profile || !profile->GetExtensionService()) | 1539 if (!profile || !profile->GetExtensionService()) |
| 1537 return false; | 1540 return false; |
| 1538 | 1541 |
| 1539 const Extension* extension = profile->GetExtensionService()->extensions()-> | 1542 const Extension* extension = profile->GetExtensionService()->extensions()-> |
| 1540 GetExtensionOrAppByURL(ExtensionURLInfo(url)); | 1543 GetExtensionOrAppByURL(ExtensionURLInfo(url)); |
| 1541 if (!extension) | 1544 if (!extension) |
| 1542 return false; | 1545 return false; |
| 1543 | 1546 |
| 1544 if (extension->HasAPIPermission(ExtensionAPIPermission::kSocket)) | 1547 if (extension->HasAPIPermission(ExtensionAPIPermission::kSocket)) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1590 #if defined(USE_NSS) | 1593 #if defined(USE_NSS) |
| 1591 crypto::CryptoModuleBlockingPasswordDelegate* | 1594 crypto::CryptoModuleBlockingPasswordDelegate* |
| 1592 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 1595 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
| 1593 const GURL& url) { | 1596 const GURL& url) { |
| 1594 return browser::NewCryptoModuleBlockingDialogDelegate( | 1597 return browser::NewCryptoModuleBlockingDialogDelegate( |
| 1595 browser::kCryptoModulePasswordKeygen, url.host()); | 1598 browser::kCryptoModulePasswordKeygen, url.host()); |
| 1596 } | 1599 } |
| 1597 #endif | 1600 #endif |
| 1598 | 1601 |
| 1599 } // namespace chrome | 1602 } // namespace chrome |
| OLD | NEW |