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

Side by Side Diff: chrome/renderer/chrome_render_view_observer.cc

Issue 296593003: Make various string_util functions take StringPieces instead of char[]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/renderer/chrome_render_view_observer.h" 5 #include "chrome/renderer/chrome_render_view_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 sprintf_s(buf, "%d chars retrieved for indexing in %gms\n", 551 sprintf_s(buf, "%d chars retrieved for indexing in %gms\n",
552 contents.size(), (end - begin)*1000); 552 contents.size(), (end - begin)*1000);
553 OutputDebugStringA(buf); 553 OutputDebugStringA(buf);
554 #endif 554 #endif
555 555
556 // When the contents are clipped to the maximum, we don't want to have a 556 // When the contents are clipped to the maximum, we don't want to have a
557 // partial word indexed at the end that might have been clipped. Therefore, 557 // partial word indexed at the end that might have been clipped. Therefore,
558 // terminate the string at the last space to ensure no words are clipped. 558 // terminate the string at the last space to ensure no words are clipped.
559 if (contents->size() == kMaxIndexChars) { 559 if (contents->size() == kMaxIndexChars) {
560 size_t last_space_index = contents->find_last_of(base::kWhitespaceUTF16); 560 size_t last_space_index = contents->find_last_of(base::kWhitespaceUTF16);
561 if (last_space_index == base::string16::npos) 561 if (last_space_index != base::string16::npos)
562 return; // don't index if we got a huge block of text with no spaces 562 contents->resize(last_space_index);
563 contents->resize(last_space_index);
564 } 563 }
565 } 564 }
566 565
567 bool ChromeRenderViewObserver::HasRefreshMetaTag(WebFrame* frame) { 566 bool ChromeRenderViewObserver::HasRefreshMetaTag(WebFrame* frame) {
568 if (!frame) 567 if (!frame)
569 return false; 568 return false;
570 WebElement head = frame->document().head(); 569 WebElement head = frame->document().head();
571 if (head.isNull() || !head.hasChildNodes()) 570 if (head.isNull() || !head.hasChildNodes())
572 return false; 571 return false;
573 572
574 const WebString tag_name(base::ASCIIToUTF16("meta")); 573 const WebString tag_name(base::ASCIIToUTF16("meta"));
575 const WebString attribute_name(base::ASCIIToUTF16("http-equiv")); 574 const WebString attribute_name(base::ASCIIToUTF16("http-equiv"));
576 575
577 WebNodeList children = head.childNodes(); 576 WebNodeList children = head.childNodes();
578 for (size_t i = 0; i < children.length(); ++i) { 577 for (size_t i = 0; i < children.length(); ++i) {
579 WebNode node = children.item(i); 578 WebNode node = children.item(i);
580 if (!node.isElementNode()) 579 if (!node.isElementNode())
581 continue; 580 continue;
582 WebElement element = node.to<WebElement>(); 581 WebElement element = node.to<WebElement>();
583 if (!element.hasTagName(tag_name)) 582 if (!element.hasTagName(tag_name))
584 continue; 583 continue;
585 WebString value = element.getAttribute(attribute_name); 584 WebString value = element.getAttribute(attribute_name);
586 if (value.isNull() || !LowerCaseEqualsASCII(value, "refresh")) 585 if (value.isNull() || !LowerCaseEqualsASCII(value, "refresh"))
587 continue; 586 continue;
588 return true; 587 return true;
589 } 588 }
590 return false; 589 return false;
591 } 590 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698