OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/net_export_ui.h" | 5 #include "chrome/browser/ui/webui/net_export_ui.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/download/download_prefs.h" | 19 #include "chrome/browser/download/download_prefs.h" |
20 #include "chrome/browser/platform_util.h" | 20 #include "chrome/browser/platform_util.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/ui/chrome_select_file_policy.h" | 22 #include "chrome/browser/ui/chrome_select_file_policy.h" |
23 #include "chrome/common/features.h" | |
24 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
25 #include "components/grit/components_resources.h" | 24 #include "components/grit/components_resources.h" |
26 #include "components/net_log/chrome_net_log.h" | 25 #include "components/net_log/chrome_net_log.h" |
27 #include "components/net_log/net_export_ui_constants.h" | 26 #include "components/net_log/net_export_ui_constants.h" |
28 #include "components/net_log/net_log_file_writer.h" | 27 #include "components/net_log/net_log_file_writer.h" |
29 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/url_data_source.h" | 29 #include "content/public/browser/url_data_source.h" |
31 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
32 #include "content/public/browser/web_ui.h" | 31 #include "content/public/browser/web_ui.h" |
33 #include "content/public/browser/web_ui_data_source.h" | 32 #include "content/public/browser/web_ui_data_source.h" |
34 #include "content/public/browser/web_ui_message_handler.h" | 33 #include "content/public/browser/web_ui_message_handler.h" |
35 #include "ui/shell_dialogs/select_file_dialog.h" | 34 #include "ui/shell_dialogs/select_file_dialog.h" |
36 | 35 |
37 #if BUILDFLAG(ANDROID_JAVA_UI) | 36 #if defined(OS_ANDROID) |
38 #include "chrome/browser/android/intent_helper.h" | 37 #include "chrome/browser/android/intent_helper.h" |
39 #endif | 38 #endif |
40 | 39 |
41 using content::BrowserThread; | 40 using content::BrowserThread; |
42 using content::WebContents; | 41 using content::WebContents; |
43 using content::WebUIMessageHandler; | 42 using content::WebUIMessageHandler; |
44 | 43 |
45 namespace { | 44 namespace { |
46 | 45 |
47 // May only be accessed on the UI thread | 46 // May only be accessed on the UI thread |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 delete value; | 283 delete value; |
285 } | 284 } |
286 } | 285 } |
287 | 286 |
288 // static | 287 // static |
289 void NetExportMessageHandler::SendEmail(const base::FilePath& file_to_send) { | 288 void NetExportMessageHandler::SendEmail(const base::FilePath& file_to_send) { |
290 if (file_to_send.empty()) | 289 if (file_to_send.empty()) |
291 return; | 290 return; |
292 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 291 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
293 | 292 |
294 #if BUILDFLAG(ANDROID_JAVA_UI) | 293 #if defined(OS_ANDROID) |
295 std::string email; | 294 std::string email; |
296 std::string subject = "net_internals_log"; | 295 std::string subject = "net_internals_log"; |
297 std::string title = "Issue number: "; | 296 std::string title = "Issue number: "; |
298 std::string body = | 297 std::string body = |
299 "Please add some informative text about the network issues."; | 298 "Please add some informative text about the network issues."; |
300 base::FilePath::StringType file_to_attach(file_to_send.value()); | 299 base::FilePath::StringType file_to_attach(file_to_send.value()); |
301 chrome::android::SendEmail( | 300 chrome::android::SendEmail( |
302 base::UTF8ToUTF16(email), base::UTF8ToUTF16(subject), | 301 base::UTF8ToUTF16(email), base::UTF8ToUTF16(subject), |
303 base::UTF8ToUTF16(body), base::UTF8ToUTF16(title), | 302 base::UTF8ToUTF16(body), base::UTF8ToUTF16(title), |
304 base::UTF8ToUTF16(file_to_attach)); | 303 base::UTF8ToUTF16(file_to_attach)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 366 |
368 } // namespace | 367 } // namespace |
369 | 368 |
370 NetExportUI::NetExportUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 369 NetExportUI::NetExportUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
371 web_ui->AddMessageHandler(base::MakeUnique<NetExportMessageHandler>()); | 370 web_ui->AddMessageHandler(base::MakeUnique<NetExportMessageHandler>()); |
372 | 371 |
373 // Set up the chrome://net-export/ source. | 372 // Set up the chrome://net-export/ source. |
374 Profile* profile = Profile::FromWebUI(web_ui); | 373 Profile* profile = Profile::FromWebUI(web_ui); |
375 content::WebUIDataSource::Add(profile, CreateNetExportHTMLSource()); | 374 content::WebUIDataSource::Add(profile, CreateNetExportHTMLSource()); |
376 } | 375 } |
OLD | NEW |