OLD | NEW |
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 "content/renderer/android/content_detector.h" | 5 #include "content/renderer/android/content_detector.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/WebKit/public/platform/WebPoint.h" | 8 #include "third_party/WebKit/public/platform/WebPoint.h" |
9 #include "third_party/WebKit/public/web/WebHitTestResult.h" | 9 #include "third_party/WebKit/public/web/WebHitTestResult.h" |
10 #include "third_party/WebKit/public/web/WebSurroundingText.h" | 10 #include "third_party/WebKit/public/web/WebSurroundingText.h" |
11 | 11 |
12 using WebKit::WebRange; | 12 using blink::WebRange; |
13 using WebKit::WebSurroundingText; | 13 using blink::WebSurroundingText; |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 ContentDetector::Result::Result() : valid(false) {} | 17 ContentDetector::Result::Result() : valid(false) {} |
18 | 18 |
19 ContentDetector::Result::Result(const WebKit::WebRange& content_boundaries, | 19 ContentDetector::Result::Result(const blink::WebRange& content_boundaries, |
20 const std::string& text, | 20 const std::string& text, |
21 const GURL& intent_url) | 21 const GURL& intent_url) |
22 : valid(true), | 22 : valid(true), |
23 content_boundaries(content_boundaries), | 23 content_boundaries(content_boundaries), |
24 text(text), | 24 text(text), |
25 intent_url(intent_url) { | 25 intent_url(intent_url) { |
26 } | 26 } |
27 | 27 |
28 ContentDetector::Result::~Result() {} | 28 ContentDetector::Result::~Result() {} |
29 | 29 |
30 ContentDetector::Result ContentDetector::FindTappedContent( | 30 ContentDetector::Result ContentDetector::FindTappedContent( |
31 const WebKit::WebHitTestResult& hit_test) { | 31 const blink::WebHitTestResult& hit_test) { |
32 if (hit_test.isNull()) | 32 if (hit_test.isNull()) |
33 return Result(); | 33 return Result(); |
34 | 34 |
35 std::string content_text; | 35 std::string content_text; |
36 WebKit::WebRange range = FindContentRange(hit_test, &content_text); | 36 blink::WebRange range = FindContentRange(hit_test, &content_text); |
37 if (range.isNull()) | 37 if (range.isNull()) |
38 return Result(); | 38 return Result(); |
39 | 39 |
40 GURL intent_url = GetIntentURL(content_text); | 40 GURL intent_url = GetIntentURL(content_text); |
41 return Result(range, content_text, intent_url); | 41 return Result(range, content_text, intent_url); |
42 } | 42 } |
43 | 43 |
44 WebRange ContentDetector::FindContentRange( | 44 WebRange ContentDetector::FindContentRange( |
45 const WebKit::WebHitTestResult& hit_test, | 45 const blink::WebHitTestResult& hit_test, |
46 std::string* content_text) { | 46 std::string* content_text) { |
47 // As the surrounding text extractor looks at maxLength/2 characters on | 47 // As the surrounding text extractor looks at maxLength/2 characters on |
48 // either side of the hit point, we need to double max content length here. | 48 // either side of the hit point, we need to double max content length here. |
49 WebSurroundingText surrounding_text; | 49 WebSurroundingText surrounding_text; |
50 surrounding_text.initialize(hit_test.node(), hit_test.localPoint(), | 50 surrounding_text.initialize(hit_test.node(), hit_test.localPoint(), |
51 GetMaximumContentLength() * 2); | 51 GetMaximumContentLength() * 2); |
52 if (surrounding_text.isNull()) | 52 if (surrounding_text.isNull()) |
53 return WebRange(); | 53 return WebRange(); |
54 | 54 |
55 string16 content = surrounding_text.textContent(); | 55 string16 content = surrounding_text.textContent(); |
(...skipping 19 matching lines...) Expand all Loading... |
75 } else { | 75 } else { |
76 start_offset += relative_end; | 76 start_offset += relative_end; |
77 } | 77 } |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 return WebRange(); | 81 return WebRange(); |
82 } | 82 } |
83 | 83 |
84 } // namespace content | 84 } // namespace content |
OLD | NEW |