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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h" | 11 #include "chrome/browser/infobars/simple_alert_infobar_delegate.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/simple_message_box.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/common/chrome_paths.h" |
13 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/switch_utils.h" |
| 18 #include "components/startup_metric_utils/startup_metric_utils.h" |
14 #include "components/translate/core/common/translate_switches.h" | 19 #include "components/translate/core/common/translate_switches.h" |
15 #include "extensions/common/switches.h" | 20 #include "extensions/common/switches.h" |
| 21 #include "grit/chromium_strings.h" |
16 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
17 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/resource/resource_bundle.h" |
18 | 25 |
19 namespace chrome { | 26 namespace chrome { |
20 | 27 |
21 void ShowBadFlagsPrompt(Browser* browser) { | 28 void ShowBadFlagsPrompt(Browser* browser) { |
22 content::WebContents* web_contents = | 29 content::WebContents* web_contents = |
23 browser->tab_strip_model()->GetActiveWebContents(); | 30 browser->tab_strip_model()->GetActiveWebContents(); |
24 if (!web_contents) | 31 if (!web_contents) |
25 return; | 32 return; |
26 | 33 |
27 // Unsupported flags for which to display a warning that "stability and | 34 // Unsupported flags for which to display a warning that "stability and |
(...skipping 24 matching lines...) Expand all Loading... |
52 InfoBarDelegate::kNoIconID, | 59 InfoBarDelegate::kNoIconID, |
53 l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE, | 60 l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE, |
54 base::UTF8ToUTF16( | 61 base::UTF8ToUTF16( |
55 std::string("--") + *flag)), | 62 std::string("--") + *flag)), |
56 false); | 63 false); |
57 return; | 64 return; |
58 } | 65 } |
59 } | 66 } |
60 } | 67 } |
61 | 68 |
| 69 void MaybeShowInvalidUserDataDirWarningDialog() { |
| 70 const base::FilePath& user_data_dir = GetInvalidSpecifiedUserDataDir(); |
| 71 if (user_data_dir.empty()) |
| 72 return; |
| 73 |
| 74 startup_metric_utils::SetNonBrowserUIDisplayed(); |
| 75 |
| 76 // Ensure the ResourceBundle is initialized for string resource access. |
| 77 bool cleanup_resource_bundle = false; |
| 78 if (!ResourceBundle::HasSharedInstance()) { |
| 79 cleanup_resource_bundle = true; |
| 80 std::string locale = l10n_util::GetApplicationLocale(std::string()); |
| 81 const char kUserDataDirDialogFallbackLocale[] = "en-US"; |
| 82 if (locale.empty()) |
| 83 locale = kUserDataDirDialogFallbackLocale; |
| 84 ResourceBundle::InitSharedInstanceWithLocale(locale, NULL); |
| 85 } |
| 86 |
| 87 const base::string16& title = |
| 88 l10n_util::GetStringUTF16(IDS_CANT_WRITE_USER_DIRECTORY_TITLE); |
| 89 const base::string16& message = |
| 90 l10n_util::GetStringFUTF16(IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY, |
| 91 user_data_dir.LossyDisplayName()); |
| 92 |
| 93 if (cleanup_resource_bundle) |
| 94 ResourceBundle::CleanupSharedInstance(); |
| 95 |
| 96 // More complex dialogs cannot be shown before the earliest calls here. |
| 97 ShowMessageBox(NULL, title, message, chrome::MESSAGE_BOX_TYPE_WARNING); |
| 98 } |
| 99 |
62 } // namespace chrome | 100 } // namespace chrome |
OLD | NEW |