| 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 if (new_host.empty()) | 506 if (new_host.empty()) |
| 507 return false; | 507 return false; |
| 508 | 508 |
| 509 *url = ReplaceURLHostAndPath(*url, new_host, new_path); | 509 *url = ReplaceURLHostAndPath(*url, new_host, new_path); |
| 510 | 510 |
| 511 DCHECK(url->is_valid()); | 511 DCHECK(url->is_valid()); |
| 512 | 512 |
| 513 return true; | 513 return true; |
| 514 } | 514 } |
| 515 | 515 |
| 516 // Handles the rewriting of the new tab page URL based on group policy. |
| 517 bool HandleNewTabPageLocationOverride( |
| 518 GURL* url, |
| 519 content::BrowserContext* browser_context) { |
| 520 if (!url->SchemeIs(content::kChromeUIScheme) || |
| 521 url->host() != chrome::kChromeUINewTabHost) |
| 522 return false; |
| 523 |
| 524 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 525 std::string ntp_location = |
| 526 profile->GetPrefs()->GetString(prefs::kNewTabPageLocationOverride); |
| 527 if (ntp_location.empty()) |
| 528 return false; |
| 529 |
| 530 *url = GURL(ntp_location); |
| 531 return true; |
| 532 } |
| 533 |
| 516 // Handles rewriting Web UI URLs. | 534 // Handles rewriting Web UI URLs. |
| 517 bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { | 535 bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) { |
| 518 // Do not handle special URLs such as "about:foo" | 536 // Do not handle special URLs such as "about:foo" |
| 519 if (!url->host().empty()) { | 537 if (!url->host().empty()) { |
| 520 const GURL chrome_url = AddUberHost(*url); | 538 const GURL chrome_url = AddUberHost(*url); |
| 521 | 539 |
| 522 // Handle valid "chrome://chrome/foo" URLs so the reverse handler will | 540 // Handle valid "chrome://chrome/foo" URLs so the reverse handler will |
| 523 // be called. | 541 // be called. |
| 524 if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL( | 542 if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL( |
| 525 browser_context, chrome_url)) | 543 browser_context, chrome_url)) |
| (...skipping 2022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2548 for (size_t i = 0; i < extra_parts_.size(); ++i) | 2566 for (size_t i = 0; i < extra_parts_.size(); ++i) |
| 2549 extra_parts_[i]->BrowserURLHandlerCreated(handler); | 2567 extra_parts_[i]->BrowserURLHandlerCreated(handler); |
| 2550 | 2568 |
| 2551 // about: handler. Must come before chrome: handler, since it will | 2569 // about: handler. Must come before chrome: handler, since it will |
| 2552 // rewrite about: urls to chrome: URLs and then expect chrome: to | 2570 // rewrite about: urls to chrome: URLs and then expect chrome: to |
| 2553 // actually handle them. Also relies on a preliminary fixup phase. | 2571 // actually handle them. Also relies on a preliminary fixup phase. |
| 2554 handler->SetFixupHandler(&FixupBrowserAboutURL); | 2572 handler->SetFixupHandler(&FixupBrowserAboutURL); |
| 2555 handler->AddHandlerPair(&WillHandleBrowserAboutURL, | 2573 handler->AddHandlerPair(&WillHandleBrowserAboutURL, |
| 2556 BrowserURLHandler::null_handler()); | 2574 BrowserURLHandler::null_handler()); |
| 2557 | 2575 |
| 2576 // The group policy NTP URL handler must be registered before the other NTP |
| 2577 // URL handlers below. |
| 2578 handler->AddHandlerPair(&HandleNewTabPageLocationOverride, |
| 2579 BrowserURLHandler::null_handler()); |
| 2580 |
| 2558 #if defined(OS_ANDROID) | 2581 #if defined(OS_ANDROID) |
| 2559 // Handler to rewrite chrome://newtab on Android. | 2582 // Handler to rewrite chrome://newtab on Android. |
| 2560 handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL, | 2583 handler->AddHandlerPair(&chrome::android::HandleAndroidNativePageURL, |
| 2561 BrowserURLHandler::null_handler()); | 2584 BrowserURLHandler::null_handler()); |
| 2562 #else | 2585 #else |
| 2563 // Handler to rewrite chrome://newtab for InstantExtended. | 2586 // Handler to rewrite chrome://newtab for InstantExtended. |
| 2564 handler->AddHandlerPair(&search::HandleNewTabURLRewrite, | 2587 handler->AddHandlerPair(&search::HandleNewTabURLRewrite, |
| 2565 &search::HandleNewTabURLReverseRewrite); | 2588 &search::HandleNewTabURLReverseRewrite); |
| 2566 #endif | 2589 #endif |
| 2567 | 2590 |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3368 bool ChromeContentBrowserClient::ShouldRedirectDOMStorageTaskRunner() { | 3391 bool ChromeContentBrowserClient::ShouldRedirectDOMStorageTaskRunner() { |
| 3369 return variations::GetVariationParamValue( | 3392 return variations::GetVariationParamValue( |
| 3370 "BrowserScheduler", "RedirectDOMStorageTaskRunner") == "true"; | 3393 "BrowserScheduler", "RedirectDOMStorageTaskRunner") == "true"; |
| 3371 } | 3394 } |
| 3372 | 3395 |
| 3373 bool ChromeContentBrowserClient:: | 3396 bool ChromeContentBrowserClient:: |
| 3374 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { | 3397 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { |
| 3375 return variations::GetVariationParamValue( | 3398 return variations::GetVariationParamValue( |
| 3376 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; | 3399 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; |
| 3377 } | 3400 } |
| OLD | NEW |