| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/common/page_transition_types.h" | 11 #include "chrome/common/page_transition_types.h" |
| 12 #include "gfx/rect.h" | 12 #include "gfx/rect.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "webkit/glue/window_open_disposition.h" | 14 #include "webkit/glue/window_open_disposition.h" |
| 15 | 15 |
| 16 class Browser; | 16 class Browser; |
| 17 class Profile; | 17 class Profile; |
| 18 class TabContents; | 18 class TabContentsWrapper; |
| 19 | 19 |
| 20 namespace browser { | 20 namespace browser { |
| 21 | 21 |
| 22 // Parameters that tell Navigate() what to do. | 22 // Parameters that tell Navigate() what to do. |
| 23 // | 23 // |
| 24 // Some basic examples: | 24 // Some basic examples: |
| 25 // | 25 // |
| 26 // Simple Navigate to URL in current tab: | 26 // Simple Navigate to URL in current tab: |
| 27 // browser::NavigateParams params(browser, GURL("http://www.google.com/"), | 27 // browser::NavigateParams params(browser, GURL("http://www.google.com/"), |
| 28 // PageTransition::LINK); | 28 // PageTransition::LINK); |
| 29 // browser::Navigate(¶ms); | 29 // browser::Navigate(¶ms); |
| 30 // | 30 // |
| 31 // Open bookmark in new background tab: | 31 // Open bookmark in new background tab: |
| 32 // browser::NavigateParams params(browser, url, PageTransition::AUTO_BOOKMARK); | 32 // browser::NavigateParams params(browser, url, PageTransition::AUTO_BOOKMARK); |
| 33 // params.disposition = NEW_BACKGROUND_TAB; | 33 // params.disposition = NEW_BACKGROUND_TAB; |
| 34 // browser::Navigate(¶ms); | 34 // browser::Navigate(¶ms); |
| 35 // | 35 // |
| 36 // Opens a popup TabContents: | 36 // Opens a popup TabContents: |
| 37 // browser::NavigateParams params(browser, popup_contents); | 37 // browser::NavigateParams params(browser, popup_contents); |
| 38 // params.source_contents = source_contents; | 38 // params.source_contents = source_contents; |
| 39 // browser::Navigate(¶ms); | 39 // browser::Navigate(¶ms); |
| 40 // | 40 // |
| 41 // See browser_navigator_browsertest.cc for more examples. | 41 // See browser_navigator_browsertest.cc for more examples. |
| 42 // | 42 // |
| 43 struct NavigateParams { | 43 struct NavigateParams { |
| 44 NavigateParams(Browser* browser, | 44 NavigateParams(Browser* browser, |
| 45 const GURL& a_url, | 45 const GURL& a_url, |
| 46 PageTransition::Type a_transition); | 46 PageTransition::Type a_transition); |
| 47 NavigateParams(Browser* browser, TabContents* a_target_contents); | 47 NavigateParams(Browser* browser, TabContentsWrapper* a_target_contents); |
| 48 ~NavigateParams(); | 48 ~NavigateParams(); |
| 49 | 49 |
| 50 // The URL/referrer to be loaded. Ignored if |target_contents| is non-NULL. | 50 // The URL/referrer to be loaded. Ignored if |target_contents| is non-NULL. |
| 51 GURL url; | 51 GURL url; |
| 52 GURL referrer; | 52 GURL referrer; |
| 53 | 53 |
| 54 // [in] A TabContents to be navigated or inserted into the target Browser's | 54 // [in] A TabContents to be navigated or inserted into the target Browser's |
| 55 // tabstrip. If NULL, |url| or the homepage will be used instead. When | 55 // tabstrip. If NULL, |url| or the homepage will be used instead. When |
| 56 // non-NULL, Navigate() assumes it has already been navigated to its | 56 // non-NULL, Navigate() assumes it has already been navigated to its |
| 57 // intended destination and will not load any URL in it (i.e. |url| is | 57 // intended destination and will not load any URL in it (i.e. |url| is |
| 58 // ignored). | 58 // ignored). |
| 59 // Default is NULL. | 59 // Default is NULL. |
| 60 // [out] The TabContents in which the navigation occurred or that was | 60 // [out] The TabContents in which the navigation occurred or that was |
| 61 // inserted. Guaranteed non-NULL except for note below: | 61 // inserted. Guaranteed non-NULL except for note below: |
| 62 // Note: If this field is set to NULL by the caller and Navigate() creates | 62 // Note: If this field is set to NULL by the caller and Navigate() creates |
| 63 // a new TabContents, this field will remain NULL and the TabContents | 63 // a new TabContents, this field will remain NULL and the TabContents |
| 64 // deleted if the TabContents it created is not added to a TabStripModel | 64 // deleted if the TabContents it created is not added to a TabStripModel |
| 65 // before Navigate() returns. | 65 // before Navigate() returns. |
| 66 TabContents* target_contents; | 66 TabContentsWrapper* target_contents; |
| 67 | 67 |
| 68 // [in] The TabContents that initiated the Navigate() request if such context | 68 // [in] The TabContents that initiated the Navigate() request if such context |
| 69 // is necessary. Default is NULL, i.e. no context. | 69 // is necessary. Default is NULL, i.e. no context. |
| 70 // [out] If NULL, this value will be set to the selected TabContents in the | 70 // [out] If NULL, this value will be set to the selected TabContents in the |
| 71 // originating browser prior to the operation performed by Navigate(). | 71 // originating browser prior to the operation performed by Navigate(). |
| 72 TabContents* source_contents; | 72 TabContentsWrapper* source_contents; |
| 73 | 73 |
| 74 // The disposition requested by the navigation source. Default is | 74 // The disposition requested by the navigation source. Default is |
| 75 // CURRENT_TAB. What follows is a set of coercions that happen to this value | 75 // CURRENT_TAB. What follows is a set of coercions that happen to this value |
| 76 // when other factors are at play: | 76 // when other factors are at play: |
| 77 // | 77 // |
| 78 // [in]: Condition: [out]: | 78 // [in]: Condition: [out]: |
| 79 // NEW_BACKGROUND_TAB target browser tabstrip is empty NEW_FOREGROUND_TAB | 79 // NEW_BACKGROUND_TAB target browser tabstrip is empty NEW_FOREGROUND_TAB |
| 80 // CURRENT_TAB " " " NEW_FOREGROUND_TAB | 80 // CURRENT_TAB " " " NEW_FOREGROUND_TAB |
| 81 // OFF_THE_RECORD target browser profile is incog. NEW_FOREGROUND_TAB | 81 // OFF_THE_RECORD target browser profile is incog. NEW_FOREGROUND_TAB |
| 82 // | 82 // |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 private: | 137 private: |
| 138 NavigateParams(); | 138 NavigateParams(); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 // Navigates according to the configuration specified in |params|. | 141 // Navigates according to the configuration specified in |params|. |
| 142 void Navigate(NavigateParams* params); | 142 void Navigate(NavigateParams* params); |
| 143 | 143 |
| 144 } // namespace browser | 144 } // namespace browser |
| 145 | 145 |
| 146 #endif // CHROME_BROWSER_UI_BROWSER_NAVIGATOR_H_ | 146 #endif // CHROME_BROWSER_UI_BROWSER_NAVIGATOR_H_ |
| OLD | NEW |