15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// PageNavigator defines an interface that can be used to express the user's
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// intention to navigate to a particular URL.  The implementing class should
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// perform the navigation.
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "base/memory/ref_counted.h"
15a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "base/memory/ref_counted_memory.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/global_request_id.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/referrer.h"
191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "ui/base/page_transition_types.h"
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/base/window_open_disposition.h"
217dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "url/gurl.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebContents;
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct CONTENT_EXPORT OpenURLParams {
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  OpenURLParams(const GURL& url,
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                const Referrer& referrer,
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                WindowOpenDisposition disposition,
311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                ui::PageTransition transition,
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                bool is_renderer_initiated);
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  OpenURLParams(const GURL& url,
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                const Referrer& referrer,
35f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)                int64 frame_tree_node_id,
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                WindowOpenDisposition disposition,
371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                ui::PageTransition transition,
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                bool is_renderer_initiated);
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ~OpenURLParams();
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The URL/referrer to be opened.
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL url;
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Referrer referrer;
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Any redirect URLs that occurred for this navigation before |url|.
461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  std::vector<GURL> redirect_chain;
471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
48a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // Indicates whether this navigation will be sent using POST.
49a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // The POST method is limited support for basic POST data by leveraging
50a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST.
51a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // It is not for things like file uploads.
52a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  bool uses_post;
53a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
54a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  // The post data when the navigation uses POST.
55a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  scoped_refptr<base::RefCountedMemory> browser_initiated_post_data;
56a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Extra headers to add to the request for this page.  Headers are
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // represented as "<name>: <value>" and separated by \r\n.  The entire string
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is terminated by \r\n.  May be empty if no extra headers are needed.
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string extra_headers;
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
62f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // The browser-global FrameTreeNode ID or -1 to indicate the main frame.
63f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  int64 frame_tree_node_id;
64f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The disposition requested by the navigation source.
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WindowOpenDisposition disposition;
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The transition type of navigation.
691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  ui::PageTransition transition;
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether this navigation is initiated by the renderer process.
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_renderer_initiated;
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Reference to the old request id in case this is a navigation that is being
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // transferred to a new renderer.
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GlobalRequestID transferred_global_request_id;
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
78ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  // Indicates whether this navigation should replace the current
79ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  // navigation entry.
80ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  bool should_replace_current_entry;
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
827dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // Indicates whether this navigation was triggered while processing a user
837dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // gesture if the navigation was initiated by the renderer.
847dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  bool user_gesture;
857dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  OpenURLParams();
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class PageNavigator {
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~PageNavigator() {}
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Opens a URL with the given disposition.  The transition specifies how this
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // navigation should be recorded in the history system (for example, typed).
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the WebContents the URL is opened in, or NULL if the URL wasn't
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // opened immediately.
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual WebContents* OpenURL(const OpenURLParams& params) = 0;
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
101a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)}  // namespace content
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_PUBLIC_BROWSER_PAGE_NAVIGATOR_H_
104