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

Side by Side Diff: third_party/WebKit/Source/web/WebFrameSerializer.cpp

Issue 2842653002: [Offline Pages] Generate MHTML header in the browser process. (Closed)
Patch Set: Update format string for gcc error. 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 WebFrameSerializerCacheControlPolicy::kFailForNoStoreMainFrame); 339 WebFrameSerializerCacheControlPolicy::kFailForNoStoreMainFrame);
340 340
341 if (!need_to_check_no_store) 341 if (!need_to_check_no_store)
342 return true; 342 return true;
343 343
344 return !CacheControlNoStoreHeaderPresent(*web_local_frame_impl); 344 return !CacheControlNoStoreHeaderPresent(*web_local_frame_impl);
345 } 345 }
346 346
347 } // namespace 347 } // namespace
348 348
349 WebThreadSafeData WebFrameSerializer::GenerateMHTMLHeader(
350 const WebString& boundary,
351 WebLocalFrame* frame,
352 MHTMLPartsGenerationDelegate* delegate) {
353 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLHeader");
354 DCHECK(frame);
355 DCHECK(delegate);
356
357 if (!FrameShouldBeSerializedAsMHTML(frame, delegate->CacheControlPolicy()))
358 return WebThreadSafeData();
359
360 WebLocalFrameImpl* web_local_frame_impl = ToWebLocalFrameImpl(frame);
361 DCHECK(web_local_frame_impl);
362
363 Document* document = web_local_frame_impl->GetFrame()->GetDocument();
364
365 RefPtr<RawData> buffer = RawData::Create();
366 MHTMLArchive::GenerateMHTMLHeader(boundary, document->title(),
367 document->SuggestedMIMEType(),
368 *buffer->MutableData());
369 return buffer.Release();
370 }
371
372 WebThreadSafeData WebFrameSerializer::GenerateMHTMLParts( 349 WebThreadSafeData WebFrameSerializer::GenerateMHTMLParts(
373 const WebString& boundary, 350 const WebString& boundary,
374 WebLocalFrame* web_frame, 351 WebLocalFrame* web_frame,
375 MHTMLPartsGenerationDelegate* web_delegate) { 352 MHTMLPartsGenerationDelegate* web_delegate) {
376 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLParts"); 353 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLParts");
377 DCHECK(web_frame); 354 DCHECK(web_frame);
378 DCHECK(web_delegate); 355 DCHECK(web_delegate);
379 356
380 if (!FrameShouldBeSerializedAsMHTML(web_frame, 357 if (!FrameShouldBeSerializedAsMHTML(web_frame,
381 web_delegate->CacheControlPolicy())) 358 web_delegate->CacheControlPolicy()))
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 const WebString& base_target) { 437 const WebString& base_target) {
461 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. 438 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|.
462 if (base_target.IsEmpty()) 439 if (base_target.IsEmpty())
463 return String("<base href=\".\">"); 440 return String("<base href=\".\">");
464 String base_string = "<base href=\".\" target=\"" + 441 String base_string = "<base href=\".\" target=\"" +
465 static_cast<const String&>(base_target) + "\">"; 442 static_cast<const String&>(base_target) + "\">";
466 return base_string; 443 return base_string;
467 } 444 }
468 445
469 } // namespace blink 446 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698