Chromium Code Reviews| 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 02368823ba6b87b7cd24f16eb5ccd3530e4e6219..78bb02f8f575e5577476ae81fe1b231cc9d68196 100644 |
| --- a/chrome/browser/ui/webui/net_export_ui.cc |
| +++ b/chrome/browser/ui/webui/net_export_ui.cc |
| @@ -6,6 +6,7 @@ |
| #include <memory> |
| #include <string> |
| +#include <vector> |
| #include "base/bind.h" |
| #include "base/lazy_instance.h" |
| @@ -17,6 +18,7 @@ |
| #include "base/values.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/download/download_prefs.h" |
| +#include "chrome/browser/io_thread.h" |
| #include "chrome/browser/net/net_export_helper.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/chrome_select_file_policy.h" |
| @@ -26,11 +28,13 @@ |
| #include "components/net_log/net_export_ui_constants.h" |
| #include "components/net_log/net_log_file_writer.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/storage_partition.h" |
| #include "content/public/browser/url_data_source.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_ui.h" |
| #include "content/public/browser/web_ui_data_source.h" |
| #include "content/public/browser/web_ui_message_handler.h" |
| +#include "extensions/features/features.h" |
| #include "net/log/net_log_capture_mode.h" |
| #include "net/url_request/url_request_context_getter.h" |
| #include "ui/shell_dialogs/select_file_dialog.h" |
| @@ -98,6 +102,9 @@ class NetExportMessageHandler |
| void OnNewState(const base::DictionaryValue& state) override; |
| private: |
| + using URLRequestContextGetterList = |
| + std::vector<scoped_refptr<net::URLRequestContextGetter>>; |
| + |
| // Send NetLog data via email. |
| static void SendEmail(const base::FilePath& file_to_send); |
| @@ -136,6 +143,10 @@ class NetExportMessageHandler |
| scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
| + // Context getters from which ongoing events at logging start are retrieved |
| + // so they can be added to the net log. |
| + URLRequestContextGetterList context_getters_; |
| + |
| base::WeakPtrFactory<NetExportMessageHandler> weak_ptr_factory_; |
| DISALLOW_COPY_AND_ASSIGN(NetExportMessageHandler); |
| @@ -162,6 +173,20 @@ NetExportMessageHandler::~NetExportMessageHandler() { |
| void NetExportMessageHandler::RegisterMessages() { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + Profile* profile = Profile::FromWebUI(web_ui()); |
| + |
| + context_getters_.push_back(profile->GetRequestContext()); |
| + context_getters_.push_back( |
| + content::BrowserContext::GetDefaultStoragePartition(profile) |
| + ->GetMediaURLRequestContext()); |
| +#if BUILDFLAG(ENABLE_EXTENSIONS) |
| + context_getters_.push_back(profile->GetRequestContextForExtensions()); |
| +#endif |
| + context_getters_.push_back( |
| + g_browser_process->io_thread()->system_url_request_context_getter()); |
| + context_getters_.push_back( |
|
eroman
2017/02/21 22:14:23
Rather than adding a member variable initialized i
wangyix1
2017/02/22 01:28:18
Done.
|
| + g_browser_process->io_thread()->proxy_script_fetcher_context_getter()); |
| + |
| web_ui()->RegisterMessageCallback( |
| net_log::kEnableNotifyUIWithStateHandler, |
| base::Bind(&NetExportMessageHandler::OnEnableNotifyUIWithState, |
| @@ -202,7 +227,8 @@ void NetExportMessageHandler::OnStartNetLog(const base::ListValue* list) { |
| net_log::NetLogFileWriter::CaptureModeFromString(capture_mode_string); |
| if (UsingMobileUI()) { |
| - file_writer_->StartNetLog(base::FilePath(), capture_mode_); |
| + file_writer_->StartNetLog(base::FilePath(), capture_mode_, |
| + context_getters_); |
| } else { |
| base::FilePath initial_dir = last_save_dir.Pointer()->empty() ? |
| DownloadPrefs::FromBrowserContext( |
| @@ -254,7 +280,7 @@ void NetExportMessageHandler::FileSelected(const base::FilePath& path, |
| select_file_dialog_ = nullptr; |
| *last_save_dir.Pointer() = path.DirName(); |
| - file_writer_->StartNetLog(path, capture_mode_); |
| + file_writer_->StartNetLog(path, capture_mode_, context_getters_); |
| } |
| void NetExportMessageHandler::FileSelectionCanceled(void* params) { |