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