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/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/browser/infobars/infobar_tab_helper.h" | 10 #include "chrome/browser/infobars/infobar_tab_helper.h" |
11 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" | 11 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_tabstrip.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
14 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
16 | 17 |
17 namespace browser { | 18 namespace browser { |
18 | 19 |
19 void ShowBadFlagsPrompt(Browser* browser) { | 20 void ShowBadFlagsPrompt(Browser* browser) { |
20 // Unsupported flags for which to display a warning that "stability and | 21 // Unsupported flags for which to display a warning that "stability and |
21 // security will suffer". | 22 // security will suffer". |
22 static const char* kBadFlags[] = { | 23 static const char* kBadFlags[] = { |
23 // These imply disabling the sandbox. | 24 // These imply disabling the sandbox. |
24 switches::kSingleProcess, | 25 switches::kSingleProcess, |
25 switches::kNoSandbox, | 26 switches::kNoSandbox, |
26 switches::kInProcessWebGL, | 27 switches::kInProcessWebGL, |
27 switches::kDisableWebSecurity, | 28 switches::kDisableWebSecurity, |
28 NULL | 29 NULL |
29 }; | 30 }; |
30 | 31 |
31 const char* bad_flag = NULL; | 32 const char* bad_flag = NULL; |
32 for (const char** flag = kBadFlags; *flag; ++flag) { | 33 for (const char** flag = kBadFlags; *flag; ++flag) { |
33 if (CommandLine::ForCurrentProcess()->HasSwitch(*flag)) { | 34 if (CommandLine::ForCurrentProcess()->HasSwitch(*flag)) { |
34 bad_flag = *flag; | 35 bad_flag = *flag; |
35 break; | 36 break; |
36 } | 37 } |
37 } | 38 } |
38 | 39 |
39 if (bad_flag) { | 40 if (bad_flag) { |
40 TabContents* tab = browser->GetActiveTabContents(); | 41 TabContents* tab = chrome::GetActiveTabContents(browser); |
41 if (!tab) | 42 if (!tab) |
42 return; | 43 return; |
43 tab->infobar_tab_helper()->AddInfoBar( | 44 tab->infobar_tab_helper()->AddInfoBar( |
44 new SimpleAlertInfoBarDelegate( | 45 new SimpleAlertInfoBarDelegate( |
45 tab->infobar_tab_helper(), NULL, | 46 tab->infobar_tab_helper(), NULL, |
46 l10n_util::GetStringFUTF16( | 47 l10n_util::GetStringFUTF16( |
47 IDS_BAD_FLAGS_WARNING_MESSAGE, | 48 IDS_BAD_FLAGS_WARNING_MESSAGE, |
48 UTF8ToUTF16(std::string("--") + bad_flag)), | 49 UTF8ToUTF16(std::string("--") + bad_flag)), |
49 false)); | 50 false)); |
50 } | 51 } |
51 } | 52 } |
52 | 53 |
53 } // namespace browser | 54 } // namespace browser |
OLD | NEW |