Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: trunk/src/chrome/browser/chrome_content_browser_client.cc

Issue 280383002: Revert 269855 "Only commit cookie changes in prerenders after a ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 (kWidthForMaxFSM - kWidthForMinFSM); 623 (kWidthForMaxFSM - kWidthForMinFSM);
624 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; 624 return ratio * (kMaxFSM - kMinFSM) + kMinFSM;
625 } 625 }
626 626
627 #endif // defined(OS_ANDROID) 627 #endif // defined(OS_ANDROID)
628 628
629 } // namespace 629 } // namespace
630 630
631 namespace chrome { 631 namespace chrome {
632 632
633 ChromeContentBrowserClient::ChromeContentBrowserClient() 633 ChromeContentBrowserClient::ChromeContentBrowserClient() {
634 : prerender_tracker_(NULL) {
635 #if defined(ENABLE_PLUGINS) 634 #if defined(ENABLE_PLUGINS)
636 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i) 635 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i)
637 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); 636 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]);
638 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) 637 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
639 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); 638 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
640 #endif 639 #endif
641 640
642 permissions_policy_delegate_.reset( 641 permissions_policy_delegate_.reset(
643 new extensions::BrowserPermissionsPolicyDelegate()); 642 new extensions::BrowserPermissionsPolicyDelegate());
644 } 643 }
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 return true; 1207 return true;
1209 1208
1210 // Otherwise, just make sure the process privilege matches the privilege 1209 // Otherwise, just make sure the process privilege matches the privilege
1211 // required by the site. 1210 // required by the site.
1212 RenderProcessHostPrivilege privilege_required = 1211 RenderProcessHostPrivilege privilege_required =
1213 GetPrivilegeRequiredByUrl(site_url, service); 1212 GetPrivilegeRequiredByUrl(site_url, service);
1214 return GetProcessPrivilege(process_host, process_map, service) == 1213 return GetProcessPrivilege(process_host, process_map, service) ==
1215 privilege_required; 1214 privilege_required;
1216 } 1215 }
1217 1216
1218 bool ChromeContentBrowserClient::MayReuseHost(
1219 content::RenderProcessHost* process_host) {
1220 // If there is currently a prerender in progress for the host provided,
1221 // it may not be shared. We require prerenders to be by themselves in a
1222 // separate process, so that we can monitor their resource usage, and so that
1223 // we can track the cookies that they change.
1224 Profile* profile = Profile::FromBrowserContext(
1225 process_host->GetBrowserContext());
1226 prerender::PrerenderManager* prerender_manager =
1227 prerender::PrerenderManagerFactory::GetForProfile(profile);
1228 if (prerender_manager &&
1229 prerender_manager->IsProcessPrerendering(process_host)) {
1230 return false;
1231 }
1232
1233 return true;
1234 }
1235
1236 // This function is trying to limit the amount of processes used by extensions 1217 // This function is trying to limit the amount of processes used by extensions
1237 // with background pages. It uses a globally set percentage of processes to 1218 // with background pages. It uses a globally set percentage of processes to
1238 // run such extensions and if the limit is exceeded, it returns true, to 1219 // run such extensions and if the limit is exceeded, it returns true, to
1239 // indicate to the content module to group extensions together. 1220 // indicate to the content module to group extensions together.
1240 bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost( 1221 bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost(
1241 content::BrowserContext* browser_context, const GURL& url) { 1222 content::BrowserContext* browser_context, const GURL& url) {
1242 // It has to be a valid URL for us to check for an extension. 1223 // It has to be a valid URL for us to check for an extension.
1243 if (!url.is_valid()) 1224 if (!url.is_valid())
1244 return false; 1225 return false;
1245 1226
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 const std::string& cookie_line, 1758 const std::string& cookie_line,
1778 content::ResourceContext* context, 1759 content::ResourceContext* context,
1779 int render_process_id, 1760 int render_process_id,
1780 int render_frame_id, 1761 int render_frame_id,
1781 net::CookieOptions* options) { 1762 net::CookieOptions* options) {
1782 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1763 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1783 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1764 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1784 CookieSettings* cookie_settings = io_data->GetCookieSettings(); 1765 CookieSettings* cookie_settings = io_data->GetCookieSettings();
1785 bool allow = cookie_settings->IsSettingCookieAllowed(url, first_party); 1766 bool allow = cookie_settings->IsSettingCookieAllowed(url, first_party);
1786 1767
1787 if (prerender_tracker_) {
1788 prerender_tracker_->OnCookieChangedForURL(
1789 render_process_id,
1790 context->GetRequestContext()->cookie_store()->GetCookieMonster(),
1791 url);
1792 }
1793
1794 BrowserThread::PostTask( 1768 BrowserThread::PostTask(
1795 BrowserThread::UI, FROM_HERE, 1769 BrowserThread::UI, FROM_HERE,
1796 base::Bind(&TabSpecificContentSettings::CookieChanged, render_process_id, 1770 base::Bind(&TabSpecificContentSettings::CookieChanged, render_process_id,
1797 render_frame_id, url, first_party, cookie_line, *options, 1771 render_frame_id, url, first_party, cookie_line, *options,
1798 !allow)); 1772 !allow));
1799 return allow; 1773 return allow;
1800 } 1774 }
1801 1775
1802 bool ChromeContentBrowserClient::AllowSaveLocalState( 1776 bool ChromeContentBrowserClient::AllowSaveLocalState(
1803 content::ResourceContext* context) { 1777 content::ResourceContext* context) {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 2204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2231 // Check if it's an extension-created worker, in which case we want to use 2205 // Check if it's an extension-created worker, in which case we want to use
2232 // the name of the extension. 2206 // the name of the extension.
2233 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 2207 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
2234 const Extension* extension = 2208 const Extension* extension =
2235 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host()); 2209 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
2236 return extension ? extension->name() : std::string(); 2210 return extension ? extension->name() : std::string();
2237 } 2211 }
2238 2212
2239 void ChromeContentBrowserClient::ResourceDispatcherHostCreated() { 2213 void ChromeContentBrowserClient::ResourceDispatcherHostCreated() {
2240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2241 prerender_tracker_ = g_browser_process->prerender_tracker();
2242 return g_browser_process->ResourceDispatcherHostCreated(); 2214 return g_browser_process->ResourceDispatcherHostCreated();
2243 } 2215 }
2244 2216
2245 // TODO(tommi): Rename from Get to Create. 2217 // TODO(tommi): Rename from Get to Create.
2246 content::SpeechRecognitionManagerDelegate* 2218 content::SpeechRecognitionManagerDelegate*
2247 ChromeContentBrowserClient::GetSpeechRecognitionManagerDelegate() { 2219 ChromeContentBrowserClient::GetSpeechRecognitionManagerDelegate() {
2248 return new speech::ChromeSpeechRecognitionManagerDelegate(); 2220 return new speech::ChromeSpeechRecognitionManagerDelegate();
2249 } 2221 }
2250 2222
2251 net::NetLog* ChromeContentBrowserClient::GetNetLog() { 2223 net::NetLog* ChromeContentBrowserClient::GetNetLog() {
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 2691 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
2720 // Allow dev channel APIs to be used on "Canary", "Dev", and "Unknown" 2692 // Allow dev channel APIs to be used on "Canary", "Dev", and "Unknown"
2721 // releases of Chrome. Permitting "Unknown" allows these APIs to be used on 2693 // releases of Chrome. Permitting "Unknown" allows these APIs to be used on
2722 // Chromium builds as well. 2694 // Chromium builds as well.
2723 return channel <= chrome::VersionInfo::CHANNEL_DEV; 2695 return channel <= chrome::VersionInfo::CHANNEL_DEV;
2724 #else 2696 #else
2725 return false; 2697 return false;
2726 #endif 2698 #endif
2727 } 2699 }
2728 2700
2729 net::CookieStore*
2730 ChromeContentBrowserClient::OverrideCookieStoreForRenderProcess(
2731 int render_process_id) {
2732 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2733 if (!prerender_tracker_)
2734 return NULL;
2735 return prerender_tracker_->
2736 GetPrerenderCookieStoreForRenderProcess(render_process_id);
2737 }
2738
2739 #if defined(ENABLE_WEBRTC) 2701 #if defined(ENABLE_WEBRTC)
2740 void ChromeContentBrowserClient::MaybeCopyDisableWebRtcEncryptionSwitch( 2702 void ChromeContentBrowserClient::MaybeCopyDisableWebRtcEncryptionSwitch(
2741 CommandLine* to_command_line, 2703 CommandLine* to_command_line,
2742 const CommandLine& from_command_line, 2704 const CommandLine& from_command_line,
2743 VersionInfo::Channel channel) { 2705 VersionInfo::Channel channel) {
2744 #if defined(OS_ANDROID) 2706 #if defined(OS_ANDROID)
2745 const VersionInfo::Channel kMaxDisableEncryptionChannel = 2707 const VersionInfo::Channel kMaxDisableEncryptionChannel =
2746 VersionInfo::CHANNEL_BETA; 2708 VersionInfo::CHANNEL_BETA;
2747 #else 2709 #else
2748 const VersionInfo::Channel kMaxDisableEncryptionChannel = 2710 const VersionInfo::Channel kMaxDisableEncryptionChannel =
2749 VersionInfo::CHANNEL_DEV; 2711 VersionInfo::CHANNEL_DEV;
2750 #endif 2712 #endif
2751 if (channel <= kMaxDisableEncryptionChannel) { 2713 if (channel <= kMaxDisableEncryptionChannel) {
2752 static const char* const kWebRtcDevSwitchNames[] = { 2714 static const char* const kWebRtcDevSwitchNames[] = {
2753 switches::kDisableWebRtcEncryption, 2715 switches::kDisableWebRtcEncryption,
2754 }; 2716 };
2755 to_command_line->CopySwitchesFrom(from_command_line, 2717 to_command_line->CopySwitchesFrom(from_command_line,
2756 kWebRtcDevSwitchNames, 2718 kWebRtcDevSwitchNames,
2757 arraysize(kWebRtcDevSwitchNames)); 2719 arraysize(kWebRtcDevSwitchNames));
2758 } 2720 }
2759 } 2721 }
2760 #endif // defined(ENABLE_WEBRTC) 2722 #endif // defined(ENABLE_WEBRTC)
2761 2723
2762 } // namespace chrome 2724 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698