| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_ANDROID_CONTENT_DETECTOR_H_ | |
| 6 #define CONTENT_RENDERER_ANDROID_CONTENT_DETECTOR_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "third_party/WebKit/public/platform/WebURL.h" | |
| 12 #include "url/gurl.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 class WebHitTestResult; | |
| 16 } | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 // Base class for text-based content detectors. | |
| 21 class ContentDetector { | |
| 22 public: | |
| 23 virtual ~ContentDetector() {} | |
| 24 | |
| 25 // Returns an intent URL for the content around the hit_test. | |
| 26 // If no content is found, an empty URL will be returned. | |
| 27 blink::WebURL FindTappedContent(const blink::WebHitTestResult& hit_test); | |
| 28 | |
| 29 protected: | |
| 30 ContentDetector() {} | |
| 31 | |
| 32 // Parses the input string defined by the begin/end iterators returning true | |
| 33 // if the desired content is found. The start and end positions relative to | |
| 34 // the input iterators are returned in start_pos and end_pos. | |
| 35 // The end position is assumed to be non-inclusive. | |
| 36 virtual bool FindContent(const base::string16::const_iterator& begin, | |
| 37 const base::string16::const_iterator& end, | |
| 38 size_t* start_pos, | |
| 39 size_t* end_pos, | |
| 40 std::string* content_text) = 0; | |
| 41 | |
| 42 // Returns the intent URL that should process the content, if any. | |
| 43 virtual GURL GetIntentURL(const std::string& content_text) = 0; | |
| 44 | |
| 45 // Returns the maximum length of text to be extracted around the tapped | |
| 46 // position in order to search for content. | |
| 47 virtual size_t GetMaximumContentLength() = 0; | |
| 48 | |
| 49 bool FindContentRange(const blink::WebHitTestResult& hit_test, | |
| 50 std::string* content_text); | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(ContentDetector); | |
| 53 }; | |
| 54 | |
| 55 } // namespace content | |
| 56 | |
| 57 #endif // CONTENT_RENDERER_ANDROID_CONTENT_DETECTOR_H_ | |
| OLD | NEW |