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 ANDROID_WEBVIEW_COMMON_AW_HIT_TEST_DATA_H_
6 #define ANDROID_WEBVIEW_COMMON_AW_HIT_TEST_DATA_H_
8 #include "base/strings/string16.h"
11 namespace android_webview
{
13 // Holdes all hit test data needed by public WebView APIs.
14 // The Java counter part to this is AwContents.HitTestData.
15 struct AwHitTestData
{
17 // Matches exactly with constants in WebView.HitTestResult, with deprecated
20 // Default type where nothing we are interested in is hit.
21 // |extra_data_for_type| will be empty. All other values should be emtpy
22 // except the special case described below.
23 // For special case of invalid or javascript scheme url that would
24 // otherwise be type an LINK type, |href| will contain the javascript
25 // string in the href attribute, and |anchor_text|i and |img_src| contain
26 // their normal values for the respective type.
29 // Special case urls for SRC_LINK_TYPE below. Each type corresponds to a
30 // different prefix in content url_constants. |extra_data_for_type| will
31 // contain the url but with the prefix removed. |href| will contain the
32 // exact href attribute string. Other fields are the same as SRC_LINK_TYPE.
37 // Hit on a pure image (without links). |extra_data_for_type|, |href|,
38 // and |anchor_text| will be empty. |img_src| will contain the absolute
39 // source url of the image.
42 // Hit on a link with valid and non-javascript url and without embedded
43 // image. |extra_data_for_type| and |href| will be the valid absolute url
44 // of the link. |anchor_text| will contain the anchor text if the link is
45 // an anchor tag. |img_src| will be empty.
46 // Note 1: If the link url is invalid or javascript scheme, then the type
47 // will be UNKNOWN_TYPE.
48 // Note 2: Note that this matches SRC_ANCHOR_TYPE in the public WebView
49 // Java API, but the actual tag can be something other than <a>, such as
51 // Note 3: |href| is not the raw attribute string, but the absolute link
55 // Same as SRC_LINK_TYPE except the link contains an image. |img_src| and
56 // |extra_data_for_type| will contain the absolute valid url of the image
57 // source. |href| will be the valid absolute url of the link. |anchor_text|
58 // will be empty. All notes from SRC_LINK_TYPE apply.
59 SRC_IMAGE_LINK_TYPE
= 8,
61 // Hit on an editable text input element. All other values will be empty.
65 // For all strings/GURLs, empty/invalid will become null upon conversion to
67 int type
; // Only values from enum Type above.
68 std::string extra_data_for_type
;
70 base::string16 anchor_text
;
77 } // namespace android_webview
79 #endif // ANDROID_WEBVIEW_COMMON_AW_HIT_TEST_DATA_H_