Disable ContentSettingBubbleModelTest.RPHAllow which is flaky.
[chromium-blink-merge.git] / content / renderer / android / content_detector.h
blob6695cf8b5120dcbf1ebf72eeea825431ba4a232d
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.
5 #ifndef CONTENT_RENDERER_ANDROID_CONTENT_DETECTOR_H_
6 #define CONTENT_RENDERER_ANDROID_CONTENT_DETECTOR_H_
8 #include "googleurl/src/gurl.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
11 namespace WebKit {
12 class WebHitTestResult;
15 namespace content {
17 // Base class for text-based content detectors.
18 class ContentDetector {
19 public:
20 // Holds the content detection results.
21 struct Result {
22 Result();
23 Result(const WebKit::WebRange& content_boundaries,
24 const std::string& text,
25 const GURL& intent_url);
26 ~Result();
28 bool valid;
29 WebKit::WebRange content_boundaries;
30 std::string text; // Processed text of the content.
31 GURL intent_url; // URL of the intent that should process this content.
34 virtual ~ContentDetector() {}
36 // Returns a WebKit range delimiting the contents found around the tapped
37 // position. If no content is found a null range will be returned.
38 Result FindTappedContent(const WebKit::WebHitTestResult& hit_test);
40 protected:
41 ContentDetector() {}
43 // Parses the input string defined by the begin/end iterators returning true
44 // if the desired content is found. The start and end positions relative to
45 // the input iterators are returned in start_pos and end_pos.
46 // The end position is assumed to be non-inclusive.
47 virtual bool FindContent(const string16::const_iterator& begin,
48 const string16::const_iterator& end,
49 size_t* start_pos,
50 size_t* end_pos,
51 std::string* content_text) = 0;
53 // Returns the intent URL that should process the content, if any.
54 virtual GURL GetIntentURL(const std::string& content_text) = 0;
56 // Returns the maximum length of text to be extracted around the tapped
57 // position in order to search for content.
58 virtual size_t GetMaximumContentLength() = 0;
60 WebKit::WebRange FindContentRange(const WebKit::WebHitTestResult& hit_test,
61 std::string* content_text);
63 DISALLOW_COPY_AND_ASSIGN(ContentDetector);
66 } // namespace content
68 #endif // CONTENT_RENDERER_ANDROID_CONTENT_DETECTOR_H_