OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // How we handle the base tag better. | 5 // How we handle the base tag better. |
6 // Current status: | 6 // Current status: |
7 // At now the normal way we use to handling base tag is | 7 // At now the normal way we use to handling base tag is |
8 // a) For those links which have corresponding local saved files, such as | 8 // a) For those links which have corresponding local saved files, such as |
9 // savable CSS, JavaScript files, they will be written to relative URLs which | 9 // savable CSS, JavaScript files, they will be written to relative URLs which |
10 // point to local saved file. Why those links can not be resolved as absolute | 10 // point to local saved file. Why those links can not be resolved as absolute |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 // For links start with "javascript:", we do not change it. | 373 // For links start with "javascript:", we do not change it. |
374 if (attr_value.startsWith("javascript:", false)) { | 374 if (attr_value.startsWith("javascript:", false)) { |
375 result += attr_value; | 375 result += attr_value; |
376 } else { | 376 } else { |
377 WebCore::String str_value = param->doc->completeURL(attr_value); | 377 WebCore::String str_value = param->doc->completeURL(attr_value); |
378 std::string value(StringToStdString(str_value)); | 378 std::string value(StringToStdString(str_value)); |
379 // Check whether we local files for those link. | 379 // Check whether we local files for those link. |
380 LinkLocalPathMap::const_iterator it = local_links_.find(value); | 380 LinkLocalPathMap::const_iterator it = local_links_.find(value); |
381 if (it != local_links_.end()) { | 381 if (it != local_links_.end()) { |
382 // Replace the link when we have local files. | 382 // Replace the link when we have local files. |
383 result += FilePathStringToString(param->directory_name.value()); | 383 FilePath::StringType path(FilePath::kCurrentDirectory); |
384 result += FilePathStringToString(it->second.value()); | 384 if (!param->directory_name.empty()) |
| 385 path += FILE_PATH_LITERAL("/") + param->directory_name.value(); |
| 386 path += FILE_PATH_LITERAL("/") + it->second.value(); |
| 387 result += FilePathStringToString(path); |
385 } else { | 388 } else { |
386 // If not found local path, replace it with absolute link. | 389 // If not found local path, replace it with absolute link. |
387 result += str_value; | 390 result += str_value; |
388 } | 391 } |
389 } | 392 } |
390 } else { | 393 } else { |
391 ConvertCorrespondingSymbolToEntity(&result, attribute->value(), | 394 ConvertCorrespondingSymbolToEntity(&result, attribute->value(), |
392 param->is_html_document); | 395 param->is_html_document); |
393 } | 396 } |
394 } | 397 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 WebCore::String encoding = current_frame->frame()->loader()->encoding(); | 573 WebCore::String encoding = current_frame->frame()->loader()->encoding(); |
571 // Create the text encoding object with target encoding. | 574 // Create the text encoding object with target encoding. |
572 WebCore::TextEncoding text_encoding(encoding); | 575 WebCore::TextEncoding text_encoding(encoding); |
573 // Construct serialize parameter for late processing document. | 576 // Construct serialize parameter for late processing document. |
574 SerializeDomParam param( | 577 SerializeDomParam param( |
575 current_frame_gurl, | 578 current_frame_gurl, |
576 encoding.length() ? text_encoding : WebCore::UTF8Encoding(), | 579 encoding.length() ? text_encoding : WebCore::UTF8Encoding(), |
577 current_doc, | 580 current_doc, |
578 current_frame_gurl == main_page_gurl ? | 581 current_frame_gurl == main_page_gurl ? |
579 local_directory_name_ : | 582 local_directory_name_ : |
580 FilePath(FilePath::kCurrentDirectory)); | 583 FilePath()); |
581 | 584 |
582 // Process current document. | 585 // Process current document. |
583 WebCore::Element* root_element = current_doc->documentElement(); | 586 WebCore::Element* root_element = current_doc->documentElement(); |
584 if (root_element) | 587 if (root_element) |
585 BuildContentForNode(root_element, ¶m); | 588 BuildContentForNode(root_element, ¶m); |
586 | 589 |
587 // Sink the remainder data and finish serializing current frame. | 590 // Sink the remainder data and finish serializing current frame. |
588 delegate_->DidSerializeDataForFrame(current_frame_gurl, data_buffer_, | 591 delegate_->DidSerializeDataForFrame(current_frame_gurl, data_buffer_, |
589 DomSerializerDelegate::CURRENT_FRAME_IS_FINISHED); | 592 DomSerializerDelegate::CURRENT_FRAME_IS_FINISHED); |
590 // Clear the buffer. | 593 // Clear the buffer. |
591 data_buffer_.clear(); | 594 data_buffer_.clear(); |
592 } | 595 } |
593 } | 596 } |
594 | 597 |
595 // We have done call frames, so we send message to embedder to tell it that | 598 // We have done call frames, so we send message to embedder to tell it that |
596 // frames are finished serializing. | 599 // frames are finished serializing. |
597 DCHECK(data_buffer_.empty()); | 600 DCHECK(data_buffer_.empty()); |
598 delegate_->DidSerializeDataForFrame(GURL(), data_buffer_, | 601 delegate_->DidSerializeDataForFrame(GURL(), data_buffer_, |
599 DomSerializerDelegate::ALL_FRAMES_ARE_FINISHED); | 602 DomSerializerDelegate::ALL_FRAMES_ARE_FINISHED); |
600 | 603 |
601 return did_serialization; | 604 return did_serialization; |
602 } | 605 } |
603 | 606 |
604 } // namespace webkit_glue | 607 } // namespace webkit_glue |
605 | 608 |
OLD | NEW |