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

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

Issue 1361923005: Move net-export resources to //components/net_log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « chrome/browser/resources/net_export/net_export.js ('k') | components/net_log.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "components/grit/components_resources.h"
17 #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"
18 #include "components/net_log/net_log_temp_file.h" 20 #include "components/net_log/net_log_temp_file.h"
19 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/url_data_source.h" 22 #include "content/public/browser/url_data_source.h"
21 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
22 #include "content/public/browser/web_ui.h" 24 #include "content/public/browser/web_ui.h"
23 #include "content/public/browser/web_ui_data_source.h" 25 #include "content/public/browser/web_ui_data_source.h"
24 #include "content/public/browser/web_ui_message_handler.h" 26 #include "content/public/browser/web_ui_message_handler.h"
25 #include "grit/browser_resources.h"
26 27
27 #if defined(OS_ANDROID) 28 #if defined(OS_ANDROID)
28 #include "chrome/browser/android/intent_helper.h" 29 #include "chrome/browser/android/intent_helper.h"
29 #endif 30 #endif
30 31
31 using content::BrowserThread; 32 using content::BrowserThread;
32 using content::WebContents; 33 using content::WebContents;
33 using content::WebUIMessageHandler; 34 using content::WebUIMessageHandler;
34 35
35 namespace { 36 namespace {
36 37
37 content::WebUIDataSource* CreateNetExportHTMLSource() { 38 content::WebUIDataSource* CreateNetExportHTMLSource() {
38 content::WebUIDataSource* source = 39 content::WebUIDataSource* source =
39 content::WebUIDataSource::Create(chrome::kChromeUINetExportHost); 40 content::WebUIDataSource::Create(chrome::kChromeUINetExportHost);
40 41
41 source->SetJsonPath("strings.js"); 42 source->SetJsonPath("strings.js");
42 source->AddResourcePath("net_export.js", IDR_NET_EXPORT_JS); 43 source->AddResourcePath(net_log::kNetExportUIJS, IDR_NET_LOG_NET_EXPORT_JS);
43 source->SetDefaultResource(IDR_NET_EXPORT_HTML); 44 source->SetDefaultResource(IDR_NET_LOG_NET_EXPORT_HTML);
44 return source; 45 return source;
45 } 46 }
46 47
47 // This class receives javascript messages from the renderer. 48 // This class receives javascript messages from the renderer.
48 // Note that the WebUI infrastructure runs on the UI thread, therefore all of 49 // Note that the WebUI infrastructure runs on the UI thread, therefore all of
49 // this class's public methods are expected to run on the UI thread. All static 50 // this class's public methods are expected to run on the UI thread. All static
50 // functions except SendEmail run on FILE_USER_BLOCKING thread. 51 // functions except SendEmail run on FILE_USER_BLOCKING thread.
51 class NetExportMessageHandler 52 class NetExportMessageHandler
52 : public WebUIMessageHandler, 53 : public WebUIMessageHandler,
53 public base::SupportsWeakPtr<NetExportMessageHandler> { 54 public base::SupportsWeakPtr<NetExportMessageHandler> {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 BrowserThread::PostTask(BrowserThread::FILE_USER_BLOCKING, FROM_HERE, 106 BrowserThread::PostTask(BrowserThread::FILE_USER_BLOCKING, FROM_HERE,
106 base::Bind(&net_log::NetLogTempFile::ProcessCommand, 107 base::Bind(&net_log::NetLogTempFile::ProcessCommand,
107 base::Unretained(net_log_temp_file_), 108 base::Unretained(net_log_temp_file_),
108 net_log::NetLogTempFile::DO_STOP)); 109 net_log::NetLogTempFile::DO_STOP));
109 } 110 }
110 111
111 void NetExportMessageHandler::RegisterMessages() { 112 void NetExportMessageHandler::RegisterMessages() {
112 DCHECK_CURRENTLY_ON(BrowserThread::UI); 113 DCHECK_CURRENTLY_ON(BrowserThread::UI);
113 114
114 web_ui()->RegisterMessageCallback( 115 web_ui()->RegisterMessageCallback(
115 "getExportNetLogInfo", 116 net_log::kGetExportNetLogInfoHandler,
116 base::Bind(&NetExportMessageHandler::OnGetExportNetLogInfo, 117 base::Bind(&NetExportMessageHandler::OnGetExportNetLogInfo,
117 base::Unretained(this))); 118 base::Unretained(this)));
118 web_ui()->RegisterMessageCallback( 119 web_ui()->RegisterMessageCallback(
119 "startNetLog", 120 net_log::kStartNetLogHandler,
120 base::Bind(&NetExportMessageHandler::OnStartNetLog, 121 base::Bind(&NetExportMessageHandler::OnStartNetLog,
121 base::Unretained(this))); 122 base::Unretained(this)));
122 web_ui()->RegisterMessageCallback( 123 web_ui()->RegisterMessageCallback(
123 "stopNetLog", 124 net_log::kStopNetLogHandler,
124 base::Bind(&NetExportMessageHandler::OnStopNetLog, 125 base::Bind(&NetExportMessageHandler::OnStopNetLog,
125 base::Unretained(this))); 126 base::Unretained(this)));
126 web_ui()->RegisterMessageCallback( 127 web_ui()->RegisterMessageCallback(
127 "sendNetLog", 128 net_log::kSendNetLogHandler,
128 base::Bind(&NetExportMessageHandler::OnSendNetLog, 129 base::Bind(&NetExportMessageHandler::OnSendNetLog,
129 base::Unretained(this))); 130 base::Unretained(this)));
130 } 131 }
131 132
132 void NetExportMessageHandler::OnGetExportNetLogInfo( 133 void NetExportMessageHandler::OnGetExportNetLogInfo(
133 const base::ListValue* list) { 134 const base::ListValue* list) {
134 BrowserThread::PostTask( 135 BrowserThread::PostTask(
135 BrowserThread::FILE_USER_BLOCKING, 136 BrowserThread::FILE_USER_BLOCKING,
136 FROM_HERE, 137 FROM_HERE,
137 base::Bind(&NetExportMessageHandler::SendExportNetLogInfo, 138 base::Bind(&NetExportMessageHandler::SendExportNetLogInfo,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 chrome::android::SendEmail( 235 chrome::android::SendEmail(
235 base::UTF8ToUTF16(email), base::UTF8ToUTF16(subject), 236 base::UTF8ToUTF16(email), base::UTF8ToUTF16(subject),
236 base::UTF8ToUTF16(body), base::UTF8ToUTF16(title), 237 base::UTF8ToUTF16(body), base::UTF8ToUTF16(title),
237 base::UTF8ToUTF16(file_to_attach)); 238 base::UTF8ToUTF16(file_to_attach));
238 #endif 239 #endif
239 } 240 }
240 241
241 void NetExportMessageHandler::OnExportNetLogInfoChanged(base::Value* arg) { 242 void NetExportMessageHandler::OnExportNetLogInfoChanged(base::Value* arg) {
242 scoped_ptr<base::Value> value(arg); 243 scoped_ptr<base::Value> value(arg);
243 DCHECK_CURRENTLY_ON(BrowserThread::UI); 244 DCHECK_CURRENTLY_ON(BrowserThread::UI);
244 web_ui()->CallJavascriptFunction( 245 web_ui()->CallJavascriptFunction(net_log::kOnExportNetLogInfoChanged, *arg);
245 "NetExportView.getInstance().onExportNetLogInfoChanged", *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 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/net_export/net_export.js ('k') | components/net_log.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698