- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / web_navigation / web_navigation_api_helpers.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 CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_HELPERS_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_HELPERS_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "content/public/common/page_transition_types.h"
12
13 namespace content {
14 class BrowserContext;
15 class WebContents;
16 }
17
18 class GURL;
19
20 namespace extensions {
21
22 namespace web_navigation_api_helpers {
23
24 // Returns the frame ID as it will be passed to the extension:
25 // 0 if the navigation happens in the main frame, or the frame ID
26 // modulo 32 bits otherwise.
27 int GetFrameId(bool is_main_frame, int64 frame_id);
28
29 // Create and dispatch the various events of the webNavigation API.
30 void DispatchOnBeforeNavigate(content::WebContents* web_contents,
31                               int render_process_id,
32                               int64 frame_id,
33                               bool is_main_frame,
34                               int64 parent_frame_id,
35                               bool parent_is_main_frame,
36                               const GURL& validated_url);
37
38 void DispatchOnCommitted(const std::string& event_name,
39                          content::WebContents* web_contents,
40                          int64 frame_id,
41                          bool is_main_frame,
42                          const GURL& url,
43                          content::PageTransition transition_type);
44
45 void DispatchOnDOMContentLoaded(content::WebContents* web_contents,
46                                 const GURL& url,
47                                 bool is_main_frame,
48                                 int64 frame_id);
49
50 void DispatchOnCompleted(content::WebContents* web_contents,
51                          const GURL& url,
52                          bool is_main_frame,
53                          int64 frame_id);
54
55 void DispatchOnCreatedNavigationTarget(
56     content::WebContents* web_contents,
57     content::BrowserContext* browser_context,
58     int64 source_frame_id,
59     bool source_frame_is_main_frame,
60     content::WebContents* target_web_contents,
61     const GURL& target_url);
62
63 void DispatchOnErrorOccurred(content::WebContents* web_contents,
64                              int render_process_id,
65                              const GURL& url,
66                              int64 frame_id,
67                              bool is_main_frame,
68                              int error_code);
69
70 void DispatchOnTabReplaced(
71     content::WebContents* old_web_contents,
72     content::BrowserContext* browser_context,
73     content::WebContents* new_web_contents);
74
75 }  // namespace web_navigation_api_helpers
76
77 }  // namespace extensions
78
79 #endif  // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_WEB_NAVIGATION_API_HELPERS_H_