Chromium Code Reviews| 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/ui/startup/bad_flags_prompt.h" | 5 #include "chrome/browser/ui/startup/bad_flags_prompt.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/simple_message_box.h" | 12 #include "chrome/browser/ui/simple_message_box.h" |
| 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/switch_utils.h" | 16 #include "chrome/common/switch_utils.h" |
| 17 #include "chrome/grit/chromium_strings.h" | 17 #include "chrome/grit/chromium_strings.h" |
| 18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 19 #include "components/infobars/core/simple_alert_infobar_delegate.h" | 19 #include "components/infobars/core/simple_alert_infobar_delegate.h" |
| 20 #include "components/invalidation/invalidation_switches.h" | 20 #include "components/invalidation/invalidation_switches.h" |
| 21 #include "components/nacl/common/nacl_switches.h" | 21 #include "components/nacl/common/nacl_switches.h" |
| 22 #include "components/startup_metric_utils/startup_metric_utils.h" | 22 #include "components/startup_metric_utils/startup_metric_utils.h" |
| 23 #include "components/translate/core/common/translate_switches.h" | 23 #include "components/translate/core/common/translate_switches.h" |
| 24 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 25 #include "extensions/common/switches.h" | 25 #include "extensions/common/switches.h" |
| 26 #include "google_apis/gaia/gaia_switches.h" | 26 #include "google_apis/gaia/gaia_switches.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 29 | 29 |
| 30 #if defined(OS_WIN) | |
|
jam
2015/01/22 17:00:15
nit: here and in other places, you don't need the
| |
| 31 #include "ui/gfx/switches.h" | |
| 32 #endif | |
| 33 | |
| 30 namespace chrome { | 34 namespace chrome { |
| 31 | 35 |
| 32 void ShowBadFlagsPrompt(Browser* browser) { | 36 void ShowBadFlagsPrompt(Browser* browser) { |
| 33 content::WebContents* web_contents = | 37 content::WebContents* web_contents = |
| 34 browser->tab_strip_model()->GetActiveWebContents(); | 38 browser->tab_strip_model()->GetActiveWebContents(); |
| 35 if (!web_contents) | 39 if (!web_contents) |
| 36 return; | 40 return; |
| 37 | 41 |
| 38 // Unsupported flags for which to display a warning that "stability and | 42 // Unsupported flags for which to display a warning that "stability and |
| 39 // security will suffer". | 43 // security will suffer". In reverse order of severity - most serious |
| 44 // switches should be nearer the top. | |
| 40 static const char* kBadFlags[] = { | 45 static const char* kBadFlags[] = { |
| 41 // These flags disable sandbox-related security. | 46 // These flags disable sandbox-related security. |
| 47 switches::kNoSandbox, | |
| 42 switches::kDisableGpuSandbox, | 48 switches::kDisableGpuSandbox, |
| 43 switches::kDisableSeccompFilterSandbox, | 49 switches::kDisableSeccompFilterSandbox, |
| 44 switches::kDisableSetuidSandbox, | 50 switches::kDisableSetuidSandbox, |
| 45 switches::kDisableWebSecurity, | 51 switches::kDisableWebSecurity, |
| 46 #if !defined(DISABLE_NACL) | 52 #if !defined(DISABLE_NACL) |
| 47 switches::kNaClDangerousNoSandboxNonSfi, | 53 switches::kNaClDangerousNoSandboxNonSfi, |
| 48 #endif | 54 #endif |
| 49 switches::kNoSandbox, | |
| 50 switches::kSingleProcess, | 55 switches::kSingleProcess, |
| 51 | 56 |
| 52 // These flags disable or undermine the Same Origin Policy. | 57 // These flags disable or undermine the Same Origin Policy. |
| 53 switches::kTrustedSpdyProxy, | 58 switches::kTrustedSpdyProxy, |
| 54 translate::switches::kTranslateSecurityOrigin, | 59 translate::switches::kTranslateSecurityOrigin, |
| 55 | 60 |
| 56 // These flags undermine HTTPS / connection security. | 61 // These flags undermine HTTPS / connection security. |
| 57 #if defined(ENABLE_WEBRTC) | 62 #if defined(ENABLE_WEBRTC) |
| 58 switches::kDisableWebRtcEncryption, | 63 switches::kDisableWebRtcEncryption, |
| 59 #endif | 64 #endif |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 70 extensions::switches::kExtensionsOnChromeURLs, | 75 extensions::switches::kExtensionsOnChromeURLs, |
| 71 | 76 |
| 72 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 77 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 73 // Speech dispatcher is buggy, it can crash and it can make Chrome freeze. | 78 // Speech dispatcher is buggy, it can crash and it can make Chrome freeze. |
| 74 // http://crbug.com/327295 | 79 // http://crbug.com/327295 |
| 75 switches::kEnableSpeechDispatcher, | 80 switches::kEnableSpeechDispatcher, |
| 76 #endif | 81 #endif |
| 77 NULL | 82 NULL |
| 78 }; | 83 }; |
| 79 | 84 |
| 85 std::string warning_switch; | |
| 86 | |
| 87 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | |
| 88 | |
| 89 #if defined(OS_WIN) | |
| 90 if (switches::IsWin32kRendererLockdownEnabled(true) && | |
| 91 cmd_line->HasSwitch(switches::kDisableDirectWrite)) { | |
| 92 warning_switch = switches::kDisableDirectWrite; | |
| 93 } | |
| 94 #endif | |
| 95 | |
| 80 for (const char** flag = kBadFlags; *flag; ++flag) { | 96 for (const char** flag = kBadFlags; *flag; ++flag) { |
| 81 if (base::CommandLine::ForCurrentProcess()->HasSwitch(*flag)) { | 97 if (cmd_line->HasSwitch(*flag)) { |
| 82 SimpleAlertInfoBarDelegate::Create( | 98 warning_switch = *flag; |
| 83 InfoBarService::FromWebContents(web_contents), | 99 break; |
| 84 infobars::InfoBarDelegate::kNoIconID, | |
| 85 l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE, | |
| 86 base::UTF8ToUTF16( | |
| 87 std::string("--") + *flag)), | |
| 88 false); | |
| 89 return; | |
| 90 } | 100 } |
| 91 } | 101 } |
| 102 | |
| 103 if (warning_switch.empty()) | |
| 104 return; | |
| 105 | |
| 106 SimpleAlertInfoBarDelegate::Create( | |
| 107 InfoBarService::FromWebContents(web_contents), | |
| 108 infobars::InfoBarDelegate::kNoIconID, | |
| 109 l10n_util::GetStringFUTF16( | |
| 110 IDS_BAD_FLAGS_WARNING_MESSAGE, | |
| 111 base::UTF8ToUTF16(std::string("--") + warning_switch)), | |
| 112 false); | |
| 92 } | 113 } |
| 93 | 114 |
| 94 void MaybeShowInvalidUserDataDirWarningDialog() { | 115 void MaybeShowInvalidUserDataDirWarningDialog() { |
| 95 const base::FilePath& user_data_dir = GetInvalidSpecifiedUserDataDir(); | 116 const base::FilePath& user_data_dir = GetInvalidSpecifiedUserDataDir(); |
| 96 if (user_data_dir.empty()) | 117 if (user_data_dir.empty()) |
| 97 return; | 118 return; |
| 98 | 119 |
| 99 startup_metric_utils::SetNonBrowserUIDisplayed(); | 120 startup_metric_utils::SetNonBrowserUIDisplayed(); |
| 100 | 121 |
| 101 // Ensure the ResourceBundle is initialized for string resource access. | 122 // Ensure the ResourceBundle is initialized for string resource access. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 117 user_data_dir.LossyDisplayName()); | 138 user_data_dir.LossyDisplayName()); |
| 118 | 139 |
| 119 if (cleanup_resource_bundle) | 140 if (cleanup_resource_bundle) |
| 120 ResourceBundle::CleanupSharedInstance(); | 141 ResourceBundle::CleanupSharedInstance(); |
| 121 | 142 |
| 122 // More complex dialogs cannot be shown before the earliest calls here. | 143 // More complex dialogs cannot be shown before the earliest calls here. |
| 123 ShowMessageBox(NULL, title, message, chrome::MESSAGE_BOX_TYPE_WARNING); | 144 ShowMessageBox(NULL, title, message, chrome::MESSAGE_BOX_TYPE_WARNING); |
| 124 } | 145 } |
| 125 | 146 |
| 126 } // namespace chrome | 147 } // namespace chrome |
| OLD | NEW |