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

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

Issue 120963002: Use a Finch Experiment to control the Browser Blacklist (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 12 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
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_browser_main_win.h" 5 #include "chrome/browser/chrome_browser_main_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/environment.h" 13 #include "base/environment.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "base/metrics/field_trial.h"
17 #include "base/metrics/histogram.h"
16 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
17 #include "base/path_service.h" 19 #include "base/path_service.h"
18 #include "base/scoped_native_library.h" 20 #include "base/scoped_native_library.h"
19 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
21 #include "base/win/metro.h" 23 #include "base/win/metro.h"
22 #include "base/win/windows_version.h" 24 #include "base/win/windows_version.h"
23 #include "base/win/wrapped_window_proc.h" 25 #include "base/win/wrapped_window_proc.h"
24 #include "chrome/browser/browser_util_win.h" 26 #include "chrome/browser/browser_util_win.h"
25 #include "chrome/browser/install_verification/win/install_verification.h" 27 #include "chrome/browser/install_verification/win/install_verification.h"
26 #include "chrome/browser/profiles/profile_info_cache.h" 28 #include "chrome/browser/profiles/profile_info_cache.h"
27 #include "chrome/browser/profiles/profile_shortcut_manager.h" 29 #include "chrome/browser/profiles/profile_shortcut_manager.h"
28 #include "chrome/browser/shell_integration.h" 30 #include "chrome/browser/shell_integration.h"
29 #include "chrome/browser/ui/simple_message_box.h" 31 #include "chrome/browser/ui/simple_message_box.h"
30 #include "chrome/browser/ui/uninstall_browser_prompt.h" 32 #include "chrome/browser/ui/uninstall_browser_prompt.h"
31 #include "chrome/common/chrome_constants.h" 33 #include "chrome/common/chrome_constants.h"
32 #include "chrome/common/chrome_result_codes.h" 34 #include "chrome/common/chrome_result_codes.h"
33 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
34 #include "chrome/common/chrome_version_info.h" 36 #include "chrome/common/chrome_version_info.h"
35 #include "chrome/common/env_vars.h" 37 #include "chrome/common/env_vars.h"
36 #include "chrome/installer/launcher_support/chrome_launcher_support.h" 38 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
37 #include "chrome/installer/util/browser_distribution.h" 39 #include "chrome/installer/util/browser_distribution.h"
38 #include "chrome/installer/util/helper.h" 40 #include "chrome/installer/util/helper.h"
39 #include "chrome/installer/util/install_util.h" 41 #include "chrome/installer/util/install_util.h"
40 #include "chrome/installer/util/l10n_string_util.h" 42 #include "chrome/installer/util/l10n_string_util.h"
41 #include "chrome/installer/util/shell_util.h" 43 #include "chrome/installer/util/shell_util.h"
44 #include "chrome_elf/blacklist/blacklist.h"
42 #include "content/public/browser/browser_thread.h" 45 #include "content/public/browser/browser_thread.h"
43 #include "content/public/common/main_function_params.h" 46 #include "content/public/common/main_function_params.h"
44 #include "grit/app_locale_settings.h" 47 #include "grit/app_locale_settings.h"
45 #include "grit/chromium_strings.h" 48 #include "grit/chromium_strings.h"
46 #include "grit/generated_resources.h" 49 #include "grit/generated_resources.h"
47 #include "installer_util_strings/installer_util_strings.h" 50 #include "installer_util_strings/installer_util_strings.h"
48 #include "ui/base/cursor/cursor_loader_win.h" 51 #include "ui/base/cursor/cursor_loader_win.h"
49 #include "ui/base/l10n/l10n_util.h" 52 #include "ui/base/l10n/l10n_util.h"
50 #include "ui/base/l10n/l10n_util_win.h" 53 #include "ui/base/l10n/l10n_util_win.h"
51 #include "ui/base/ui_base_switches.h" 54 #include "ui/base/ui_base_switches.h"
52 #include "ui/base/win/message_box_win.h" 55 #include "ui/base/win/message_box_win.h"
53 #include "ui/gfx/platform_font_win.h" 56 #include "ui/gfx/platform_font_win.h"
54 #include "ui/gfx/switches.h" 57 #include "ui/gfx/switches.h"
55 58
56 namespace { 59 namespace {
57 60
58 typedef HRESULT (STDAPICALLTYPE* RegisterApplicationRestartProc)( 61 typedef HRESULT (STDAPICALLTYPE* RegisterApplicationRestartProc)(
59 const wchar_t* command_line, 62 const wchar_t* command_line,
60 DWORD flags); 63 DWORD flags);
61 64
65 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist";
66 const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled";
67
68 enum BlacklistSetupEvent {
69 // The blacklist beacon has placed to enable the browser blacklisting.
70 BLACKLIST_SETUP_ENABLED = 0,
71
72 // The blacklist was successfully enabled.
73 BLACKLIST_SETUP_RAN_SUCCESSFULLY,
74
75 // The blacklist setup code failed to execute.
76 BLACKLIST_SETUP_FAILED,
77
78 // Always keep this at the end.
79 BLACKLIST_SETUP_EVENT_MAX,
80 };
Ilya Sherman 2013/12/27 01:22:50 Please document that this histogram is used to bac
csharp 2014/01/02 19:55:36 Added the comment although I reworded part b to sa
81
62 void InitializeWindowProcExceptions() { 82 void InitializeWindowProcExceptions() {
63 // Get the breakpad pointer from chrome.exe 83 // Get the breakpad pointer from chrome.exe
64 base::win::WinProcExceptionFilter exception_filter = 84 base::win::WinProcExceptionFilter exception_filter =
65 reinterpret_cast<base::win::WinProcExceptionFilter>( 85 reinterpret_cast<base::win::WinProcExceptionFilter>(
66 ::GetProcAddress(::GetModuleHandle( 86 ::GetProcAddress(::GetModuleHandle(
67 chrome::kBrowserProcessExecutableName), 87 chrome::kBrowserProcessExecutableName),
68 "CrashForException")); 88 "CrashForException"));
69 exception_filter = base::win::SetWinProcExceptionFilter(exception_filter); 89 exception_filter = base::win::SetWinProcExceptionFilter(exception_filter);
70 DCHECK(!exception_filter); 90 DCHECK(!exception_filter);
71 } 91 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 void ChromeBrowserMainPartsWin::PostBrowserStart() { 264 void ChromeBrowserMainPartsWin::PostBrowserStart() {
245 ChromeBrowserMainParts::PostBrowserStart(); 265 ChromeBrowserMainParts::PostBrowserStart();
246 266
247 // Set up a task to verify installed modules in the current process. Use a 267 // Set up a task to verify installed modules in the current process. Use a
248 // delay to reduce the impact on startup time. 268 // delay to reduce the impact on startup time.
249 content::BrowserThread::GetMessageLoopProxyForThread( 269 content::BrowserThread::GetMessageLoopProxyForThread(
250 content::BrowserThread::UI)->PostDelayedTask( 270 content::BrowserThread::UI)->PostDelayedTask(
251 FROM_HERE, 271 FROM_HERE,
252 base::Bind(&VerifyInstallation), 272 base::Bind(&VerifyInstallation),
253 base::TimeDelta::FromSeconds(45)); 273 base::TimeDelta::FromSeconds(45));
274
275 // Setup the blacklist beacon if this client is in the experiment to use
276 // the browser blacklist.
277 if (base::FieldTrialList::FindFullName(kBrowserBlacklistTrialName) ==
278 kBrowserBlacklistTrialEnabledGroupName) {
279 // Find the current state of the blacklist.
280 DWORD blacklist_state;
robertshield 2013/12/27 03:24:29 = 0
csharp 2014/01/02 19:55:36 Done.
281 DWORD blacklist_state_size = sizeof(blacklist_state);
282 ::RegGetValue(HKEY_CURRENT_USER,
robertshield 2013/12/27 03:24:29 Please use base/win/registry.h instead of the adva
csharp 2014/01/02 19:55:36 Done.
283 blacklist::kRegistryBeaconPath,
284 blacklist::kBeaconState,
285 RRF_RT_REG_DWORD,
286 NULL,
287 &blacklist_state,
288 &blacklist_state_size);
289
290 if (blacklist_state == blacklist::BLACKLIST_ENABLED) {
291 // The blacklist was setup successfully.
292 UMA_HISTOGRAM_ENUMERATION("Blacklist.Setup",
293 BLACKLIST_SETUP_RAN_SUCCESSFULLY,
294 BLACKLIST_SETUP_EVENT_MAX);
295 } else if (blacklist_state == blacklist::BLACKLIST_SETUP_RUNNING) {
296 // The blacklist setup failed.
297 UMA_HISTOGRAM_ENUMERATION("Blacklist.Setup",
298 BLACKLIST_SETUP_FAILED,
299 BLACKLIST_SETUP_EVENT_MAX);
Ilya Sherman 2013/12/27 01:22:50 Please create a wrapper method to emit to this his
csharp 2014/01/02 19:55:36 Done.
300
301 // Since the setup failed, mark the blacklist as disabled so we don't
302 // try it again.
303 DWORD blacklist_state = blacklist::BLACKLIST_DISABLED;
304 ::RegSetKeyValue(HKEY_CURRENT_USER,
305 blacklist::kRegistryBeaconPath,
306 blacklist::kBeaconState,
307 REG_DWORD,
308 &blacklist_state,
309 sizeof(blacklist_state));
310 }
311
312 // Find the version the blacklist was last enabled for.
313 wchar_t key_data[255];
robertshield 2013/12/27 03:24:29 = {}
csharp 2014/01/02 19:55:36 Done.
314 DWORD key_data_size = sizeof(key_data);
315 ::RegGetValue(HKEY_CURRENT_USER,
316 blacklist::kRegistryBeaconPath,
317 blacklist::kBeaconVersion,
318 RRF_RT_REG_SZ,
319 NULL,
320 key_data,
321 &key_data_size);
322
323 // If the blacklist hasn't been enabled for this version yet, enable it.
324 chrome::VersionInfo version_info;
325 base::string16 version = UTF8ToUTF16(version_info.Version());
326 if (key_data != version) {
327 ::RegSetKeyValue(HKEY_CURRENT_USER,
328 blacklist::kRegistryBeaconPath,
329 blacklist::kBeaconVersion,
330 REG_SZ,
331 version.c_str(),
332 version.size() * sizeof(wchar_t));
333
334 DWORD blacklist_state = blacklist::BLACKLIST_ENABLED;
335 ::RegSetKeyValue(HKEY_CURRENT_USER,
336 blacklist::kRegistryBeaconPath,
337 blacklist::kBeaconState,
338 REG_DWORD,
339 &blacklist_state,
340 sizeof(blacklist_state));
341
342 // Record the blacklist getting enabled for this version.
343 UMA_HISTOGRAM_ENUMERATION("Blacklist.Setup",
344 BLACKLIST_SETUP_ENABLED,
345 BLACKLIST_SETUP_EVENT_MAX);
346 }
347 } else {
348 // Disable the blacklist for future runs by removing the beacon.
349 ::RegDeleteKey(HKEY_CURRENT_USER, blacklist::kRegistryBeaconPath);
350 }
Ilya Sherman 2013/12/27 01:22:50 I've mostly only looked at the histograms-related
robertshield 2013/12/27 03:24:29 +1
csharp 2014/01/02 19:55:36 Done.
254 } 351 }
255 352
256 // static 353 // static
257 void ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment( 354 void ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment(
258 const CommandLine& parsed_command_line) { 355 const CommandLine& parsed_command_line) {
259 // Clear this var so child processes don't show the dialog by default. 356 // Clear this var so child processes don't show the dialog by default.
260 scoped_ptr<base::Environment> env(base::Environment::Create()); 357 scoped_ptr<base::Environment> env(base::Environment::Create());
261 env->UnSetVar(env_vars::kShowRestart); 358 env->UnSetVar(env_vars::kShowRestart);
262 359
263 // For non-interactive tests we don't restart on crash. 360 // For non-interactive tests we don't restart on crash.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 if (resource_id) 520 if (resource_id)
424 return l10n_util::GetStringUTF16(resource_id); 521 return l10n_util::GetStringUTF16(resource_id);
425 return base::string16(); 522 return base::string16();
426 } 523 }
427 524
428 // static 525 // static
429 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() { 526 void ChromeBrowserMainPartsWin::SetupInstallerUtilStrings() {
430 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ()); 527 CR_DEFINE_STATIC_LOCAL(TranslationDelegate, delegate, ());
431 installer::SetTranslationDelegate(&delegate); 528 installer::SetTranslationDelegate(&delegate);
432 } 529 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698