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

Side by Side Diff: chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc

Issue 2713013002: Track original URL when downloading a redirected page (Closed)
Patch Set: A little update Created 3 years, 10 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/offline/offline_internals_ui_message_handler.h " 5 #include "chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h "
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 save_page_requests.Append(save_page_request); 160 save_page_requests.Append(save_page_request);
161 save_page_request->SetString("onlineUrl", request->url().spec()); 161 save_page_request->SetString("onlineUrl", request->url().spec());
162 save_page_request->SetDouble("creationTime", 162 save_page_request->SetDouble("creationTime",
163 request->creation_time().ToJsTime()); 163 request->creation_time().ToJsTime());
164 save_page_request->SetString("status", GetStringFromSavePageStatus()); 164 save_page_request->SetString("status", GetStringFromSavePageStatus());
165 save_page_request->SetString("namespace", 165 save_page_request->SetString("namespace",
166 request->client_id().name_space); 166 request->client_id().name_space);
167 save_page_request->SetDouble("lastAttempt", 167 save_page_request->SetDouble("lastAttempt",
168 request->last_attempt_time().ToJsTime()); 168 request->last_attempt_time().ToJsTime());
169 save_page_request->SetString("id", std::to_string(request->request_id())); 169 save_page_request->SetString("id", std::to_string(request->request_id()));
170 save_page_request->SetString("originalUrl",
171 request->original_url().spec());
170 } 172 }
171 } 173 }
172 ResolveJavascriptCallback(base::StringValue(callback_id), save_page_requests); 174 ResolveJavascriptCallback(base::StringValue(callback_id), save_page_requests);
173 } 175 }
174 176
175 void OfflineInternalsUIMessageHandler::HandleGetRequestQueue( 177 void OfflineInternalsUIMessageHandler::HandleGetRequestQueue(
176 const base::ListValue* args) { 178 const base::ListValue* args) {
177 AllowJavascript(); 179 AllowJavascript();
178 std::string callback_id; 180 std::string callback_id;
179 CHECK(args->GetString(0, &callback_id)); 181 CHECK(args->GetString(0, &callback_id));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 277
276 if (request_coordinator_) { 278 if (request_coordinator_) {
277 std::string url; 279 std::string url;
278 CHECK(args->GetString(1, &url)); 280 CHECK(args->GetString(1, &url));
279 281
280 // To be visible in Downloads UI, these items need a well-formed GUID 282 // To be visible in Downloads UI, these items need a well-formed GUID
281 // and AsyncNamespace in their ClientId. 283 // and AsyncNamespace in their ClientId.
282 std::ostringstream id_stream; 284 std::ostringstream id_stream;
283 id_stream << base::GenerateGUID(); 285 id_stream << base::GenerateGUID();
284 286
287 offline_pages::RequestCoordinator::SavePageLaterParams params;
288 params.url = GURL(url);
289 params.client_id = offline_pages::ClientId(offline_pages::kAsyncNamespace,
290 id_stream.str());
291 params.user_requested = true;
fgorski 2017/02/27 17:34:36 availability?
jianli 2017/02/27 23:20:06 ditto.
285 ResolveJavascriptCallback( 292 ResolveJavascriptCallback(
286 *callback_id, 293 *callback_id, base::FundamentalValue(
287 base::FundamentalValue(request_coordinator_->SavePageLater( 294 request_coordinator_->SavePageLater(params) > 0));
288 GURL(url), offline_pages::ClientId(
289 offline_pages::kAsyncNamespace, id_stream.str()),
290 true, offline_pages::RequestCoordinator::RequestAvailability::
291 ENABLED_FOR_OFFLINER) > 0));
292 } else { 295 } else {
293 ResolveJavascriptCallback(*callback_id, base::FundamentalValue(false)); 296 ResolveJavascriptCallback(*callback_id, base::FundamentalValue(false));
294 } 297 }
295 } 298 }
296 299
297 void OfflineInternalsUIMessageHandler::RegisterMessages() { 300 void OfflineInternalsUIMessageHandler::RegisterMessages() {
298 web_ui()->RegisterMessageCallback( 301 web_ui()->RegisterMessageCallback(
299 "deleteSelectedPages", 302 "deleteSelectedPages",
300 base::Bind(&OfflineInternalsUIMessageHandler::HandleDeleteSelectedPages, 303 base::Bind(&OfflineInternalsUIMessageHandler::HandleDeleteSelectedPages,
301 weak_ptr_factory_.GetWeakPtr())); 304 weak_ptr_factory_.GetWeakPtr()));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 342
340 // Get the offline page model associated with this web ui. 343 // Get the offline page model associated with this web ui.
341 Profile* profile = Profile::FromWebUI(web_ui()); 344 Profile* profile = Profile::FromWebUI(web_ui());
342 offline_page_model_ = 345 offline_page_model_ =
343 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile); 346 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile);
344 request_coordinator_ = 347 request_coordinator_ =
345 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile); 348 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile);
346 } 349 }
347 350
348 } // namespace offline_internals 351 } // namespace offline_internals
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698