| 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/webui/web_ui.h" |
| 24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/browser/web_ui_message_handler.h" | 26 #include "content/public/browser/web_ui_message_handler.h" |
| 26 #include "grit/browser_resources.h" | 27 #include "grit/browser_resources.h" |
| 27 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 29 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 30 #include "grit/theme_resources_standard.h" | 31 #include "grit/theme_resources_standard.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
| 33 | 34 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 153 } |
| 153 | 154 |
| 154 } // namespace | 155 } // namespace |
| 155 | 156 |
| 156 /////////////////////////////////////////////////////////////////////////////// | 157 /////////////////////////////////////////////////////////////////////////////// |
| 157 // | 158 // |
| 158 // CrashesUI | 159 // CrashesUI |
| 159 // | 160 // |
| 160 /////////////////////////////////////////////////////////////////////////////// | 161 /////////////////////////////////////////////////////////////////////////////// |
| 161 | 162 |
| 162 CrashesUI::CrashesUI(WebContents* contents) : WebUI(contents, this) { | 163 CrashesUI::CrashesUI(WebUI* web_ui) : WebUIController(web_ui) { |
| 163 AddMessageHandler(new CrashesDOMHandler()); | 164 web_ui->AddMessageHandler(new CrashesDOMHandler()); |
| 164 | 165 |
| 165 // Set up the chrome://crashes/ source. | 166 // Set up the chrome://crashes/ source. |
| 166 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 167 Profile* profile = Profile::FromBrowserContext( |
| 168 web_ui->web_contents()->GetBrowserContext()); |
| 167 profile->GetChromeURLDataManager()->AddDataSource( | 169 profile->GetChromeURLDataManager()->AddDataSource( |
| 168 CreateCrashesUIHTMLSource()); | 170 CreateCrashesUIHTMLSource()); |
| 169 } | 171 } |
| 170 | 172 |
| 171 // static | 173 // static |
| 172 RefCountedMemory* CrashesUI::GetFaviconResourceBytes() { | 174 RefCountedMemory* CrashesUI::GetFaviconResourceBytes() { |
| 173 return ResourceBundle::GetSharedInstance(). | 175 return ResourceBundle::GetSharedInstance(). |
| 174 LoadDataResourceBytes(IDR_SAD_FAVICON); | 176 LoadDataResourceBytes(IDR_SAD_FAVICON); |
| 175 } | 177 } |
| 176 | 178 |
| 177 // static | 179 // static |
| 178 bool CrashesUI::CrashReportingEnabled() { | 180 bool CrashesUI::CrashReportingEnabled() { |
| 179 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) | 181 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
| 180 PrefService* prefs = g_browser_process->local_state(); | 182 PrefService* prefs = g_browser_process->local_state(); |
| 181 return prefs->GetBoolean(prefs::kMetricsReportingEnabled); | 183 return prefs->GetBoolean(prefs::kMetricsReportingEnabled); |
| 182 #elif defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) | 184 #elif defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) |
| 183 bool reporting_enabled = false; | 185 bool reporting_enabled = false; |
| 184 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | 186 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, |
| 185 &reporting_enabled); | 187 &reporting_enabled); |
| 186 return reporting_enabled; | 188 return reporting_enabled; |
| 187 #else | 189 #else |
| 188 return false; | 190 return false; |
| 189 #endif | 191 #endif |
| 190 } | 192 } |
| OLD | NEW |