Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/browser/ui/webui/crashes_ui.cc

Issue 2324983002: [Android] Wire up manual crash uploads. (Closed)
Patch Set: Fix pending upload handling, and nit fixes Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/webui/crashes_ui.h" 5 #include "chrome/browser/ui/webui/crashes_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 void HandleRequestCrashes(const base::ListValue* args); 86 void HandleRequestCrashes(const base::ListValue* args);
87 87
88 #if defined(OS_CHROMEOS) 88 #if defined(OS_CHROMEOS)
89 // Asynchronously triggers crash uploading. Called from JS. 89 // Asynchronously triggers crash uploading. Called from JS.
90 void HandleRequestUploads(const base::ListValue* args); 90 void HandleRequestUploads(const base::ListValue* args);
91 #endif 91 #endif
92 92
93 // Sends the recent crashes list JS. 93 // Sends the recent crashes list JS.
94 void UpdateUI(); 94 void UpdateUI();
95 95
96 #if defined(OS_WIN) || defined(OS_MACOSX)
97 // Asynchronously requests a user triggered upload. Called from JS. 96 // Asynchronously requests a user triggered upload. Called from JS.
98 void HandleRequestSingleCrashUpload(const base::ListValue* args); 97 void HandleRequestSingleCrashUpload(const base::ListValue* args);
99 #endif
100 98
101 scoped_refptr<CrashUploadList> upload_list_; 99 scoped_refptr<CrashUploadList> upload_list_;
102 bool list_available_; 100 bool list_available_;
103 bool first_load_; 101 bool first_load_;
104 102
105 DISALLOW_COPY_AND_ASSIGN(CrashesDOMHandler); 103 DISALLOW_COPY_AND_ASSIGN(CrashesDOMHandler);
106 }; 104 };
107 105
108 CrashesDOMHandler::CrashesDOMHandler() 106 CrashesDOMHandler::CrashesDOMHandler()
109 : list_available_(false), first_load_(true) { 107 : list_available_(false), first_load_(true) {
(...skipping 11 matching lines...) Expand all
121 base::Bind(&CrashesDOMHandler::HandleRequestCrashes, 119 base::Bind(&CrashesDOMHandler::HandleRequestCrashes,
122 base::Unretained(this))); 120 base::Unretained(this)));
123 121
124 #if defined(OS_CHROMEOS) 122 #if defined(OS_CHROMEOS)
125 web_ui()->RegisterMessageCallback( 123 web_ui()->RegisterMessageCallback(
126 crash::kCrashesUIRequestCrashUpload, 124 crash::kCrashesUIRequestCrashUpload,
127 base::Bind(&CrashesDOMHandler::HandleRequestUploads, 125 base::Bind(&CrashesDOMHandler::HandleRequestUploads,
128 base::Unretained(this))); 126 base::Unretained(this)));
129 #endif 127 #endif
130 128
131 #if defined(OS_WIN) || defined(OS_MACOSX)
132 web_ui()->RegisterMessageCallback( 129 web_ui()->RegisterMessageCallback(
133 crash::kCrashesUIRequestSingleCrashUpload, 130 crash::kCrashesUIRequestSingleCrashUpload,
134 base::Bind(&CrashesDOMHandler::HandleRequestSingleCrashUpload, 131 base::Bind(&CrashesDOMHandler::HandleRequestSingleCrashUpload,
135 base::Unretained(this))); 132 base::Unretained(this)));
136 #endif
137 } 133 }
138 134
139 void CrashesDOMHandler::HandleRequestCrashes(const base::ListValue* args) { 135 void CrashesDOMHandler::HandleRequestCrashes(const base::ListValue* args) {
140 if (first_load_) { 136 if (first_load_) {
141 first_load_ = false; 137 first_load_ = false;
142 if (list_available_) 138 if (list_available_)
143 UpdateUI(); 139 UpdateUI();
144 } else { 140 } else {
145 list_available_ = false; 141 list_available_ = false;
146 upload_list_->LoadUploadListAsynchronously(); 142 upload_list_->LoadUploadListAsynchronously();
(...skipping 22 matching lines...) Expand all
169 165
170 bool system_crash_reporter = false; 166 bool system_crash_reporter = false;
171 #if defined(OS_CHROMEOS) 167 #if defined(OS_CHROMEOS)
172 // Chrome OS has a system crash reporter. 168 // Chrome OS has a system crash reporter.
173 system_crash_reporter = true; 169 system_crash_reporter = true;
174 #endif 170 #endif
175 171
176 bool upload_list = crash_reporting_enabled; 172 bool upload_list = crash_reporting_enabled;
177 bool support_manual_uploads = false; 173 bool support_manual_uploads = false;
178 174
179 #if defined(OS_WIN) || defined(OS_MACOSX) 175 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_ANDROID)
180 // Maunal uploads currently are supported only for Crashpad-using platforms 176 // Maunal uploads currently are supported only for Crashpad-using platforms
181 // and only if crash uploads are not disabled by policy. 177 // and Android, and only if crash uploads are not disabled by policy.
182 support_manual_uploads = 178 support_manual_uploads =
183 crash_reporting_enabled || !IsMetricsReportingPolicyManaged(); 179 crash_reporting_enabled || !IsMetricsReportingPolicyManaged();
184 180
185 // Show crash reports regardless of |crash_reporting_enabled| so that users 181 // Show crash reports regardless of |crash_reporting_enabled| so that users
186 // can manually upload those reports. 182 // can manually upload those reports.
187 upload_list = true; 183 upload_list = true;
188 #endif 184 #endif
189 185
190 base::ListValue crash_list; 186 base::ListValue crash_list;
191 if (upload_list) 187 if (upload_list)
(...skipping 10 matching lines...) Expand all
202 args.push_back(&enabled); 198 args.push_back(&enabled);
203 args.push_back(&dynamic_backend); 199 args.push_back(&dynamic_backend);
204 args.push_back(&manual_uploads); 200 args.push_back(&manual_uploads);
205 args.push_back(&crash_list); 201 args.push_back(&crash_list);
206 args.push_back(&version); 202 args.push_back(&version);
207 args.push_back(&os_string); 203 args.push_back(&os_string);
208 web_ui()->CallJavascriptFunctionUnsafe(crash::kCrashesUIUpdateCrashList, 204 web_ui()->CallJavascriptFunctionUnsafe(crash::kCrashesUIUpdateCrashList,
209 args); 205 args);
210 } 206 }
211 207
212 #if defined(OS_WIN) || defined(OS_MACOSX)
213 void CrashesDOMHandler::HandleRequestSingleCrashUpload( 208 void CrashesDOMHandler::HandleRequestSingleCrashUpload(
214 const base::ListValue* args) { 209 const base::ListValue* args) {
215 DCHECK(args); 210 DCHECK(args);
216 211
217 std::string local_id; 212 std::string local_id;
218 bool success = args->GetString(0, &local_id); 213 bool success = args->GetString(0, &local_id);
219 DCHECK(success); 214 DCHECK(success);
220 215
221 // Only allow manual uploads if crash uploads aren’t disabled by policy. 216 // Only allow manual uploads if crash uploads aren’t disabled by policy.
222 if (!ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled() && 217 if (!ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled() &&
223 IsMetricsReportingPolicyManaged()) { 218 IsMetricsReportingPolicyManaged()) {
224 return; 219 return;
225 } 220 }
226 upload_list_->RequestSingleCrashUploadAsync(local_id); 221 upload_list_->RequestSingleCrashUploadAsync(local_id);
227 } 222 }
228 #endif
229 223
230 } // namespace 224 } // namespace
231 225
232 /////////////////////////////////////////////////////////////////////////////// 226 ///////////////////////////////////////////////////////////////////////////////
233 // 227 //
234 // CrashesUI 228 // CrashesUI
235 // 229 //
236 /////////////////////////////////////////////////////////////////////////////// 230 ///////////////////////////////////////////////////////////////////////////////
237 231
238 CrashesUI::CrashesUI(content::WebUI* web_ui) : WebUIController(web_ui) { 232 CrashesUI::CrashesUI(content::WebUI* web_ui) : WebUIController(web_ui) {
239 web_ui->AddMessageHandler(new CrashesDOMHandler()); 233 web_ui->AddMessageHandler(new CrashesDOMHandler());
240 234
241 // Set up the chrome://crashes/ source. 235 // Set up the chrome://crashes/ source.
242 Profile* profile = Profile::FromWebUI(web_ui); 236 Profile* profile = Profile::FromWebUI(web_ui);
243 content::WebUIDataSource::Add(profile, CreateCrashesUIHTMLSource()); 237 content::WebUIDataSource::Add(profile, CreateCrashesUIHTMLSource());
244 } 238 }
245 239
246 // static 240 // static
247 base::RefCountedMemory* CrashesUI::GetFaviconResourceBytes( 241 base::RefCountedMemory* CrashesUI::GetFaviconResourceBytes(
248 ui::ScaleFactor scale_factor) { 242 ui::ScaleFactor scale_factor) {
249 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 243 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
250 IDR_CRASH_SAD_FAVICON, scale_factor); 244 IDR_CRASH_SAD_FAVICON, scale_factor);
251 } 245 }
OLDNEW
« no previous file with comments | « chrome/browser/crash_upload_list/crash_upload_list_android.cc ('k') | components/upload_list/upload_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698