Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / content / common / navigation_params.h
1 // Copyright 2014 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 CONTENT_COMMON_NAVIGATION_PARAMS_H_
6 #define CONTENT_COMMON_NAVIGATION_PARAMS_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/time/time.h"
12 #include "content/common/content_export.h"
13 #include "content/common/frame_message_enums.h"
14 #include "content/public/common/page_state.h"
15 #include "content/public/common/referrer.h"
16 #include "ui/base/page_transition_types.h"
17 #include "url/gurl.h"
18
19 namespace base {
20 class RefCountedMemory;
21 }
22
23 namespace content {
24 class NavigationEntry;
25
26 // The following structures hold parameters used during a navigation. In
27 // particular they are used by FrameMsg_Navigate, FrameMsg_CommitNavigation and
28 // FrameHostMsg_BeginNavigation.
29 // TODO(clamy): Depending on the avancement of the history refactoring move the
30 // history parameters from FrameMsg_Navigate into one of the structs.
31
32 // Used by all navigation IPCs.
33 struct CONTENT_EXPORT CommonNavigationParams {
34   CommonNavigationParams();
35   CommonNavigationParams(const GURL& url,
36                          const Referrer& referrer,
37                          ui::PageTransition transition,
38                          FrameMsg_Navigate_Type::Value navigation_type,
39                          bool allow_download);
40   ~CommonNavigationParams();
41
42   // The URL to navigate to.
43   // PlzNavigate: May be modified when the navigation is ready to commit.
44   GURL url;
45
46   // The URL to send in the "Referer" header field. Can be empty if there is
47   // no referrer.
48   Referrer referrer;
49
50   // The type of transition.
51   ui::PageTransition transition;
52
53   // Type of navigation.
54   FrameMsg_Navigate_Type::Value navigation_type;
55
56   // Allows the URL to be downloaded (true by default).
57   // Avoid downloading when in view-source mode.
58   bool allow_download;
59 };
60
61 // Used by FrameMsg_Navigate.
62 // PlzNavigate: sent to the renderer when requesting a navigation.
63 struct CONTENT_EXPORT RequestNavigationParams {
64   RequestNavigationParams();
65   RequestNavigationParams(bool is_post,
66                           const std::string& extra_headers,
67                           const base::RefCountedMemory* post_data);
68   ~RequestNavigationParams();
69
70   // Whether the navigation is a POST request (as opposed to a GET).
71   bool is_post;
72
73   // Extra headers (separated by \n) to send during the request.
74   std::string extra_headers;
75
76   // If is_post is true, holds the post_data information from browser. Empty
77   // otherwise.
78   std::vector<unsigned char> browser_initiated_post_data;
79 };
80
81 // Used by FrameMsg_Navigate.
82 // PlzNavigate: sent to the renderer when the navigation is ready to commit.
83 struct CONTENT_EXPORT CommitNavigationParams {
84   CommitNavigationParams();
85   CommitNavigationParams(const PageState& page_state,
86                          bool is_overriding_user_agent,
87                          base::TimeTicks navigation_start);
88   ~CommitNavigationParams();
89
90   // Opaque history state (received by ViewHostMsg_UpdateState).
91   PageState page_state;
92
93   // Whether or not the user agent override string should be used.
94   bool is_overriding_user_agent;
95
96   // The navigationStart time to expose through the Navigation Timing API to JS.
97   base::TimeTicks browser_navigation_start;
98
99   // TODO(clamy): Move the redirect chain here.
100 };
101
102 }  // namespace content
103
104 #endif  // CONTENT_COMMON_NAVIGATION_PARAMS_H_