| OLD | NEW |
| 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 20 matching lines...) Expand all Loading... |
| 31 #include "public/web/WebFrameSerializer.h" | 31 #include "public/web/WebFrameSerializer.h" |
| 32 | 32 |
| 33 #include "core/HTMLNames.h" | 33 #include "core/HTMLNames.h" |
| 34 #include "core/InputTypeNames.h" | 34 #include "core/InputTypeNames.h" |
| 35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 36 #include "core/dom/Element.h" | 36 #include "core/dom/Element.h" |
| 37 #include "core/frame/Frame.h" | 37 #include "core/frame/Frame.h" |
| 38 #include "core/frame/FrameSerializer.h" | 38 #include "core/frame/FrameSerializer.h" |
| 39 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 40 #include "core/frame/RemoteFrame.h" | 40 #include "core/frame/RemoteFrame.h" |
| 41 #include "core/frame/WebLocalFrameBase.h" |
| 41 #include "core/html/HTMLAllCollection.h" | 42 #include "core/html/HTMLAllCollection.h" |
| 42 #include "core/html/HTMLFrameElementBase.h" | 43 #include "core/html/HTMLFrameElementBase.h" |
| 43 #include "core/html/HTMLFrameOwnerElement.h" | 44 #include "core/html/HTMLFrameOwnerElement.h" |
| 44 #include "core/html/HTMLImageElement.h" | 45 #include "core/html/HTMLImageElement.h" |
| 45 #include "core/html/HTMLInputElement.h" | 46 #include "core/html/HTMLInputElement.h" |
| 46 #include "core/html/HTMLTableElement.h" | 47 #include "core/html/HTMLTableElement.h" |
| 47 #include "core/layout/LayoutBox.h" | 48 #include "core/layout/LayoutBox.h" |
| 48 #include "core/loader/DocumentLoader.h" | 49 #include "core/loader/DocumentLoader.h" |
| 49 #include "platform/Histogram.h" | 50 #include "platform/Histogram.h" |
| 50 #include "platform/SerializedResource.h" | 51 #include "platform/SerializedResource.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 65 #include "public/platform/WebString.h" | 66 #include "public/platform/WebString.h" |
| 66 #include "public/platform/WebURL.h" | 67 #include "public/platform/WebURL.h" |
| 67 #include "public/platform/WebURLResponse.h" | 68 #include "public/platform/WebURLResponse.h" |
| 68 #include "public/platform/WebVector.h" | 69 #include "public/platform/WebVector.h" |
| 69 #include "public/web/WebDataSource.h" | 70 #include "public/web/WebDataSource.h" |
| 70 #include "public/web/WebDocument.h" | 71 #include "public/web/WebDocument.h" |
| 71 #include "public/web/WebFrame.h" | 72 #include "public/web/WebFrame.h" |
| 72 #include "public/web/WebFrameSerializerCacheControlPolicy.h" | 73 #include "public/web/WebFrameSerializerCacheControlPolicy.h" |
| 73 #include "public/web/WebFrameSerializerClient.h" | 74 #include "public/web/WebFrameSerializerClient.h" |
| 74 #include "web/WebFrameSerializerImpl.h" | 75 #include "web/WebFrameSerializerImpl.h" |
| 75 #include "web/WebLocalFrameImpl.h" | |
| 76 #include "web/WebRemoteFrameImpl.h" | 76 #include "web/WebRemoteFrameImpl.h" |
| 77 | 77 |
| 78 namespace blink { | 78 namespace blink { |
| 79 | 79 |
| 80 namespace { | 80 namespace { |
| 81 | 81 |
| 82 const int kPopupOverlayZIndexThreshold = 50; | 82 const int kPopupOverlayZIndexThreshold = 50; |
| 83 | 83 |
| 84 class MHTMLFrameSerializerDelegate final : public FrameSerializer::Delegate { | 84 class MHTMLFrameSerializerDelegate final : public FrameSerializer::Delegate { |
| 85 WTF_MAKE_NONCOPYABLE(MHTMLFrameSerializerDelegate); | 85 WTF_MAKE_NONCOPYABLE(MHTMLFrameSerializerDelegate); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 // Disable all form elements in MTHML to tell the user that the form cannot be | 323 // Disable all form elements in MTHML to tell the user that the form cannot be |
| 324 // worked on. MHTML is loaded in full sandboxing mode which disable the form | 324 // worked on. MHTML is loaded in full sandboxing mode which disable the form |
| 325 // submission and script execution. | 325 // submission and script execution. |
| 326 if (element.FastHasAttribute(HTMLNames::disabledAttr)) | 326 if (element.FastHasAttribute(HTMLNames::disabledAttr)) |
| 327 return; | 327 return; |
| 328 Attribute disabled_attribute(HTMLNames::disabledAttr, ""); | 328 Attribute disabled_attribute(HTMLNames::disabledAttr, ""); |
| 329 attributes->push_back(disabled_attribute); | 329 attributes->push_back(disabled_attribute); |
| 330 } | 330 } |
| 331 | 331 |
| 332 bool CacheControlNoStoreHeaderPresent( | 332 bool CacheControlNoStoreHeaderPresent( |
| 333 const WebLocalFrameImpl& web_local_frame_impl) { | 333 const WebLocalFrameBase& web_local_frame) { |
| 334 const ResourceResponse& response = | 334 const ResourceResponse& response = |
| 335 web_local_frame_impl.DataSource()->GetResponse().ToResourceResponse(); | 335 web_local_frame.DataSource()->GetResponse().ToResourceResponse(); |
| 336 if (response.CacheControlContainsNoStore()) | 336 if (response.CacheControlContainsNoStore()) |
| 337 return true; | 337 return true; |
| 338 | 338 |
| 339 const ResourceRequest& request = | 339 const ResourceRequest& request = |
| 340 web_local_frame_impl.DataSource()->GetRequest().ToResourceRequest(); | 340 web_local_frame.DataSource()->GetRequest().ToResourceRequest(); |
| 341 return request.CacheControlContainsNoStore(); | 341 return request.CacheControlContainsNoStore(); |
| 342 } | 342 } |
| 343 | 343 |
| 344 bool FrameShouldBeSerializedAsMHTML( | 344 bool FrameShouldBeSerializedAsMHTML( |
| 345 WebLocalFrame* frame, | 345 WebLocalFrame* frame, |
| 346 WebFrameSerializerCacheControlPolicy cache_control_policy) { | 346 WebFrameSerializerCacheControlPolicy cache_control_policy) { |
| 347 WebLocalFrameImpl* web_local_frame_impl = ToWebLocalFrameImpl(frame); | 347 WebLocalFrameBase* web_local_frame = ToWebLocalFrameBase(frame); |
| 348 DCHECK(web_local_frame_impl); | 348 DCHECK(web_local_frame); |
| 349 | 349 |
| 350 if (cache_control_policy == WebFrameSerializerCacheControlPolicy::kNone) | 350 if (cache_control_policy == WebFrameSerializerCacheControlPolicy::kNone) |
| 351 return true; | 351 return true; |
| 352 | 352 |
| 353 bool need_to_check_no_store = | 353 bool need_to_check_no_store = |
| 354 cache_control_policy == WebFrameSerializerCacheControlPolicy:: | 354 cache_control_policy == WebFrameSerializerCacheControlPolicy:: |
| 355 kSkipAnyFrameOrResourceMarkedNoStore || | 355 kSkipAnyFrameOrResourceMarkedNoStore || |
| 356 (!frame->Parent() && | 356 (!frame->Parent() && |
| 357 cache_control_policy == | 357 cache_control_policy == |
| 358 WebFrameSerializerCacheControlPolicy::kFailForNoStoreMainFrame); | 358 WebFrameSerializerCacheControlPolicy::kFailForNoStoreMainFrame); |
| 359 | 359 |
| 360 if (!need_to_check_no_store) | 360 if (!need_to_check_no_store) |
| 361 return true; | 361 return true; |
| 362 | 362 |
| 363 return !CacheControlNoStoreHeaderPresent(*web_local_frame_impl); | 363 return !CacheControlNoStoreHeaderPresent(*web_local_frame); |
| 364 } | 364 } |
| 365 | 365 |
| 366 } // namespace | 366 } // namespace |
| 367 | 367 |
| 368 WebThreadSafeData WebFrameSerializer::GenerateMHTMLHeader( | 368 WebThreadSafeData WebFrameSerializer::GenerateMHTMLHeader( |
| 369 const WebString& boundary, | 369 const WebString& boundary, |
| 370 WebLocalFrame* frame, | 370 WebLocalFrame* frame, |
| 371 MHTMLPartsGenerationDelegate* delegate) { | 371 MHTMLPartsGenerationDelegate* delegate) { |
| 372 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLHeader"); | 372 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLHeader"); |
| 373 DCHECK(frame); | 373 DCHECK(frame); |
| 374 DCHECK(delegate); | 374 DCHECK(delegate); |
| 375 | 375 |
| 376 if (!FrameShouldBeSerializedAsMHTML(frame, delegate->CacheControlPolicy())) | 376 if (!FrameShouldBeSerializedAsMHTML(frame, delegate->CacheControlPolicy())) |
| 377 return WebThreadSafeData(); | 377 return WebThreadSafeData(); |
| 378 | 378 |
| 379 WebLocalFrameImpl* web_local_frame_impl = ToWebLocalFrameImpl(frame); | 379 WebLocalFrameBase* web_local_frame = ToWebLocalFrameBase(frame); |
| 380 DCHECK(web_local_frame_impl); | 380 DCHECK(web_local_frame); |
| 381 | 381 |
| 382 Document* document = web_local_frame_impl->GetFrame()->GetDocument(); | 382 Document* document = web_local_frame->GetFrame()->GetDocument(); |
| 383 | 383 |
| 384 RefPtr<RawData> buffer = RawData::Create(); | 384 RefPtr<RawData> buffer = RawData::Create(); |
| 385 MHTMLArchive::GenerateMHTMLHeader(boundary, document->title(), | 385 MHTMLArchive::GenerateMHTMLHeader(boundary, document->title(), |
| 386 document->SuggestedMIMEType(), | 386 document->SuggestedMIMEType(), |
| 387 *buffer->MutableData()); | 387 *buffer->MutableData()); |
| 388 return buffer.Release(); | 388 return buffer.Release(); |
| 389 } | 389 } |
| 390 | 390 |
| 391 WebThreadSafeData WebFrameSerializer::GenerateMHTMLParts( | 391 WebThreadSafeData WebFrameSerializer::GenerateMHTMLParts( |
| 392 const WebString& boundary, | 392 const WebString& boundary, |
| 393 WebLocalFrame* web_frame, | 393 WebLocalFrame* web_frame, |
| 394 MHTMLPartsGenerationDelegate* web_delegate) { | 394 MHTMLPartsGenerationDelegate* web_delegate) { |
| 395 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLParts"); | 395 TRACE_EVENT0("page-serialization", "WebFrameSerializer::generateMHTMLParts"); |
| 396 DCHECK(web_frame); | 396 DCHECK(web_frame); |
| 397 DCHECK(web_delegate); | 397 DCHECK(web_delegate); |
| 398 | 398 |
| 399 if (!FrameShouldBeSerializedAsMHTML(web_frame, | 399 if (!FrameShouldBeSerializedAsMHTML(web_frame, |
| 400 web_delegate->CacheControlPolicy())) | 400 web_delegate->CacheControlPolicy())) |
| 401 return WebThreadSafeData(); | 401 return WebThreadSafeData(); |
| 402 | 402 |
| 403 // Translate arguments from public to internal blink APIs. | 403 // Translate arguments from public to internal blink APIs. |
| 404 LocalFrame* frame = ToWebLocalFrameImpl(web_frame)->GetFrame(); | 404 LocalFrame* frame = ToWebLocalFrameBase(web_frame)->GetFrame(); |
| 405 MHTMLArchive::EncodingPolicy encoding_policy = | 405 MHTMLArchive::EncodingPolicy encoding_policy = |
| 406 web_delegate->UseBinaryEncoding() | 406 web_delegate->UseBinaryEncoding() |
| 407 ? MHTMLArchive::EncodingPolicy::kUseBinaryEncoding | 407 ? MHTMLArchive::EncodingPolicy::kUseBinaryEncoding |
| 408 : MHTMLArchive::EncodingPolicy::kUseDefaultEncoding; | 408 : MHTMLArchive::EncodingPolicy::kUseDefaultEncoding; |
| 409 | 409 |
| 410 // Serialize. | 410 // Serialize. |
| 411 TRACE_EVENT_BEGIN0("page-serialization", | 411 TRACE_EVENT_BEGIN0("page-serialization", |
| 412 "WebFrameSerializer::generateMHTMLParts serializing"); | 412 "WebFrameSerializer::generateMHTMLParts serializing"); |
| 413 Deque<SerializedResource> resources; | 413 Deque<SerializedResource> resources; |
| 414 { | 414 { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 const WebString& base_target) { | 479 const WebString& base_target) { |
| 480 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. | 480 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. |
| 481 if (base_target.IsEmpty()) | 481 if (base_target.IsEmpty()) |
| 482 return String("<base href=\".\">"); | 482 return String("<base href=\".\">"); |
| 483 String base_string = "<base href=\".\" target=\"" + | 483 String base_string = "<base href=\".\" target=\"" + |
| 484 static_cast<const String&>(base_target) + "\">"; | 484 static_cast<const String&>(base_target) + "\">"; |
| 485 return base_string; | 485 return base_string; |
| 486 } | 486 } |
| 487 | 487 |
| 488 } // namespace blink | 488 } // namespace blink |
| OLD | NEW |