- add sources.
[platform/framework/web/crosswalk.git] / src / android_webview / common / aw_hit_test_data.h
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 ANDROID_WEBVIEW_COMMON_AW_HIT_TEST_DATA_H_
6 #define ANDROID_WEBVIEW_COMMON_AW_HIT_TEST_DATA_H_
7
8 #include "base/strings/string16.h"
9 #include "url/gurl.h"
10
11 namespace android_webview {
12
13 // Holdes all hit test data needed by public WebView APIs.
14 // The Java counter part to this is AwContents.HitTestData.
15 struct AwHitTestData {
16
17   // Matches exactly with constants in WebView.HitTestResult, with deprecated
18   // values removed.
19   enum Type {
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|, |anchor_text|, |img_src| contain
25     // their normal values for the respective type.
26     UNKNOWN_TYPE = 0,
27
28     // Special case urls for SRC_LINK_TYPE below. Each type corresponds to a
29     // different prefix in content url_constants. |extra_data_for_type| will
30     // contain the url but with the prefix removed. Other fields are the same
31     // as SRC_LINK_TYPE.
32     PHONE_TYPE = 2,
33     GEO_TYPE = 3,
34     EMAIL_TYPE = 4,
35
36     // Hit on a pure image (without links). |extra_data_for_type|, |href|,
37     // and |anchor_text| will be empty. |img_src| will contain the absolute
38     // source url of the image.
39     IMAGE_TYPE = 5,
40
41     // Hit on a link with valid and non-javascript url and without embedded
42     // image. |extra_data_for_type| is the valid absolute url of the link.
43     // |href| will contain the exact href attribute string. |anchor_text| will
44     // contain the anchor text if the link is an anchor tag. |img_src| will be
45     // 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
50     // <link> or <area>.
51     SRC_LINK_TYPE = 7,
52
53     // Same as SRC_LINK_TYPE except the link contains an image. |img_src| and
54     // |extra_data_for_type| will contain the absolute valid url of the image
55     // source. |href| will contain the (possibly invalid or javascript-scheme)
56     // link href attribute. |anchor_text| will be empty.
57     // Both notes from SRC_LINK_TYPE apply.
58     SRC_IMAGE_LINK_TYPE = 8,
59
60     // Hit on an editable text input element. All other values will be empty.
61     EDIT_TEXT_TYPE = 9,
62   };
63
64   // For all strings/GURLs, empty/invalid will become null upon conversion to
65   // Java.
66   int type;  // Only values from enum Type above.
67   std::string extra_data_for_type;
68   string16 href;
69   string16 anchor_text;
70   GURL img_src;
71
72   AwHitTestData();
73   ~AwHitTestData();
74 };
75
76 }  // namespace android_webview
77
78 #endif  // ANDROID_WEBVIEW_COMMON_AW_HIT_TEST_DATA_H_