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

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

Issue 10541019: Adding a field trial for testing --force-compositing-mode on 50% of (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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
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/metrics/histogram.h"
13 #include "base/string_tokenizer.h" 14 #include "base/string_tokenizer.h"
14 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
15 #include "chrome/app/breakpad_mac.h" 16 #include "chrome/app/breakpad_mac.h"
16 #include "chrome/browser/browser_about_handler.h" 17 #include "chrome/browser/browser_about_handler.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/browser_trial.h"
18 #include "chrome/browser/browsing_data_helper.h" 20 #include "chrome/browser/browsing_data_helper.h"
19 #include "chrome/browser/browsing_data_remover.h" 21 #include "chrome/browser/browsing_data_remover.h"
20 #include "chrome/browser/character_encoding.h" 22 #include "chrome/browser/character_encoding.h"
21 #include "chrome/browser/chrome_benchmarking_message_filter.h" 23 #include "chrome/browser/chrome_benchmarking_message_filter.h"
22 #include "chrome/browser/chrome_quota_permission_context.h" 24 #include "chrome/browser/chrome_quota_permission_context.h"
23 #include "chrome/browser/content_settings/content_settings_utils.h" 25 #include "chrome/browser/content_settings/content_settings_utils.h"
24 #include "chrome/browser/content_settings/cookie_settings.h" 26 #include "chrome/browser/content_settings/cookie_settings.h"
25 #include "chrome/browser/content_settings/host_content_settings_map.h" 27 #include "chrome/browser/content_settings/host_content_settings_map.h"
26 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 28 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
27 #include "chrome/browser/defaults.h" 29 #include "chrome/browser/defaults.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #include "chrome/browser/ui/media_stream_infobar_delegate.h" 70 #include "chrome/browser/ui/media_stream_infobar_delegate.h"
69 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" 71 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h"
70 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 72 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
71 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" 73 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
72 #include "chrome/browser/user_style_sheet_watcher.h" 74 #include "chrome/browser/user_style_sheet_watcher.h"
73 #include "chrome/browser/user_style_sheet_watcher_factory.h" 75 #include "chrome/browser/user_style_sheet_watcher_factory.h"
74 #include "chrome/browser/view_type_utils.h" 76 #include "chrome/browser/view_type_utils.h"
75 #include "chrome/common/child_process_logging.h" 77 #include "chrome/common/child_process_logging.h"
76 #include "chrome/common/chrome_constants.h" 78 #include "chrome/common/chrome_constants.h"
77 #include "chrome/common/chrome_switches.h" 79 #include "chrome/common/chrome_switches.h"
80 #include "chrome/common/chrome_version_info.h"
78 #include "chrome/common/extensions/extension.h" 81 #include "chrome/common/extensions/extension.h"
79 #include "chrome/common/extensions/extension_process_policy.h" 82 #include "chrome/common/extensions/extension_process_policy.h"
80 #include "chrome/common/extensions/extension_set.h" 83 #include "chrome/common/extensions/extension_set.h"
81 #include "chrome/common/logging_chrome.h" 84 #include "chrome/common/logging_chrome.h"
82 #include "chrome/common/pref_names.h" 85 #include "chrome/common/pref_names.h"
83 #include "chrome/common/render_messages.h" 86 #include "chrome/common/render_messages.h"
84 #include "chrome/common/url_constants.h" 87 #include "chrome/common/url_constants.h"
85 #include "content/public/browser/browser_child_process_host.h" 88 #include "content/public/browser/browser_child_process_host.h"
86 #include "content/public/browser/browser_main_parts.h" 89 #include "content/public/browser/browser_main_parts.h"
87 #include "content/public/browser/browser_url_handler.h" 90 #include "content/public/browser/browser_url_handler.h"
88 #include "content/public/browser/child_process_security_policy.h" 91 #include "content/public/browser/child_process_security_policy.h"
89 #include "content/public/browser/render_process_host.h" 92 #include "content/public/browser/render_process_host.h"
90 #include "content/public/browser/render_view_host.h" 93 #include "content/public/browser/render_view_host.h"
91 #include "content/public/browser/resource_context.h" 94 #include "content/public/browser/resource_context.h"
92 #include "content/public/browser/site_instance.h" 95 #include "content/public/browser/site_instance.h"
93 #include "content/public/browser/web_contents.h" 96 #include "content/public/browser/web_contents.h"
94 #include "content/public/browser/web_contents_view.h" 97 #include "content/public/browser/web_contents_view.h"
95 #include "content/public/common/child_process_host.h" 98 #include "content/public/common/child_process_host.h"
96 #include "grit/generated_resources.h" 99 #include "grit/generated_resources.h"
97 #include "grit/ui_resources.h" 100 #include "grit/ui_resources.h"
98 #include "net/base/ssl_cert_request_info.h" 101 #include "net/base/ssl_cert_request_info.h"
99 #include "net/cookies/cookie_monster.h" 102 #include "net/cookies/cookie_monster.h"
100 #include "net/cookies/cookie_options.h" 103 #include "net/cookies/cookie_options.h"
101 #include "ui/base/l10n/l10n_util.h" 104 #include "ui/base/l10n/l10n_util.h"
102 #include "ui/base/resource/resource_bundle.h" 105 #include "ui/base/resource/resource_bundle.h"
103 #include "webkit/glue/webpreferences.h" 106 #include "webkit/glue/webpreferences.h"
104 #include "webkit/plugins/plugin_switches.h" 107 #include "webkit/plugins/plugin_switches.h"
105 108
106 #if defined(OS_WIN) 109 #if defined(OS_WIN)
110 #include "base/win/windows_version.h"
107 #include "chrome/browser/chrome_browser_main_win.h" 111 #include "chrome/browser/chrome_browser_main_win.h"
108 #elif defined(OS_MACOSX) 112 #elif defined(OS_MACOSX)
113 #include "base/mac/mac_util.h"
109 #include "chrome/browser/chrome_browser_main_mac.h" 114 #include "chrome/browser/chrome_browser_main_mac.h"
110 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h" 115 #include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
111 #elif defined(OS_CHROMEOS) 116 #elif defined(OS_CHROMEOS)
112 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" 117 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
113 #include "chrome/browser/chromeos/login/user_manager.h" 118 #include "chrome/browser/chromeos/login/user_manager.h"
114 #elif defined(OS_LINUX) 119 #elif defined(OS_LINUX)
115 #include "chrome/browser/chrome_browser_main_linux.h" 120 #include "chrome/browser/chrome_browser_main_linux.h"
116 #elif defined(OS_POSIX) 121 #elif defined(OS_POSIX)
117 #include "chrome/browser/chrome_browser_main_posix.h" 122 #include "chrome/browser/chrome_browser_main_posix.h"
118 #endif 123 #endif
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 WebPreferences::ScriptFontFamilyMap* map) { 305 WebPreferences::ScriptFontFamilyMap* map) {
301 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { 306 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) {
302 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; 307 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i];
303 std::string pref_name = base::StringPrintf("%s.%s", map_name, script); 308 std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
304 std::string font_family = prefs->GetString(pref_name.c_str()); 309 std::string font_family = prefs->GetString(pref_name.c_str());
305 if (!font_family.empty()) 310 if (!font_family.empty())
306 (*map)[script] = UTF8ToUTF16(font_family); 311 (*map)[script] = UTF8ToUTF16(font_family);
307 } 312 }
308 } 313 }
309 314
315 void CheckForceCompositingModeTrialFlag(CommandLine* command_line) {
316 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
317 // Only run the trial on the Canary channel.
318 if (channel != chrome::VersionInfo::CHANNEL_CANARY)
319 return;
320 #if defined(OS_WIN)
321 // Don't run the trial on windows XP.
322 if (base::win::GetVersion() < base::win::VERSION_VISTA)
323 return;
324 #elif defined(OS_MACOSX)
325 // Accelerated compositing is only implemented on Mac OSX 10.6 or later.
326 if (base::mac::IsOSLeopardOrEarlier())
327 return;
328 #endif
329
330 static base::FieldTrial* trial = NULL;
331 static bool in_enable_group = false;
332
333 if (!trial) {
334 const base::FieldTrial::Probability kDivisor = 100;
335 // 50% probability of being in the enabled group.
336 const base::FieldTrial::Probability kEnableProbability = 50;
337 trial = base::FieldTrialList::FactoryGetFieldTrial(
338 BrowserTrial::kForceCompositingModeTrial, kDivisor,
339 "disable", 2012, 12, 31, NULL);
340 // Produce the same result on every run of this client.
341 trial->UseOneTimeRandomization();
342 int enable_group = trial->AppendGroup("enable", kEnableProbability);
343 in_enable_group = (trial->group() == enable_group);
344 UMA_HISTOGRAM_ENUMERATION("GPU.InForceCompositingModeFieldTrial",
Ilya Sherman 2012/06/06 09:50:21 nit: UMA_HISTOGRAM_BOOLEAN?
345 in_enable_group ? 1 : 0, 2);
346 }
347
348 if (in_enable_group)
349 command_line->AppendSwitch(switches::kForceCompositingMode);
350 }
351
310 } // namespace 352 } // namespace
311 353
312 namespace chrome { 354 namespace chrome {
313 355
314 ChromeContentBrowserClient::ChromeContentBrowserClient() { 356 ChromeContentBrowserClient::ChromeContentBrowserClient() {
315 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) 357 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
316 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); 358 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
317 } 359 }
318 360
319 ChromeContentBrowserClient::~ChromeContentBrowserClient() { 361 ChromeContentBrowserClient::~ChromeContentBrowserClient() {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 } 786 }
745 } 787 }
746 { 788 {
747 PrefService* local_state = g_browser_process->local_state(); 789 PrefService* local_state = g_browser_process->local_state();
748 if (local_state && 790 if (local_state &&
749 !local_state->GetBoolean(prefs::kPrintPreviewDisabled)) { 791 !local_state->GetBoolean(prefs::kPrintPreviewDisabled)) {
750 command_line->AppendSwitch(switches::kRendererPrintPreview); 792 command_line->AppendSwitch(switches::kRendererPrintPreview);
751 } 793 }
752 } 794 }
753 795
796 CheckForceCompositingModeTrialFlag(command_line);
797
754 // Please keep this in alphabetical order. 798 // Please keep this in alphabetical order.
755 static const char* const kSwitchNames[] = { 799 static const char* const kSwitchNames[] = {
756 switches::kAllowHTTPBackgroundPage, 800 switches::kAllowHTTPBackgroundPage,
757 switches::kAllowLegacyExtensionManifests, 801 switches::kAllowLegacyExtensionManifests,
758 switches::kAllowScriptingGallery, 802 switches::kAllowScriptingGallery,
759 switches::kAppsCheckoutURL, 803 switches::kAppsCheckoutURL,
760 switches::kAppsGalleryURL, 804 switches::kAppsGalleryURL,
761 switches::kCloudPrintServiceURL, 805 switches::kCloudPrintServiceURL,
762 switches::kDebugPrint, 806 switches::kDebugPrint,
763 switches::kDisableAsynchronousSpellChecking, 807 switches::kDisableAsynchronousSpellChecking,
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 #if defined(USE_NSS) 1663 #if defined(USE_NSS)
1620 crypto::CryptoModuleBlockingPasswordDelegate* 1664 crypto::CryptoModuleBlockingPasswordDelegate*
1621 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1665 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1622 const GURL& url) { 1666 const GURL& url) {
1623 return browser::NewCryptoModuleBlockingDialogDelegate( 1667 return browser::NewCryptoModuleBlockingDialogDelegate(
1624 browser::kCryptoModulePasswordKeygen, url.host()); 1668 browser::kCryptoModulePasswordKeygen, url.host());
1625 } 1669 }
1626 #endif 1670 #endif
1627 1671
1628 } // namespace chrome 1672 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698