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

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

Issue 2246563002: [Offline Pages]Allow multiple urls to be requested in internal page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/offline_internals_ui.cc
diff --git a/chrome/browser/ui/webui/offline_internals_ui.cc b/chrome/browser/ui/webui/offline_internals_ui.cc
index 08c49c4420b82efe1dfb2f57ccfc46cc09f9b6d7..68cc0d18f2fb116a2cbf2ed32d8c733e92520faf 100644
--- a/chrome/browser/ui/webui/offline_internals_ui.cc
+++ b/chrome/browser/ui/webui/offline_internals_ui.cc
@@ -6,6 +6,8 @@
#include <stdint.h>
#include <stdlib.h>
+#include <sstream>
michaelpg 2016/08/14 21:31:20 alphabetize
romax 2016/08/19 18:53:35 removed c++ changes and moved to JS side.
+#include <string>
#include <vector>
#include "base/bind.h"
@@ -319,22 +321,31 @@ void OfflineInternalsUIMessageHandler::HandleAddToRequestQueue(
const base::Value* callback_id;
CHECK(args->Get(0, &callback_id));
- std::string url;
- CHECK(args->GetString(1, &url));
+ std::string request_urls;
+ CHECK(args->GetString(1, &request_urls));
// To be visible in Downloads UI, these items need a well-formed GUID
// and AsyncNamespace in their ClientId.
std::ostringstream id_stream;
id_stream << base::GenerateGUID();
- ResolveJavascriptCallback(
- *callback_id,
- base::FundamentalValue(
- request_coordinator_->SavePageLater(
- GURL(url),
- offline_pages::ClientId(offline_pages::kAsyncNamespace,
- id_stream.str()),
- true)));
+ std::vector<std::string> url_list;
+ std::stringstream ss(request_urls);
michaelpg 2016/08/14 21:31:19 istringstream?
romax 2016/08/19 18:53:35 Done.
+ std::string url;
+ while (getline(ss, url, ',') && (!url.empty())) {
michaelpg 2016/08/14 21:31:20 nit: parens not needed around !url.empty()
romax 2016/08/19 18:53:35 Done.
+ url_list.push_back(url);
+ }
+
+ for (auto url : url_list) {
+ ResolveJavascriptCallback(
michaelpg 2016/08/14 21:31:20 it doesn't make sense to repeatedly "resolve" a pr
chili 2016/08/15 18:27:08 +1. I believe ResolveJavascriptCallback might als
romax 2016/08/19 18:53:35 I think i'm going with parsing the urls in JS side
+ *callback_id,
+ base::FundamentalValue(
+ request_coordinator_->SavePageLater(
+ GURL(url),
+ offline_pages::ClientId(offline_pages::kAsyncNamespace,
+ id_stream.str()),
+ true)));
+ }
}
void OfflineInternalsUIMessageHandler::RegisterMessages() {

Powered by Google App Engine
This is Rietveld 408576698