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