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

Unified Diff: chrome/browser/ui/webui/net_export_ui.cc

Issue 2857973003: Add a "Show File" button to chrome://net-export/ (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/net_export_ui.cc
diff --git a/chrome/browser/ui/webui/net_export_ui.cc b/chrome/browser/ui/webui/net_export_ui.cc
index 72db7cfe0301c26590fa5257a6a6c5f250181603..abc8b81a58464600c3ef950f34f9a5bc97f82e51 100644
--- a/chrome/browser/ui/webui/net_export_ui.cc
+++ b/chrome/browser/ui/webui/net_export_ui.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/net_export_helper.h"
+#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/common/url_constants.h"
@@ -114,6 +115,7 @@ class NetExportMessageHandler
void OnStartNetLog(const base::ListValue* list);
void OnStopNetLog(const base::ListValue* list);
void OnSendNetLog(const base::ListValue* list);
+ void OnShowFile(const base::ListValue* list);
// ui::SelectFileDialog::Listener implementation.
void FileSelected(const base::FilePath& path,
@@ -131,6 +133,9 @@ class NetExportMessageHandler
// Send NetLog data via email.
static void SendEmail(const base::FilePath& file_to_send);
+ // Reveal |path| in the shell on desktop platforms.
+ void ShowFileInShell(const base::FilePath& path);
+
// chrome://net-export can be used on both mobile and desktop platforms.
// On mobile a user cannot pick where their NetLog file is saved to.
// Instead, everything is saved on the user's temp directory. Thus the
@@ -212,6 +217,9 @@ void NetExportMessageHandler::RegisterMessages() {
net_log::kSendNetLogHandler,
base::Bind(&NetExportMessageHandler::OnSendNetLog,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ net_log::kShowFile,
+ base::Bind(&NetExportMessageHandler::OnShowFile, base::Unretained(this)));
}
// The net-export UI is not notified of state changes until this function runs.
@@ -281,6 +289,12 @@ void NetExportMessageHandler::OnSendNetLog(const base::ListValue* list) {
base::Bind(&NetExportMessageHandler::SendEmail));
}
+void NetExportMessageHandler::OnShowFile(const base::ListValue* list) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ file_writer_->GetFilePathToCompletedLog(
+ base::Bind(&NetExportMessageHandler::ShowFileInShell, AsWeakPtr()));
+}
+
void NetExportMessageHandler::FileSelected(const base::FilePath& path,
int index,
void* params) {
@@ -320,6 +334,17 @@ void NetExportMessageHandler::SendEmail(const base::FilePath& file_to_send) {
#endif
}
+void NetExportMessageHandler::ShowFileInShell(const base::FilePath& path) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ if (path.empty())
+ return;
+
+ // (The |profile| parameter is relevant for Chrome OS)
+ Profile* profile = Profile::FromWebUI(web_ui());
+
+ platform_util::ShowItemInFolder(profile, path);
+}
+
// static
bool NetExportMessageHandler::UsingMobileUI() {
#if defined(OS_ANDROID) || defined(OS_IOS)
« no previous file with comments | « no previous file | components/net_log/net_export_ui_constants.h » ('j') | components/net_log/resources/net_export.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698