| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_BROWSER_NAVIGATOR_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_NAVIGATOR_H_ |
| 6 #define CHROME_BROWSER_UI_BROWSER_NAVIGATOR_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_NAVIGATOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "content/public/browser/global_request_id.h" | 11 #include "content/public/browser/global_request_id.h" |
| 12 #include "content/public/common/page_transition_types.h" | 12 #include "content/public/common/page_transition_types.h" |
| 13 #include "content/public/common/referrer.h" | 13 #include "content/public/common/referrer.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 16 #include "webkit/glue/window_open_disposition.h" | 16 #include "webkit/glue/window_open_disposition.h" |
| 17 | 17 |
| 18 class Browser; | 18 class Browser; |
| 19 class Profile; | 19 class Profile; |
| 20 class TabContents; | 20 class TabContents; |
| 21 typedef TabContents TabContentsWrapper; | |
| 22 | 21 |
| 23 namespace browser { | 22 namespace browser { |
| 24 | 23 |
| 25 // Parameters that tell Navigate() what to do. | 24 // Parameters that tell Navigate() what to do. |
| 26 // | 25 // |
| 27 // Some basic examples: | 26 // Some basic examples: |
| 28 // | 27 // |
| 29 // Simple Navigate to URL in current tab: | 28 // Simple Navigate to URL in current tab: |
| 30 // browser::NavigateParams params(browser, GURL("http://www.google.com/"), | 29 // browser::NavigateParams params(browser, GURL("http://www.google.com/"), |
| 31 // PageTransition::LINK); | 30 // PageTransition::LINK); |
| 32 // browser::Navigate(¶ms); | 31 // browser::Navigate(¶ms); |
| 33 // | 32 // |
| 34 // Open bookmark in new background tab: | 33 // Open bookmark in new background tab: |
| 35 // browser::NavigateParams params(browser, url, PageTransition::AUTO_BOOKMARK); | 34 // browser::NavigateParams params(browser, url, PageTransition::AUTO_BOOKMARK); |
| 36 // params.disposition = NEW_BACKGROUND_TAB; | 35 // params.disposition = NEW_BACKGROUND_TAB; |
| 37 // browser::Navigate(¶ms); | 36 // browser::Navigate(¶ms); |
| 38 // | 37 // |
| 39 // Opens a popup TabContentsWrapper: | 38 // Opens a popup TabContents: |
| 40 // browser::NavigateParams params(browser, popup_contents); | 39 // browser::NavigateParams params(browser, popup_contents); |
| 41 // params.source_contents = source_contents; | 40 // params.source_contents = source_contents; |
| 42 // browser::Navigate(¶ms); | 41 // browser::Navigate(¶ms); |
| 43 // | 42 // |
| 44 // See browser_navigator_browsertest.cc for more examples. | 43 // See browser_navigator_browsertest.cc for more examples. |
| 45 // | 44 // |
| 46 struct NavigateParams { | 45 struct NavigateParams { |
| 47 NavigateParams(Browser* browser, | 46 NavigateParams(Browser* browser, |
| 48 const GURL& a_url, | 47 const GURL& a_url, |
| 49 content::PageTransition a_transition); | 48 content::PageTransition a_transition); |
| 50 NavigateParams(Browser* browser, TabContentsWrapper* a_target_contents); | 49 NavigateParams(Browser* browser, TabContents* a_target_contents); |
| 51 ~NavigateParams(); | 50 ~NavigateParams(); |
| 52 | 51 |
| 53 // The URL/referrer to be loaded. Ignored if |target_contents| is non-NULL. | 52 // The URL/referrer to be loaded. Ignored if |target_contents| is non-NULL. |
| 54 GURL url; | 53 GURL url; |
| 55 content::Referrer referrer; | 54 content::Referrer referrer; |
| 56 | 55 |
| 57 // [in] A TabContentsWrapper to be navigated or inserted into the target | 56 // [in] A TabContents to be navigated or inserted into the target |
| 58 // Browser's tabstrip. If NULL, |url| or the homepage will be used | 57 // Browser's tabstrip. If NULL, |url| or the homepage will be used |
| 59 // instead. When non-NULL, Navigate() assumes it has already been | 58 // instead. When non-NULL, Navigate() assumes it has already been |
| 60 // navigated to its intended destination and will not load any URL in it | 59 // navigated to its intended destination and will not load any URL in it |
| 61 // (i.e. |url| is ignored). | 60 // (i.e. |url| is ignored). |
| 62 // Default is NULL. | 61 // Default is NULL. |
| 63 // [out] The TabContentsWrapper in which the navigation occurred or that was | 62 // [out] The TabContents in which the navigation occurred or that was |
| 64 // inserted. Guaranteed non-NULL except for note below: | 63 // inserted. Guaranteed non-NULL except for note below: |
| 65 // Note: If this field is set to NULL by the caller and Navigate() creates | 64 // Note: If this field is set to NULL by the caller and Navigate() creates |
| 66 // a new TabContentsWrapper, this field will remain NULL and the | 65 // a new TabContents, this field will remain NULL and the |
| 67 // TabContentsWrapper deleted if the TabContentsWrapper it created is | 66 // TabContents deleted if the TabContents it created is |
| 68 // not added to a TabStripModel before Navigate() returns. | 67 // not added to a TabStripModel before Navigate() returns. |
| 69 TabContentsWrapper* target_contents; | 68 TabContents* target_contents; |
| 70 | 69 |
| 71 // [in] The TabContentsWrapper that initiated the Navigate() request if such | 70 // [in] The TabContents that initiated the Navigate() request if such |
| 72 // context is necessary. Default is NULL, i.e. no context. | 71 // context is necessary. Default is NULL, i.e. no context. |
| 73 // [out] If NULL, this value will be set to the selected TabContentsWrapper in | 72 // [out] If NULL, this value will be set to the selected TabContents in |
| 74 // the originating browser prior to the operation performed by | 73 // the originating browser prior to the operation performed by |
| 75 // Navigate(). However, if the originating page is from a different | 74 // Navigate(). However, if the originating page is from a different |
| 76 // profile (e.g. an OFF_THE_RECORD page originating from a non-OTR | 75 // profile (e.g. an OFF_THE_RECORD page originating from a non-OTR |
| 77 // window), then |source_contents| is reset to NULL. | 76 // window), then |source_contents| is reset to NULL. |
| 78 TabContentsWrapper* source_contents; | 77 TabContents* source_contents; |
| 79 | 78 |
| 80 // The disposition requested by the navigation source. Default is | 79 // The disposition requested by the navigation source. Default is |
| 81 // CURRENT_TAB. What follows is a set of coercions that happen to this value | 80 // CURRENT_TAB. What follows is a set of coercions that happen to this value |
| 82 // when other factors are at play: | 81 // when other factors are at play: |
| 83 // | 82 // |
| 84 // [in]: Condition: [out]: | 83 // [in]: Condition: [out]: |
| 85 // NEW_BACKGROUND_TAB target browser tabstrip is empty NEW_FOREGROUND_TAB | 84 // NEW_BACKGROUND_TAB target browser tabstrip is empty NEW_FOREGROUND_TAB |
| 86 // CURRENT_TAB " " " NEW_FOREGROUND_TAB | 85 // CURRENT_TAB " " " NEW_FOREGROUND_TAB |
| 87 // OFF_THE_RECORD target browser profile is incog. NEW_FOREGROUND_TAB | 86 // OFF_THE_RECORD target browser profile is incog. NEW_FOREGROUND_TAB |
| 88 // | 87 // |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // If the given navigational URL is a Singleton, return the tab index for it. | 197 // If the given navigational URL is a Singleton, return the tab index for it. |
| 199 // Otherwise, returns -1. | 198 // Otherwise, returns -1. |
| 200 int GetIndexOfSingletonTab(NavigateParams* params); | 199 int GetIndexOfSingletonTab(NavigateParams* params); |
| 201 | 200 |
| 202 // Returns true if the url is allowed to open in incognito window. | 201 // Returns true if the url is allowed to open in incognito window. |
| 203 bool IsURLAllowedInIncognito(const GURL& url); | 202 bool IsURLAllowedInIncognito(const GURL& url); |
| 204 | 203 |
| 205 } // namespace browser | 204 } // namespace browser |
| 206 | 205 |
| 207 #endif // CHROME_BROWSER_UI_BROWSER_NAVIGATOR_H_ | 206 #endif // CHROME_BROWSER_UI_BROWSER_NAVIGATOR_H_ |
| OLD | NEW |