| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/string_tokenizer.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/app/breakpad_mac.h" | 15 #include "chrome/app/breakpad_mac.h" |
| 15 #include "chrome/browser/browser_about_handler.h" | 16 #include "chrome/browser/browser_about_handler.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/browsing_data_remover.h" | 18 #include "chrome/browser/browsing_data_remover.h" |
| 18 #include "chrome/browser/character_encoding.h" | 19 #include "chrome/browser/character_encoding.h" |
| 19 #include "chrome/browser/chrome_benchmarking_message_filter.h" | 20 #include "chrome/browser/chrome_benchmarking_message_filter.h" |
| 20 #include "chrome/browser/chrome_quota_permission_context.h" | 21 #include "chrome/browser/chrome_quota_permission_context.h" |
| 21 #include "chrome/browser/content_settings/content_settings_utils.h" | 22 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 22 #include "chrome/browser/content_settings/cookie_settings.h" | 23 #include "chrome/browser/content_settings/cookie_settings.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 #endif | 131 #endif |
| 131 | 132 |
| 132 using content::AccessTokenStore; | 133 using content::AccessTokenStore; |
| 133 using content::BrowserThread; | 134 using content::BrowserThread; |
| 134 using content::ChildProcessSecurityPolicy; | 135 using content::ChildProcessSecurityPolicy; |
| 135 using content::SiteInstance; | 136 using content::SiteInstance; |
| 136 using content::WebContents; | 137 using content::WebContents; |
| 137 | 138 |
| 138 namespace { | 139 namespace { |
| 139 | 140 |
| 141 const char* kPredefinedAllowedSocketOrigins[] = { |
| 142 "okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client |
| 143 "pnhechapfaindjhompbnflcldabbghjo" // HTerm App (SSH Client) |
| 144 }; |
| 145 |
| 140 // Handles rewriting Web UI URLs. | 146 // Handles rewriting Web UI URLs. |
| 141 bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { | 147 bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { |
| 142 if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL( | 148 if (!ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL( |
| 143 browser_context, *url)) | 149 browser_context, *url)) |
| 144 return false; | 150 return false; |
| 145 | 151 |
| 146 // Special case the new tab page. In older versions of Chrome, the new tab | 152 // Special case the new tab page. In older versions of Chrome, the new tab |
| 147 // page was hosted at chrome-internal:<blah>. This might be in people's saved | 153 // page was hosted at chrome-internal:<blah>. This might be in people's saved |
| 148 // sessions or bookmarks, so we say any URL with that scheme triggers the new | 154 // sessions or bookmarks, so we say any URL with that scheme triggers the new |
| 149 // tab page. | 155 // tab page. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 std::string font_family = prefs->GetString(pref_name.c_str()); | 268 std::string font_family = prefs->GetString(pref_name.c_str()); |
| 263 if (!font_family.empty()) | 269 if (!font_family.empty()) |
| 264 map->push_back(std::make_pair(script, UTF8ToUTF16(font_family))); | 270 map->push_back(std::make_pair(script, UTF8ToUTF16(font_family))); |
| 265 } | 271 } |
| 266 } | 272 } |
| 267 | 273 |
| 268 } // namespace | 274 } // namespace |
| 269 | 275 |
| 270 namespace chrome { | 276 namespace chrome { |
| 271 | 277 |
| 278 ChromeContentBrowserClient::ChromeContentBrowserClient() { |
| 279 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
| 280 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
| 281 |
| 282 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 283 std::string allowed_list = |
| 284 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI); |
| 285 if (!allowed_list.empty()) { |
| 286 StringTokenizer t(allowed_list, ","); |
| 287 while (t.GetNext()) { |
| 288 allowed_socket_origins_.insert(t.token()); |
| 289 } |
| 290 } |
| 291 } |
| 292 |
| 293 ChromeContentBrowserClient::~ChromeContentBrowserClient() { |
| 294 } |
| 295 |
| 272 content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts( | 296 content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts( |
| 273 const content::MainFunctionParams& parameters) { | 297 const content::MainFunctionParams& parameters) { |
| 274 ChromeBrowserMainParts* main_parts; | 298 ChromeBrowserMainParts* main_parts; |
| 275 // Construct the Main browser parts based on the OS type. | 299 // Construct the Main browser parts based on the OS type. |
| 276 #if defined(OS_WIN) | 300 #if defined(OS_WIN) |
| 277 main_parts = new ChromeBrowserMainPartsWin(parameters); | 301 main_parts = new ChromeBrowserMainPartsWin(parameters); |
| 278 #elif defined(OS_MACOSX) | 302 #elif defined(OS_MACOSX) |
| 279 main_parts = new ChromeBrowserMainPartsMac(parameters); | 303 main_parts = new ChromeBrowserMainPartsMac(parameters); |
| 280 #elif defined(OS_CHROMEOS) | 304 #elif defined(OS_CHROMEOS) |
| 281 main_parts = new ChromeBrowserMainPartsChromeos(parameters); | 305 main_parts = new ChromeBrowserMainPartsChromeos(parameters); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 if (local_state && | 657 if (local_state && |
| 634 !local_state->GetBoolean(prefs::kPrintPreviewDisabled)) { | 658 !local_state->GetBoolean(prefs::kPrintPreviewDisabled)) { |
| 635 command_line->AppendSwitch(switches::kRendererPrintPreview); | 659 command_line->AppendSwitch(switches::kRendererPrintPreview); |
| 636 } | 660 } |
| 637 } | 661 } |
| 638 | 662 |
| 639 // Please keep this in alphabetical order. | 663 // Please keep this in alphabetical order. |
| 640 static const char* const kSwitchNames[] = { | 664 static const char* const kSwitchNames[] = { |
| 641 switches::kAllowHTTPBackgroundPage, | 665 switches::kAllowHTTPBackgroundPage, |
| 642 switches::kAllowLegacyExtensionManifests, | 666 switches::kAllowLegacyExtensionManifests, |
| 643 switches::kAllowNaClSocketAPI, | |
| 644 switches::kAllowScriptingGallery, | 667 switches::kAllowScriptingGallery, |
| 645 switches::kAppsCheckoutURL, | 668 switches::kAppsCheckoutURL, |
| 646 switches::kAppsGalleryURL, | 669 switches::kAppsGalleryURL, |
| 647 switches::kCloudPrintServiceURL, | 670 switches::kCloudPrintServiceURL, |
| 648 switches::kDebugPrint, | 671 switches::kDebugPrint, |
| 649 switches::kDumpHistogramsOnExit, | 672 switches::kDumpHistogramsOnExit, |
| 650 switches::kEnableAsynchronousSpellChecking, | 673 switches::kEnableAsynchronousSpellChecking, |
| 651 switches::kEnableBenchmarking, | 674 switches::kEnableBenchmarking, |
| 652 switches::kEnableCrxlessWebApps, | 675 switches::kEnableCrxlessWebApps, |
| 653 switches::kEnableExperimentalExtensionApis, | 676 switches::kEnableExperimentalExtensionApis, |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 } | 1326 } |
| 1304 | 1327 |
| 1305 FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { | 1328 FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
| 1306 return download_util::GetDefaultDownloadDirectory(); | 1329 return download_util::GetDefaultDownloadDirectory(); |
| 1307 } | 1330 } |
| 1308 | 1331 |
| 1309 std::string ChromeContentBrowserClient::GetDefaultDownloadName() { | 1332 std::string ChromeContentBrowserClient::GetDefaultDownloadName() { |
| 1310 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); | 1333 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); |
| 1311 } | 1334 } |
| 1312 | 1335 |
| 1336 bool ChromeContentBrowserClient::AllowSocketAPI(const GURL& url) { |
| 1337 return url.is_valid() && |
| 1338 allowed_socket_origins_.find(url.host()) != allowed_socket_origins_.end(); |
| 1339 } |
| 1340 |
| 1313 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1341 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 1314 int ChromeContentBrowserClient::GetCrashSignalFD( | 1342 int ChromeContentBrowserClient::GetCrashSignalFD( |
| 1315 const CommandLine& command_line) { | 1343 const CommandLine& command_line) { |
| 1316 #if defined(OS_ANDROID) | 1344 #if defined(OS_ANDROID) |
| 1317 // TODO(carlosvaldivia): Upstream breakpad code for Android and remove this | 1345 // TODO(carlosvaldivia): Upstream breakpad code for Android and remove this |
| 1318 // fork. http://crbug.com/113560 | 1346 // fork. http://crbug.com/113560 |
| 1319 NOTIMPLEMENTED(); | 1347 NOTIMPLEMENTED(); |
| 1320 #else | 1348 #else |
| 1321 if (command_line.HasSwitch(switches::kExtensionProcess)) { | 1349 if (command_line.HasSwitch(switches::kExtensionProcess)) { |
| 1322 ExtensionCrashHandlerHostLinux* crash_handler = | 1350 ExtensionCrashHandlerHostLinux* crash_handler = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1353 #if defined(USE_NSS) | 1381 #if defined(USE_NSS) |
| 1354 crypto::CryptoModuleBlockingPasswordDelegate* | 1382 crypto::CryptoModuleBlockingPasswordDelegate* |
| 1355 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 1383 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
| 1356 const GURL& url) { | 1384 const GURL& url) { |
| 1357 return browser::NewCryptoModuleBlockingDialogDelegate( | 1385 return browser::NewCryptoModuleBlockingDialogDelegate( |
| 1358 browser::kCryptoModulePasswordKeygen, url.host()); | 1386 browser::kCryptoModulePasswordKeygen, url.host()); |
| 1359 } | 1387 } |
| 1360 #endif | 1388 #endif |
| 1361 | 1389 |
| 1362 } // namespace chrome | 1390 } // namespace chrome |
| OLD | NEW |