OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 #include "base/message_loop.h" | 128 #include "base/message_loop.h" |
129 #include "base/stats_counters.h" | 129 #include "base/stats_counters.h" |
130 #include "base/string_util.h" | 130 #include "base/string_util.h" |
131 #include "base/time.h" | 131 #include "base/time.h" |
132 #include "net/base/net_errors.h" | 132 #include "net/base/net_errors.h" |
133 #include "skia/ext/bitmap_platform_device.h" | 133 #include "skia/ext/bitmap_platform_device.h" |
134 #include "skia/ext/platform_canvas.h" | 134 #include "skia/ext/platform_canvas.h" |
135 #include "webkit/glue/alt_error_page_resource_fetcher.h" | 135 #include "webkit/glue/alt_error_page_resource_fetcher.h" |
136 #include "webkit/glue/dom_operations.h" | 136 #include "webkit/glue/dom_operations.h" |
137 #include "webkit/glue/dom_operations_private.h" | 137 #include "webkit/glue/dom_operations_private.h" |
| 138 #include "webkit/glue/feed.h" |
138 #include "webkit/glue/glue_serialize.h" | 139 #include "webkit/glue/glue_serialize.h" |
139 #include "webkit/glue/glue_util.h" | 140 #include "webkit/glue/glue_util.h" |
140 #include "webkit/glue/webdatasource_impl.h" | 141 #include "webkit/glue/webdatasource_impl.h" |
141 #include "webkit/glue/weberror_impl.h" | 142 #include "webkit/glue/weberror_impl.h" |
142 #include "webkit/glue/webframe_impl.h" | 143 #include "webkit/glue/webframe_impl.h" |
143 #include "webkit/glue/webhistoryitem_impl.h" | 144 #include "webkit/glue/webhistoryitem_impl.h" |
144 #include "webkit/glue/weburlrequest_impl.h" | 145 #include "webkit/glue/weburlrequest_impl.h" |
145 #include "webkit/glue/webtextinput_impl.h" | 146 #include "webkit/glue/webtextinput_impl.h" |
146 #include "webkit/glue/webview_impl.h" | 147 #include "webkit/glue/webview_impl.h" |
147 | 148 |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 if (link_element && link_element->type() == kOSDType && | 479 if (link_element && link_element->type() == kOSDType && |
479 link_element->rel() == kOSDRel && !link_element->href().isEmpty()) { | 480 link_element->rel() == kOSDRel && !link_element->href().isEmpty()) { |
480 return webkit_glue::KURLToGURL(link_element->href()); | 481 return webkit_glue::KURLToGURL(link_element->href()); |
481 } | 482 } |
482 } | 483 } |
483 } | 484 } |
484 } | 485 } |
485 return GURL(); | 486 return GURL(); |
486 } | 487 } |
487 | 488 |
| 489 scoped_refptr<FeedList> WebFrameImpl::GetFeedList() const { |
| 490 scoped_refptr<FeedList> feedlist = new FeedList(); |
| 491 |
| 492 WebCore::FrameLoader* frame_loader = frame_->loader(); |
| 493 if (frame_loader->state() != WebCore::FrameStateComplete || |
| 494 !frame_->document() || |
| 495 !frame_->document()->head() || |
| 496 frame_->tree()->parent()) |
| 497 return feedlist; |
| 498 |
| 499 // We only consider HTML documents with <head> tags. |
| 500 // (Interestingly, isHTMLDocument() returns false for some pages -- |
| 501 // perhaps an XHTML thing? It doesn't really matter because head() is |
| 502 // a method on Documents anyway.) |
| 503 WebCore::HTMLHeadElement* head = frame_->document()->head(); |
| 504 if (!head) |
| 505 return feedlist; |
| 506 |
| 507 // Iterate through all children of the <head>, looking for feed links. |
| 508 for (WebCore::Node* node = head->firstChild(); |
| 509 node; node = node->nextSibling()) { |
| 510 // Skip over all nodes except <link ...>. |
| 511 if (!node->isHTMLElement()) |
| 512 continue; |
| 513 if (!static_cast<WebCore::Element*>(node)->hasLocalName("link")) |
| 514 continue; |
| 515 |
| 516 const WebCore::HTMLLinkElement* link = |
| 517 static_cast<WebCore::HTMLLinkElement*>(node); |
| 518 |
| 519 // Look at the 'rel' tag and see if we have a feed. |
| 520 std::wstring rel = webkit_glue::StringToStdWString(link->rel()); |
| 521 bool is_feed = false; |
| 522 if (LowerCaseEqualsASCII(rel, "feed") || |
| 523 LowerCaseEqualsASCII(rel, "feed alternate")) { |
| 524 // rel="feed" or rel="alternate feed" always means this is a feed. |
| 525 is_feed = true; |
| 526 } else if (LowerCaseEqualsASCII(rel, "alternate")) { |
| 527 // Otherwise, rel="alternate" may mean a feed if it has a certain mime |
| 528 // type. |
| 529 std::wstring link_type = webkit_glue::StringToStdWString(link->type()); |
| 530 TrimWhitespace(link_type, TRIM_ALL, &link_type); |
| 531 if (LowerCaseEqualsASCII(link_type, "application/atom+xml") || |
| 532 LowerCaseEqualsASCII(link_type, "application/rss+xml")) { |
| 533 is_feed = true; |
| 534 } |
| 535 } |
| 536 |
| 537 if (is_feed) { |
| 538 FeedItem feedItem; |
| 539 feedItem.title = webkit_glue::StringToStdWString(link->title()); |
| 540 TrimWhitespace(feedItem.title, TRIM_ALL, &feedItem.title); |
| 541 feedItem.type = webkit_glue::StringToStdWString(link->type()); |
| 542 TrimWhitespace(feedItem.type, TRIM_ALL, &feedItem.type); |
| 543 feedItem.url = webkit_glue::KURLToGURL(link->href()); |
| 544 feedlist->Add(feedItem); |
| 545 } |
| 546 } |
| 547 |
| 548 return feedlist; |
| 549 } |
| 550 |
488 bool WebFrameImpl::GetPreviousHistoryState(std::string* history_state) const { | 551 bool WebFrameImpl::GetPreviousHistoryState(std::string* history_state) const { |
489 // We use the previous item here because documentState (filled-out forms) | 552 // We use the previous item here because documentState (filled-out forms) |
490 // only get saved to history when it becomes the previous item. The caller | 553 // only get saved to history when it becomes the previous item. The caller |
491 // is expected to query the history state after a navigation occurs, after | 554 // is expected to query the history state after a navigation occurs, after |
492 // the desired history item has become the previous entry. | 555 // the desired history item has become the previous entry. |
493 RefPtr<HistoryItem> item = webview_impl_->GetPreviousHistoryItem(); | 556 RefPtr<HistoryItem> item = webview_impl_->GetPreviousHistoryItem(); |
494 if (!item) | 557 if (!item) |
495 return false; | 558 return false; |
496 | 559 |
497 static StatsCounterTimer history_timer("GetHistoryTimer"); | 560 static StatsCounterTimer history_timer("GetHistoryTimer"); |
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1843 return password_listeners_.get(input_element); | 1906 return password_listeners_.get(input_element); |
1844 } | 1907 } |
1845 | 1908 |
1846 void WebFrameImpl::ClearPasswordListeners() { | 1909 void WebFrameImpl::ClearPasswordListeners() { |
1847 for (PasswordListenerMap::iterator iter = password_listeners_.begin(); | 1910 for (PasswordListenerMap::iterator iter = password_listeners_.begin(); |
1848 iter != password_listeners_.end(); ++iter) { | 1911 iter != password_listeners_.end(); ++iter) { |
1849 delete iter->second; | 1912 delete iter->second; |
1850 } | 1913 } |
1851 password_listeners_.clear(); | 1914 password_listeners_.clear(); |
1852 } | 1915 } |
OLD | NEW |