1// Copyright (c) 2010 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 WEBKIT_GLUE_DOM_OPERATIONS_H__
6#define WEBKIT_GLUE_DOM_OPERATIONS_H__
7
8#include <string>
9#include <vector>
10
11#include "googleurl/src/gurl.h"
12
13namespace WebKit {
14class WebDocument;
15class WebElement;
16class WebString;
17class WebView;
18}
19
20// A collection of operations that access the underlying WebKit DOM directly.
21namespace webkit_glue {
22
23// Structure for storage the result of getting all savable resource links
24// for current page. The consumer of the SavableResourcesResult is responsible
25// for keeping these pointers valid for the lifetime of the
26// SavableResourcesResult instance.
27struct SavableResourcesResult {
28  // vector which contains all savable links of sub resource.
29  std::vector<GURL>* resources_list;
30  // vector which contains corresponding all referral links of sub resource,
31  // it matched with links one by one.
32  std::vector<GURL>* referrers_list;
33  // vector which contains all savable links of main frame and sub frames.
34  std::vector<GURL>* frames_list;
35
36  // Constructor.
37  SavableResourcesResult(std::vector<GURL>* resources_list,
38                         std::vector<GURL>* referrers_list,
39                         std::vector<GURL>* frames_list)
40      : resources_list(resources_list),
41        referrers_list(referrers_list),
42        frames_list(frames_list) { }
43
44 private:
45  DISALLOW_COPY_AND_ASSIGN(SavableResourcesResult);
46};
47
48// Get all savable resource links from current webview, include main frame
49// and sub-frame. After collecting all savable resource links, this function
50// will send those links to embedder. Return value indicates whether we get
51// all saved resource links successfully.
52bool GetAllSavableResourceLinksForCurrentPage(WebKit::WebView* view,
53    const GURL& page_url, SavableResourcesResult* savable_resources_result,
54    const char** savable_schemes);
55
56// Invokes pauseAnimationAtTime on the AnimationController associated with the
57// |view|s main frame.
58// This is used by test shell.
59bool PauseAnimationAtTimeOnElementWithId(WebKit::WebView* view,
60                                         const std::string& animation_name,
61                                         double time,
62                                         const std::string& element_id);
63
64// Invokes pauseTransitionAtTime on the AnimationController associated with the
65// |view|s main frame.
66// This is used by test shell.
67bool PauseTransitionAtTimeOnElementWithId(WebKit::WebView* view,
68                                          const std::string& property_name,
69                                          double time,
70                                          const std::string& element_id);
71
72// Returns true if the element with |element_id| as its id has autocomplete
73// on.
74bool ElementDoesAutoCompleteForElementWithId(WebKit::WebView* view,
75                                             const std::string& element_id);
76
77// Returns the number of animations currently running.
78int NumberOfActiveAnimations(WebKit::WebView* view);
79
80// Returns the value in an elements resource url attribute. For IMG, SCRIPT or
81// INPUT TYPE=image, returns the value in "src". For LINK TYPE=text/css, returns
82// the value in "href". For BODY, TABLE, TR, TD, returns the value in
83// "background". For BLOCKQUOTE, Q, DEL, INS, returns the value in "cite"
84// attribute. Otherwise returns a null WebString.
85WebKit::WebString GetSubResourceLinkFromElement(
86    const WebKit::WebElement& element);
87
88// Puts the meta-elements of |document| that have the attribute |attribute_name|
89// with a value of |attribute_value| in |meta_elements|.
90void GetMetaElementsWithAttribute(
91    WebKit::WebDocument* document,
92    const string16& attribute_name,
93    const string16& atribute_value,
94    std::vector<WebKit::WebElement>* meta_elements);
95
96}  // namespace webkit_glue
97
98#endif  // WEBKIT_GLUE_DOM_OPERATIONS_H__
99