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_BROWSER_NAVIGATOR_H_ | 5 #ifndef CHROME_BROWSER_BROWSER_NAVIGATOR_H_ |
6 #define CHROME_BROWSER_BROWSER_NAVIGATOR_H_ | 6 #define CHROME_BROWSER_BROWSER_NAVIGATOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
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, TabContents* a_target_contents); |
48 ~NavigateParams(); | 48 ~NavigateParams(); |
49 | 49 |
50 // The URL/referrer to be loaded. Can be empty if |contents| is specified | 50 // The URL/referrer to be loaded. Ignored if |target_contents| is non-NULL. |
51 // non-NULL. | |
52 GURL url; | 51 GURL url; |
53 GURL referrer; | 52 GURL referrer; |
54 | 53 |
55 // [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 |
56 // tabstrip. If NULL, |url| or the homepage will be used instead. | 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 |
| 57 // intended destination and will not load any URL in it (i.e. |url| is |
| 58 // ignored). |
57 // Default is NULL. | 59 // Default is NULL. |
58 // [out] The TabContents in which the navigation occurred or that was | 60 // [out] The TabContents in which the navigation occurred or that was |
59 // inserted. Guaranteed non-NULL except for note below: | 61 // inserted. Guaranteed non-NULL except for note below: |
60 // 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 |
61 // a new TabContents, this field will remain NULL and the TabContents | 63 // a new TabContents, this field will remain NULL and the TabContents |
62 // 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 |
63 // before Navigate() returns. | 65 // before Navigate() returns. |
64 TabContents* target_contents; | 66 TabContents* target_contents; |
65 | 67 |
66 // [in] The TabContents that initiated the Navigate() request if such context | 68 // [in] The TabContents that initiated the Navigate() request if such context |
67 // is necessary. Default is NULL, i.e. no context. | 69 // is necessary. Default is NULL, i.e. no context. |
68 // [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 |
69 // originating browser prior to the operation performed by Navigate(). | 71 // originating browser prior to the operation performed by Navigate(). |
70 TabContents* source_contents; | 72 TabContents* source_contents; |
71 | 73 |
72 // The disposition requested by the navigation source. Default is | 74 // The disposition requested by the navigation source. Default is |
73 // CURRENT_TAB. | 75 // CURRENT_TAB. What follows is a set of coercions that happen to this value |
| 76 // when other factors are at play: |
| 77 // |
| 78 // [in]: Condition: [out]: |
| 79 // NEW_BACKGROUND_TAB target browser tabstrip is empty NEW_FOREGROUND_TAB |
| 80 // CURRENT_TAB " " " NEW_FOREGROUND_TAB |
| 81 // OFF_THE_RECORD target browser profile is incog. NEW_FOREGROUND_TAB |
| 82 // |
| 83 // If disposition is NEW_WINDOW or NEW_POPUP, |show_window| is set to true |
| 84 // automatically. |
| 85 // If disposition is NEW_BACKGROUND_TAB, TabStripModel::ADD_SELECTED is |
| 86 // removed from |tabstrip_add_types| automatically. |
74 WindowOpenDisposition disposition; | 87 WindowOpenDisposition disposition; |
75 | 88 |
76 // The transition type of the navigation. Default is PageTransition::LINK | 89 // The transition type of the navigation. Default is PageTransition::LINK |
77 // when target_contents is specified in the constructor. | 90 // when target_contents is specified in the constructor. |
78 PageTransition::Type transition; | 91 PageTransition::Type transition; |
79 | 92 |
80 // The index the caller would like the tab to be positioned at in the | 93 // The index the caller would like the tab to be positioned at in the |
81 // TabStrip. The actual index will be determined by the TabHandler in | 94 // TabStrip. The actual index will be determined by the TabHandler in |
82 // accordance with |add_types|. Defaults to -1 (allows the TabHandler to | 95 // accordance with |add_types|. Defaults to -1 (allows the TabHandler to |
83 // decide). | 96 // decide). |
84 int tabstrip_index; | 97 int tabstrip_index; |
85 | 98 |
86 // A bitmask of values defined in TabStripModel::AddTabTypes. Helps | 99 // A bitmask of values defined in TabStripModel::AddTabTypes. Helps |
87 // determine where to insert a new tab and whether or not it should be | 100 // determine where to insert a new tab and whether or not it should be |
88 // selected, among other properties. Default is ADD_SELECTED. | 101 // selected, among other properties. Default is ADD_SELECTED. |
89 int tabstrip_add_types; | 102 int tabstrip_add_types; |
90 | 103 |
91 // If non-empty, the new tab is an app tab. | 104 // If non-empty, the new tab is an app tab. |
92 std::string extension_app_id; | 105 std::string extension_app_id; |
93 | 106 |
94 // If non-empty, specifies the desired initial position and size of the | 107 // If non-empty, specifies the desired initial position and size of the |
95 // window if |disposition| == NEW_POPUP. | 108 // window if |disposition| == NEW_POPUP. |
96 // TODO(beng): Figure out if this can be used to create Browser windows | 109 // TODO(beng): Figure out if this can be used to create Browser windows |
97 // for other callsites that use set_override_bounds, or | 110 // for other callsites that use set_override_bounds, or |
98 // remove this comment. | 111 // remove this comment. |
99 gfx::Rect window_bounds; | 112 gfx::Rect window_bounds; |
100 | 113 |
101 // True if the target window should be made visible at the end of the call | 114 // True if the target window should be made visible at the end of the call |
102 // to Navigate(). Default is false. | 115 // to Navigate(). This activates the window if it was already visible. |
| 116 // Default is false. |
103 bool show_window; | 117 bool show_window; |
104 | 118 |
105 // [in] Specifies a Browser object where the navigation could occur or the | 119 // [in] Specifies a Browser object where the navigation could occur or the |
106 // tab could be added. Navigate() is not obliged to use this Browser if | 120 // tab could be added. Navigate() is not obliged to use this Browser if |
107 // it is not compatible with the operation being performed. Cannot be | 121 // it is not compatible with the operation being performed. Cannot be |
108 // NULL since Navigate() uses this Browser's Profile. | 122 // NULL since Navigate() uses this Browser's Profile. |
109 // [out] Specifies the Browser object where the navigation occurred or the | 123 // [out] Specifies the Browser object where the navigation occurred or the |
110 // tab was added. Guaranteed non-NULL unless the disposition did not | 124 // tab was added. Guaranteed non-NULL unless the disposition did not |
111 // require a navigation, in which case this is set to NULL | 125 // require a navigation, in which case this is set to NULL |
112 // (SUPPRESS_OPEN, SAVE_TO_DISK, IGNORE_ACTION). | 126 // (SUPPRESS_OPEN, SAVE_TO_DISK, IGNORE_ACTION). |
113 // Note: If |show_window| is set to false and a new Browser is created by | 127 // Note: If |show_window| is set to false and a new Browser is created by |
114 // Navigate(), the caller is responsible for showing it so that its | 128 // Navigate(), the caller is responsible for showing it so that its |
115 // window can assume responsibility for the Browser's lifetime (Browser | 129 // window can assume responsibility for the Browser's lifetime (Browser |
116 // objects are deleted when the user closes a visible browser window). | 130 // objects are deleted when the user closes a visible browser window). |
117 Browser* browser; | 131 Browser* browser; |
118 | 132 |
119 private: | 133 private: |
120 NavigateParams(); | 134 NavigateParams(); |
121 }; | 135 }; |
122 | 136 |
123 // Navigates according to the configuration specified in |params|. | 137 // Navigates according to the configuration specified in |params|. |
124 void Navigate(NavigateParams* params); | 138 void Navigate(NavigateParams* params); |
125 | 139 |
126 } // namespace browser | 140 } // namespace browser |
127 | 141 |
128 #endif // CHROME_BROWSER_BROWSER_NAVIGATOR_H_ | 142 #endif // CHROME_BROWSER_BROWSER_NAVIGATOR_H_ |
129 | 143 |
OLD | NEW |