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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
17 #include "components/grit/components_resources.h" | 17 #include "components/grit/components_resources.h" |
18 #include "components/net_log/chrome_net_log.h" | 18 #include "components/net_log/chrome_net_log.h" |
19 #include "components/net_log/net_export_ui_constants.h" | 19 #include "components/net_log/net_export_ui_constants.h" |
20 #include "components/net_log/net_log_temp_file.h" | 20 #include "components/net_log/net_log_temp_file.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/url_data_source.h" | 22 #include "content/public/browser/url_data_source.h" |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
24 #include "content/public/browser/web_ui.h" | 24 #include "content/public/browser/web_ui.h" |
25 #include "content/public/browser/web_ui_data_source.h" | 25 #include "content/public/browser/web_ui_data_source.h" |
26 #include "content/public/browser/web_ui_message_handler.h" | 26 #include "content/public/browser/web_ui_message_handler.h" |
27 | 27 |
28 #if defined(OS_ANDROID) | 28 #if defined(ANDROID_JAVA_UI) |
29 #include "chrome/browser/android/intent_helper.h" | 29 #include "chrome/browser/android/intent_helper.h" |
30 #endif | 30 #endif |
31 | 31 |
32 using content::BrowserThread; | 32 using content::BrowserThread; |
33 using content::WebContents; | 33 using content::WebContents; |
34 using content::WebUIMessageHandler; | 34 using content::WebUIMessageHandler; |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 content::WebUIDataSource* CreateNetExportHTMLSource() { | 38 content::WebUIDataSource* CreateNetExportHTMLSource() { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 delete value; | 218 delete value; |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 // static | 222 // static |
223 void NetExportMessageHandler::SendEmail(const base::FilePath& file_to_send) { | 223 void NetExportMessageHandler::SendEmail(const base::FilePath& file_to_send) { |
224 if (file_to_send.empty()) | 224 if (file_to_send.empty()) |
225 return; | 225 return; |
226 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 226 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
227 | 227 |
228 #if defined(OS_ANDROID) | 228 #if defined(ANDROID_JAVA_UI) |
229 std::string email; | 229 std::string email; |
230 std::string subject = "net_internals_log"; | 230 std::string subject = "net_internals_log"; |
231 std::string title = "Issue number: "; | 231 std::string title = "Issue number: "; |
232 std::string body = | 232 std::string body = |
233 "Please add some informative text about the network issues."; | 233 "Please add some informative text about the network issues."; |
234 base::FilePath::StringType file_to_attach(file_to_send.value()); | 234 base::FilePath::StringType file_to_attach(file_to_send.value()); |
235 chrome::android::SendEmail( | 235 chrome::android::SendEmail( |
236 base::UTF8ToUTF16(email), base::UTF8ToUTF16(subject), | 236 base::UTF8ToUTF16(email), base::UTF8ToUTF16(subject), |
237 base::UTF8ToUTF16(body), base::UTF8ToUTF16(title), | 237 base::UTF8ToUTF16(body), base::UTF8ToUTF16(title), |
238 base::UTF8ToUTF16(file_to_attach)); | 238 base::UTF8ToUTF16(file_to_attach)); |
239 #endif | 239 #endif |
240 } | 240 } |
241 | 241 |
242 void NetExportMessageHandler::OnExportNetLogInfoChanged(base::Value* arg) { | 242 void NetExportMessageHandler::OnExportNetLogInfoChanged(base::Value* arg) { |
243 scoped_ptr<base::Value> value(arg); | 243 scoped_ptr<base::Value> value(arg); |
244 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 244 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
245 web_ui()->CallJavascriptFunction(net_log::kOnExportNetLogInfoChanged, *arg); | 245 web_ui()->CallJavascriptFunction(net_log::kOnExportNetLogInfoChanged, *arg); |
246 } | 246 } |
247 | 247 |
248 } // namespace | 248 } // namespace |
249 | 249 |
250 NetExportUI::NetExportUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 250 NetExportUI::NetExportUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
251 web_ui->AddMessageHandler(new NetExportMessageHandler()); | 251 web_ui->AddMessageHandler(new NetExportMessageHandler()); |
252 | 252 |
253 // Set up the chrome://net-export/ source. | 253 // Set up the chrome://net-export/ source. |
254 Profile* profile = Profile::FromWebUI(web_ui); | 254 Profile* profile = Profile::FromWebUI(web_ui); |
255 content::WebUIDataSource::Add(profile, CreateNetExportHTMLSource()); | 255 content::WebUIDataSource::Add(profile, CreateNetExportHTMLSource()); |
256 } | 256 } |
OLD | NEW |