Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chrome / browser / ui / startup / bad_flags_prompt.cc
blob0c4b77c1fdfcac4d665f8769df44986e221cf62f
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/startup/bad_flags_prompt.h"
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/simple_message_box.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/common/chrome_paths.h"
16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/switch_utils.h"
18 #include "chrome/grit/chromium_strings.h"
19 #include "chrome/grit/generated_resources.h"
20 #include "components/invalidation/invalidation_switches.h"
21 #include "components/nacl/common/nacl_switches.h"
22 #include "components/startup_metric_utils/startup_metric_utils.h"
23 #include "components/translate/core/common/translate_switches.h"
24 #include "content/public/common/content_switches.h"
25 #include "extensions/common/switches.h"
26 #include "google_apis/gaia/gaia_switches.h"
27 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/resource/resource_bundle.h"
30 namespace chrome {
32 void ShowBadFlagsPrompt(Browser* browser) {
33 content::WebContents* web_contents =
34 browser->tab_strip_model()->GetActiveWebContents();
35 if (!web_contents)
36 return;
38 // Unsupported flags for which to display a warning that "stability and
39 // security will suffer".
40 static const char* kBadFlags[] = {
41 // These flags disable sandbox-related security.
42 switches::kDisableGpuSandbox,
43 switches::kDisableSeccompFilterSandbox,
44 switches::kDisableSetuidSandbox,
45 switches::kDisableWebSecurity,
46 #if !defined(DISABLE_NACL)
47 switches::kNaClDangerousNoSandboxNonSfi,
48 #endif
49 switches::kNoSandbox,
50 switches::kSingleProcess,
52 // These flags disable or undermine the Same Origin Policy.
53 switches::kTrustedSpdyProxy,
54 translate::switches::kTranslateSecurityOrigin,
56 // These flags undermine HTTPS / connection security.
57 #if defined(ENABLE_WEBRTC)
58 switches::kDisableWebRtcEncryption,
59 #endif
60 switches::kIgnoreCertificateErrors,
61 switches::kReduceSecurityForTesting,
62 invalidation::switches::kSyncAllowInsecureXmppConnection,
64 // These flags change the URLs that handle PII.
65 autofill::switches::kWalletSecureServiceUrl,
66 switches::kGaiaUrl,
67 translate::switches::kTranslateScriptURL,
69 // This flag gives extensions more powers.
70 extensions::switches::kExtensionsOnChromeURLs,
72 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
73 // Speech dispatcher is buggy, it can crash and it can make Chrome freeze.
74 // http://crbug.com/327295
75 switches::kEnableSpeechDispatcher,
76 #endif
77 NULL
80 for (const char** flag = kBadFlags; *flag; ++flag) {
81 if (CommandLine::ForCurrentProcess()->HasSwitch(*flag)) {
82 SimpleAlertInfoBarDelegate::Create(
83 InfoBarService::FromWebContents(web_contents),
84 infobars::InfoBarDelegate::kNoIconID,
85 l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE,
86 base::UTF8ToUTF16(
87 std::string("--") + *flag)),
88 false);
89 return;
94 void MaybeShowInvalidUserDataDirWarningDialog() {
95 const base::FilePath& user_data_dir = GetInvalidSpecifiedUserDataDir();
96 if (user_data_dir.empty())
97 return;
99 startup_metric_utils::SetNonBrowserUIDisplayed();
101 // Ensure the ResourceBundle is initialized for string resource access.
102 bool cleanup_resource_bundle = false;
103 if (!ResourceBundle::HasSharedInstance()) {
104 cleanup_resource_bundle = true;
105 std::string locale = l10n_util::GetApplicationLocale(std::string());
106 const char kUserDataDirDialogFallbackLocale[] = "en-US";
107 if (locale.empty())
108 locale = kUserDataDirDialogFallbackLocale;
109 ui::ResourceBundle::InitSharedInstanceWithLocale(
110 locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
113 const base::string16& title =
114 l10n_util::GetStringUTF16(IDS_CANT_WRITE_USER_DIRECTORY_TITLE);
115 const base::string16& message =
116 l10n_util::GetStringFUTF16(IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY,
117 user_data_dir.LossyDisplayName());
119 if (cleanup_resource_bundle)
120 ResourceBundle::CleanupSharedInstance();
122 // More complex dialogs cannot be shown before the earliest calls here.
123 ShowMessageBox(NULL, title, message, chrome::MESSAGE_BOX_TYPE_WARNING);
126 } // namespace chrome