OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webui/crashes_ui.h" | 5 #include "chrome/browser/ui/webui/crashes_ui.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/i18n/time_formatting.h" | 11 #include "base/i18n/time_formatting.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/crash_upload_list.h" | 16 #include "chrome/browser/crash_upload_list.h" |
17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 19 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
20 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 20 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
21 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
24 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/public/browser/web_contents.h" |
25 #include "grit/browser_resources.h" | 25 #include "grit/browser_resources.h" |
26 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
28 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
29 #include "grit/theme_resources_standard.h" | 29 #include "grit/theme_resources_standard.h" |
30 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
32 | 32 |
33 #if defined(OS_CHROMEOS) | 33 #if defined(OS_CHROMEOS) |
34 #include "chrome/browser/chromeos/cros_settings.h" | 34 #include "chrome/browser/chromeos/cros_settings.h" |
35 #endif | 35 #endif |
36 | 36 |
| 37 using content::WebContents; |
| 38 |
37 namespace { | 39 namespace { |
38 | 40 |
39 ChromeWebUIDataSource* CreateCrashesUIHTMLSource() { | 41 ChromeWebUIDataSource* CreateCrashesUIHTMLSource() { |
40 ChromeWebUIDataSource* source = | 42 ChromeWebUIDataSource* source = |
41 new ChromeWebUIDataSource(chrome::kChromeUICrashesHost); | 43 new ChromeWebUIDataSource(chrome::kChromeUICrashesHost); |
42 | 44 |
43 source->AddLocalizedString("crashesTitle", IDS_CRASHES_TITLE); | 45 source->AddLocalizedString("crashesTitle", IDS_CRASHES_TITLE); |
44 source->AddLocalizedString("crashCountFormat", | 46 source->AddLocalizedString("crashCountFormat", |
45 IDS_CRASHES_CRASH_COUNT_BANNER_FORMAT); | 47 IDS_CRASHES_CRASH_COUNT_BANNER_FORMAT); |
46 source->AddLocalizedString("crashHeaderFormat", | 48 source->AddLocalizedString("crashHeaderFormat", |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 150 } |
149 | 151 |
150 } // namespace | 152 } // namespace |
151 | 153 |
152 /////////////////////////////////////////////////////////////////////////////// | 154 /////////////////////////////////////////////////////////////////////////////// |
153 // | 155 // |
154 // CrashesUI | 156 // CrashesUI |
155 // | 157 // |
156 /////////////////////////////////////////////////////////////////////////////// | 158 /////////////////////////////////////////////////////////////////////////////// |
157 | 159 |
158 CrashesUI::CrashesUI(TabContents* contents) : ChromeWebUI(contents) { | 160 CrashesUI::CrashesUI(WebContents* contents) : ChromeWebUI(contents) { |
159 AddMessageHandler(new CrashesDOMHandler()); | 161 AddMessageHandler(new CrashesDOMHandler()); |
160 | 162 |
161 // Set up the chrome://crashes/ source. | 163 // Set up the chrome://crashes/ source. |
162 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 164 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
163 profile->GetChromeURLDataManager()->AddDataSource( | 165 profile->GetChromeURLDataManager()->AddDataSource( |
164 CreateCrashesUIHTMLSource()); | 166 CreateCrashesUIHTMLSource()); |
165 } | 167 } |
166 | 168 |
167 // static | 169 // static |
168 RefCountedMemory* CrashesUI::GetFaviconResourceBytes() { | 170 RefCountedMemory* CrashesUI::GetFaviconResourceBytes() { |
169 return ResourceBundle::GetSharedInstance(). | 171 return ResourceBundle::GetSharedInstance(). |
170 LoadDataResourceBytes(IDR_SAD_FAVICON); | 172 LoadDataResourceBytes(IDR_SAD_FAVICON); |
171 } | 173 } |
172 | 174 |
173 // static | 175 // static |
174 bool CrashesUI::CrashReportingEnabled() { | 176 bool CrashesUI::CrashReportingEnabled() { |
175 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) | 177 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
176 PrefService* prefs = g_browser_process->local_state(); | 178 PrefService* prefs = g_browser_process->local_state(); |
177 return prefs->GetBoolean(prefs::kMetricsReportingEnabled); | 179 return prefs->GetBoolean(prefs::kMetricsReportingEnabled); |
178 #elif defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) | 180 #elif defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) |
179 bool reporting_enabled = false; | 181 bool reporting_enabled = false; |
180 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | 182 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, |
181 &reporting_enabled); | 183 &reporting_enabled); |
182 return reporting_enabled; | 184 return reporting_enabled; |
183 #else | 185 #else |
184 return false; | 186 return false; |
185 #endif | 187 #endif |
186 } | 188 } |
OLD | NEW |