Chromium Code Reviews| 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 if (process_type == switches::kPpapiPluginProcess) | 427 if (process_type == switches::kPpapiPluginProcess) |
| 428 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); | 428 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 429 | 429 |
| 430 if (process_type == switches::kGpuProcess) | 430 if (process_type == switches::kGpuProcess) |
| 431 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); | 431 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); |
| 432 | 432 |
| 433 return -1; | 433 return -1; |
| 434 } | 434 } |
| 435 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | 435 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
| 436 | 436 |
| 437 // Transforms the input |url| into its "effective URL". The returned URL | |
| 438 // facilitates grouping process-per-site. The |url| is transformed, for | |
| 439 // example, from | |
| 440 // | |
| 441 // https://www.google.com/search?espv=1&q=tractors | |
| 442 // | |
| 443 // to the effective URL | |
| 444 // | |
| 445 // chrome-search://www.google.com/search?espv=1&q=tractors | |
| 446 // | |
| 447 // Notice the scheme change. | |
| 448 // | |
| 449 // If the input is already an effective URL then that same URL is returned. | |
| 450 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { | |
| 451 CHECK(chrome::ShouldAssignURLToInstantRenderer(url, profile)) | |
| 452 << "Error granting Instant access."; | |
| 453 | |
| 454 if (url.SchemeIs(chrome::kChromeSearchScheme)) | |
| 455 return url; | |
| 456 | |
| 457 GURL effective_url(url); | |
| 458 | |
| 459 // Replace the scheme with "chrome-search:". | |
| 460 url_canon::Replacements<char> replacements; | |
| 461 std::string search_scheme(chrome::kChromeSearchScheme); | |
| 462 replacements.SetScheme(search_scheme.data(), | |
| 463 url_parse::Component(0, search_scheme.length())); | |
| 464 effective_url = effective_url.ReplaceComponents(replacements); | |
| 465 return effective_url; | |
| 466 } | |
| 467 | |
| 468 #if !defined(OS_CHROMEOS) | 437 #if !defined(OS_CHROMEOS) |
| 469 GURL GetEffectiveURLForSignin(const GURL& url) { | 438 GURL GetEffectiveURLForSignin(const GURL& url) { |
| 470 CHECK(SigninManager::IsWebBasedSigninFlowURL(url)); | 439 CHECK(SigninManager::IsWebBasedSigninFlowURL(url)); |
| 471 | 440 |
| 472 GURL effective_url(SigninManager::kChromeSigninEffectiveSite); | 441 GURL effective_url(SigninManager::kChromeSigninEffectiveSite); |
| 473 // Copy the path because the argument to SetPathStr must outlive | 442 // Copy the path because the argument to SetPathStr must outlive |
| 474 // the Replacements object. | 443 // the Replacements object. |
| 475 const std::string path_copy(url.path()); | 444 const std::string path_copy(url.path()); |
| 476 GURL::Replacements replacements; | 445 GURL::Replacements replacements; |
| 477 replacements.SetPathStr(path_copy); | 446 replacements.SetPathStr(path_copy); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 host->Send(new ChromeViewMsg_SetExtensionActivityLogEnabled( | 707 host->Send(new ChromeViewMsg_SetExtensionActivityLogEnabled( |
| 739 IsExtensionActivityLogEnabledForProfile(profile))); | 708 IsExtensionActivityLogEnabledForProfile(profile))); |
| 740 | 709 |
| 741 SendExtensionWebRequestStatusToHost(host); | 710 SendExtensionWebRequestStatusToHost(host); |
| 742 | 711 |
| 743 RendererContentSettingRules rules; | 712 RendererContentSettingRules rules; |
| 744 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules); | 713 GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules); |
| 745 host->Send(new ChromeViewMsg_SetContentSettingRules(rules)); | 714 host->Send(new ChromeViewMsg_SetContentSettingRules(rules)); |
| 746 } | 715 } |
| 747 | 716 |
| 717 GURL ChromeContentBrowserClient::GetPossiblyPrivilegedURL( | |
| 718 content::BrowserContext* browser_context, | |
| 719 const GURL& url, | |
| 720 bool is_renderer_initiated, | |
| 721 content::SiteInstance* current_instance) { | |
| 722 Profile* profile = Profile::FromBrowserContext(browser_context); | |
| 723 if (!profile) | |
| 724 return url; | |
| 725 | |
| 726 // Only return the privileged instant URL if we are entering from a browser- | |
| 727 // initiated navigation or if we are already in the instant process. | |
| 728 bool is_instant_process = false; | |
| 729 int process_id = current_instance->GetProcess()->GetID(); | |
| 730 InstantService* instant_service = | |
| 731 InstantServiceFactory::GetForProfile(profile); | |
| 732 if (instant_service) | |
| 733 is_instant_process = instant_service->IsInstantProcess(process_id); | |
| 734 | |
| 735 // TODO(shishir): Uncomment the followng DCHECK after tests are fixed. | |
|
Charlie Reis
2013/05/02 17:25:20
Is the ReplaceSearchTerms CL difficult to fix? It
Shishir
2013/05/02 18:07:07
Fixed the test. Turns out the code that caused thi
Charlie Reis
2013/05/02 18:33:02
Fantastic! LGTM.
| |
| 736 // DCHECK_EQ(is_instant_process, | |
| 737 // chrome::IsPrivilegedURLForInstant(current_instance->GetSiteURL())); | |
| 738 if (!is_renderer_initiated || is_instant_process) { | |
| 739 // If the input |url| should be assigned to the Instant renderer, make its | |
| 740 // privileged URL distinct from other URLs on the search provider's domain. | |
| 741 if (chrome::ShouldAssignURLToInstantRenderer(url, profile)) | |
| 742 return chrome::GetPrivilegedURLForInstant(url, profile); | |
| 743 } | |
| 744 | |
| 745 return url; | |
| 746 } | |
| 747 | |
| 748 GURL ChromeContentBrowserClient::GetEffectiveURL( | 748 GURL ChromeContentBrowserClient::GetEffectiveURL( |
| 749 content::BrowserContext* browser_context, const GURL& url) { | 749 content::BrowserContext* browser_context, const GURL& url) { |
| 750 Profile* profile = Profile::FromBrowserContext(browser_context); | 750 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 751 if (!profile) | 751 if (!profile) |
| 752 return url; | 752 return url; |
| 753 | 753 |
| 754 // If the input |url| should be assigned to the Instant renderer, make its | |
| 755 // effective URL distinct from other URLs on the search provider's domain. | |
| 756 if (chrome::ShouldAssignURLToInstantRenderer(url, profile)) | |
| 757 return GetEffectiveURLForInstant(url, profile); | |
| 758 | |
| 759 #if !defined(OS_CHROMEOS) | 754 #if !defined(OS_CHROMEOS) |
| 760 // If the input |url| should be assigned to the Signin renderer, make its | 755 // If the input |url| should be assigned to the Signin renderer, make its |
| 761 // effective URL distinct from other URLs on the signin service's domain. | 756 // effective URL distinct from other URLs on the signin service's domain. |
| 762 // Note that the signin renderer will be allowed to sign the user in to | 757 // Note that the signin renderer will be allowed to sign the user in to |
| 763 // Chrome. | 758 // Chrome. |
| 764 if (SigninManager::IsWebBasedSigninFlowURL(url)) | 759 if (SigninManager::IsWebBasedSigninFlowURL(url)) |
| 765 return GetEffectiveURLForSignin(url); | 760 return GetEffectiveURLForSignin(url); |
| 766 #endif | 761 #endif |
| 767 | 762 |
| 768 // If the input |url| is part of an installed app, the effective URL is an | 763 // If the input |url| is part of an installed app, the effective URL is an |
| (...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2247 #if defined(USE_NSS) | 2242 #if defined(USE_NSS) |
| 2248 crypto::CryptoModuleBlockingPasswordDelegate* | 2243 crypto::CryptoModuleBlockingPasswordDelegate* |
| 2249 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 2244 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
| 2250 const GURL& url) { | 2245 const GURL& url) { |
| 2251 return chrome::NewCryptoModuleBlockingDialogDelegate( | 2246 return chrome::NewCryptoModuleBlockingDialogDelegate( |
| 2252 chrome::kCryptoModulePasswordKeygen, url.host()); | 2247 chrome::kCryptoModulePasswordKeygen, url.host()); |
| 2253 } | 2248 } |
| 2254 #endif | 2249 #endif |
| 2255 | 2250 |
| 2256 } // namespace chrome | 2251 } // namespace chrome |
| OLD | NEW |