Chromium Code Reviews| 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 "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 | 120 |
| 121 scoped_refptr<CrashUploadList> upload_list_; | 121 scoped_refptr<CrashUploadList> upload_list_; |
| 122 bool list_available_; | 122 bool list_available_; |
| 123 bool js_request_pending_; | 123 bool js_request_pending_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(CrashesDOMHandler); | 125 DISALLOW_COPY_AND_ASSIGN(CrashesDOMHandler); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 CrashesDOMHandler::CrashesDOMHandler() | 128 CrashesDOMHandler::CrashesDOMHandler() |
| 129 : list_available_(false), js_request_pending_(false) { | 129 : list_available_(false), js_request_pending_(false) { |
| 130 upload_list_ = new CrashUploadList(this); | 130 upload_list_ = CrashUploadList::Create(this); |
| 131 } | 131 } |
| 132 | 132 |
| 133 CrashesDOMHandler::~CrashesDOMHandler() { | 133 CrashesDOMHandler::~CrashesDOMHandler() { |
| 134 upload_list_->ClearDelegate(); | 134 upload_list_->ClearDelegate(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 WebUIMessageHandler* CrashesDOMHandler::Attach(WebUI* web_ui) { | 137 WebUIMessageHandler* CrashesDOMHandler::Attach(WebUI* web_ui) { |
| 138 upload_list_->LoadCrashListAsynchronously(); | 138 upload_list_->LoadCrashListAsynchronously(); |
| 139 return WebUIMessageHandler::Attach(web_ui); | 139 return WebUIMessageHandler::Attach(web_ui); |
| 140 } | 140 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 FundamentalValue enabled(crash_reporting_enabled); | 178 FundamentalValue enabled(crash_reporting_enabled); |
| 179 | 179 |
| 180 web_ui_->CallJavascriptFunction("updateCrashList", enabled, crash_list); | 180 web_ui_->CallJavascriptFunction("updateCrashList", enabled, crash_list); |
| 181 } | 181 } |
| 182 | 182 |
| 183 bool CrashesDOMHandler::CrashReportingEnabled() const { | 183 bool CrashesDOMHandler::CrashReportingEnabled() const { |
| 184 #if defined(GOOGLE_CHROME_BUILD) | 184 #if defined(GOOGLE_CHROME_BUILD) |
| 185 PrefService* prefs = g_browser_process->local_state(); | 185 PrefService* prefs = g_browser_process->local_state(); |
| 186 return prefs->GetBoolean(prefs::kMetricsReportingEnabled); | 186 return prefs->GetBoolean(prefs::kMetricsReportingEnabled); |
| 187 #else | 187 #else |
| 188 return false; | 188 return true; |
|
stuartmorgan
2011/03/30 16:28:10
This needs to not be part of the CL.
Alexei Svitkine (slow)
2011/03/30 18:54:37
Forgot to revert that! Done now..
| |
| 189 #endif | 189 #endif |
| 190 } | 190 } |
| 191 | 191 |
| 192 } // namespace | 192 } // namespace |
| 193 | 193 |
| 194 /////////////////////////////////////////////////////////////////////////////// | 194 /////////////////////////////////////////////////////////////////////////////// |
| 195 // | 195 // |
| 196 // CrashesUI | 196 // CrashesUI |
| 197 // | 197 // |
| 198 /////////////////////////////////////////////////////////////////////////////// | 198 /////////////////////////////////////////////////////////////////////////////// |
| 199 | 199 |
| 200 CrashesUI::CrashesUI(TabContents* contents) : WebUI(contents) { | 200 CrashesUI::CrashesUI(TabContents* contents) : WebUI(contents) { |
| 201 AddMessageHandler((new CrashesDOMHandler())->Attach(this)); | 201 AddMessageHandler((new CrashesDOMHandler())->Attach(this)); |
| 202 | 202 |
| 203 CrashesUIHTMLSource* html_source = new CrashesUIHTMLSource(); | 203 CrashesUIHTMLSource* html_source = new CrashesUIHTMLSource(); |
| 204 | 204 |
| 205 // Set up the chrome://crashes/ source. | 205 // Set up the chrome://crashes/ source. |
| 206 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 206 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
| 207 } | 207 } |
| 208 | 208 |
| 209 // static | 209 // static |
| 210 RefCountedMemory* CrashesUI::GetFaviconResourceBytes() { | 210 RefCountedMemory* CrashesUI::GetFaviconResourceBytes() { |
| 211 return ResourceBundle::GetSharedInstance(). | 211 return ResourceBundle::GetSharedInstance(). |
| 212 LoadDataResourceBytes(IDR_SAD_FAVICON); | 212 LoadDataResourceBytes(IDR_SAD_FAVICON); |
| 213 } | 213 } |
| OLD | NEW |