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

Side by Side Diff: webkit/glue/webframe_impl.cc

Issue 43109: RSS feed support (part 1)... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webframe_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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/webdocumentloader_impl.h" 141 #include "webkit/glue/webdocumentloader_impl.h"
141 #include "webkit/glue/webdatasource_impl.h" 142 #include "webkit/glue/webdatasource_impl.h"
142 #include "webkit/glue/weberror_impl.h" 143 #include "webkit/glue/weberror_impl.h"
143 #include "webkit/glue/webframe_impl.h" 144 #include "webkit/glue/webframe_impl.h"
144 #include "webkit/glue/webhistoryitem_impl.h" 145 #include "webkit/glue/webhistoryitem_impl.h"
145 #include "webkit/glue/weburlrequest_impl.h" 146 #include "webkit/glue/weburlrequest_impl.h"
146 #include "webkit/glue/webtextinput_impl.h" 147 #include "webkit/glue/webtextinput_impl.h"
147 #include "webkit/glue/webview_impl.h" 148 #include "webkit/glue/webview_impl.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 if (link_element && link_element->type() == kOSDType && 480 if (link_element && link_element->type() == kOSDType &&
480 link_element->rel() == kOSDRel && !link_element->href().isEmpty()) { 481 link_element->rel() == kOSDRel && !link_element->href().isEmpty()) {
481 return webkit_glue::KURLToGURL(link_element->href()); 482 return webkit_glue::KURLToGURL(link_element->href());
482 } 483 }
483 } 484 }
484 } 485 }
485 } 486 }
486 return GURL(); 487 return GURL();
487 } 488 }
488 489
490 scoped_refptr<FeedList> WebFrameImpl::GetFeedList() const {
491 scoped_refptr<FeedList> feedlist = new FeedList();
492
493 WebCore::FrameLoader* frame_loader = frame_->loader();
494 if (frame_loader->state() != WebCore::FrameStateComplete ||
495 !frame_->document() ||
496 !frame_->document()->head() ||
497 frame_->tree()->parent())
498 return feedlist;
499
500 // We only consider HTML documents with <head> tags.
501 // (Interestingly, isHTMLDocument() returns false for some pages --
502 // perhaps an XHTML thing? It doesn't really matter because head() is
503 // a method on Documents anyway.)
504 WebCore::HTMLHeadElement* head = frame_->document()->head();
505 if (!head)
506 return feedlist;
507
508 // Iterate through all children of the <head>, looking for feed links.
509 for (WebCore::Node* node = head->firstChild();
510 node; node = node->nextSibling()) {
511 // Skip over all nodes except <link ...>.
512 if (!node->isHTMLElement())
513 continue;
514 if (!static_cast<WebCore::Element*>(node)->hasLocalName("link"))
515 continue;
516
517 const WebCore::HTMLLinkElement* link =
518 static_cast<WebCore::HTMLLinkElement*>(node);
519
520 // Look at the 'rel' tag and see if we have a feed.
521 std::wstring rel = webkit_glue::StringToStdWString(link->rel());
522 bool is_feed = false;
523 if (LowerCaseEqualsASCII(rel, "feed") ||
524 LowerCaseEqualsASCII(rel, "feed alternate")) {
525 // rel="feed" or rel="alternate feed" always means this is a feed.
526 is_feed = true;
527 } else if (LowerCaseEqualsASCII(rel, "alternate")) {
528 // Otherwise, rel="alternate" may mean a feed if it has a certain mime
529 // type.
530 std::wstring link_type = webkit_glue::StringToStdWString(link->type());
531 TrimWhitespace(link_type, TRIM_ALL, &link_type);
532 if (LowerCaseEqualsASCII(link_type, "application/atom+xml") ||
533 LowerCaseEqualsASCII(link_type, "application/rss+xml")) {
534 is_feed = true;
535 }
536 }
537
538 if (is_feed) {
539 FeedItem feedItem;
540 feedItem.title = webkit_glue::StringToStdWString(link->title());
541 TrimWhitespace(feedItem.title, TRIM_ALL, &feedItem.title);
542 feedItem.type = webkit_glue::StringToStdWString(link->type());
543 TrimWhitespace(feedItem.type, TRIM_ALL, &feedItem.type);
544 feedItem.url = webkit_glue::KURLToGURL(link->href());
545 feedlist->Add(feedItem);
546 }
547 }
548
549 return feedlist;
550 }
551
489 bool WebFrameImpl::GetPreviousHistoryState(std::string* history_state) const { 552 bool WebFrameImpl::GetPreviousHistoryState(std::string* history_state) const {
490 // We use the previous item here because documentState (filled-out forms) 553 // We use the previous item here because documentState (filled-out forms)
491 // only get saved to history when it becomes the previous item. The caller 554 // only get saved to history when it becomes the previous item. The caller
492 // is expected to query the history state after a navigation occurs, after 555 // is expected to query the history state after a navigation occurs, after
493 // the desired history item has become the previous entry. 556 // the desired history item has become the previous entry.
494 RefPtr<HistoryItem> item = webview_impl_->GetPreviousHistoryItem(); 557 RefPtr<HistoryItem> item = webview_impl_->GetPreviousHistoryItem();
495 if (!item) 558 if (!item)
496 return false; 559 return false;
497 560
498 static StatsCounterTimer history_timer("GetHistoryTimer"); 561 static StatsCounterTimer history_timer("GetHistoryTimer");
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 return password_listeners_.get(input_element); 1908 return password_listeners_.get(input_element);
1846 } 1909 }
1847 1910
1848 void WebFrameImpl::ClearPasswordListeners() { 1911 void WebFrameImpl::ClearPasswordListeners() {
1849 for (PasswordListenerMap::iterator iter = password_listeners_.begin(); 1912 for (PasswordListenerMap::iterator iter = password_listeners_.begin();
1850 iter != password_listeners_.end(); ++iter) { 1913 iter != password_listeners_.end(); ++iter) {
1851 delete iter->second; 1914 delete iter->second;
1852 } 1915 }
1853 password_listeners_.clear(); 1916 password_listeners_.clear();
1854 } 1917 }
OLDNEW
« no previous file with comments | « webkit/glue/webframe_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698