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

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

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

Powered by Google App Engine
This is Rietveld 408576698