OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "content/public/browser/global_request_id.h" | 10 #include "content/public/browser/global_request_id.h" |
11 #include "content/public/common/page_transition_types.h" | 11 #include "content/public/common/page_transition_types.h" |
12 #include "content/public/common/referrer.h" | 12 #include "content/public/common/referrer.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
15 #include "webkit/glue/window_open_disposition.h" | 15 #include "webkit/glue/window_open_disposition.h" |
16 | 16 |
17 class Browser; | 17 class Browser; |
| 18 class Profile; |
18 class TabContents; | 19 class TabContents; |
19 | 20 |
20 namespace chrome { | 21 namespace chrome { |
21 | 22 |
22 // Parameters that tell Navigate() what to do. | 23 // Parameters that tell Navigate() what to do. |
23 // | 24 // |
24 // Some basic examples: | 25 // Some basic examples: |
25 // | 26 // |
26 // Simple Navigate to URL in current tab: | 27 // Simple Navigate to URL in current tab: |
27 // chrome::NavigateParams params(browser, GURL("http://www.google.com/"), | 28 // chrome::NavigateParams params(browser, GURL("http://www.google.com/"), |
(...skipping 11 matching lines...) Expand all Loading... |
39 // params.source_contents = source_contents; | 40 // params.source_contents = source_contents; |
40 // chrome::Navigate(¶ms); | 41 // chrome::Navigate(¶ms); |
41 // | 42 // |
42 // See browser_navigator_browsertest.cc for more examples. | 43 // See browser_navigator_browsertest.cc for more examples. |
43 // | 44 // |
44 struct NavigateParams { | 45 struct NavigateParams { |
45 NavigateParams(Browser* browser, | 46 NavigateParams(Browser* browser, |
46 const GURL& a_url, | 47 const GURL& a_url, |
47 content::PageTransition a_transition); | 48 content::PageTransition a_transition); |
48 NavigateParams(Browser* browser, TabContents* a_target_contents); | 49 NavigateParams(Browser* browser, TabContents* a_target_contents); |
| 50 NavigateParams(Profile* profile, |
| 51 const GURL& a_url, |
| 52 content::PageTransition a_transition); |
49 ~NavigateParams(); | 53 ~NavigateParams(); |
50 | 54 |
51 // The URL/referrer to be loaded. Ignored if |target_contents| is non-NULL. | 55 // The URL/referrer to be loaded. Ignored if |target_contents| is non-NULL. |
52 GURL url; | 56 GURL url; |
53 content::Referrer referrer; | 57 content::Referrer referrer; |
54 | 58 |
55 // [in] A TabContents to be navigated or inserted into the target | 59 // [in] A TabContents to be navigated or inserted into the target |
56 // Browser's tabstrip. If NULL, |url| or the homepage will be used | 60 // Browser's tabstrip. If NULL, |url| or the homepage will be used |
57 // instead. When non-NULL, Navigate() assumes it has already been | 61 // instead. When non-NULL, Navigate() assumes it has already been |
58 // navigated to its intended destination and will not load any URL in it | 62 // navigated to its intended destination and will not load any URL in it |
(...skipping 30 matching lines...) Expand all Loading... |
89 // If disposition is one of NEW_WINDOW, NEW_POPUP, NEW_FOREGROUND_TAB or | 93 // If disposition is one of NEW_WINDOW, NEW_POPUP, NEW_FOREGROUND_TAB or |
90 // SINGLETON_TAB, then TabStripModel::ADD_ACTIVE is automatically added to | 94 // SINGLETON_TAB, then TabStripModel::ADD_ACTIVE is automatically added to |
91 // |tabstrip_add_types|. | 95 // |tabstrip_add_types|. |
92 WindowOpenDisposition disposition; | 96 WindowOpenDisposition disposition; |
93 | 97 |
94 // The transition type of the navigation. Default is | 98 // The transition type of the navigation. Default is |
95 // content::PAGE_TRANSITION_LINK when target_contents is specified in the | 99 // content::PAGE_TRANSITION_LINK when target_contents is specified in the |
96 // constructor. | 100 // constructor. |
97 content::PageTransition transition; | 101 content::PageTransition transition; |
98 | 102 |
99 // Whether this navigation was initiated by the renderer process. | 103 // Whether this navigation was initiated by the renderer process. Default is |
| 104 // false. |
100 bool is_renderer_initiated; | 105 bool is_renderer_initiated; |
101 | 106 |
102 // The index the caller would like the tab to be positioned at in the | 107 // The index the caller would like the tab to be positioned at in the |
103 // TabStrip. The actual index will be determined by the TabHandler in | 108 // TabStrip. The actual index will be determined by the TabHandler in |
104 // accordance with |add_types|. Defaults to -1 (allows the TabHandler to | 109 // accordance with |add_types|. Defaults to -1 (allows the TabHandler to |
105 // decide). | 110 // decide). |
106 int tabstrip_index; | 111 int tabstrip_index; |
107 | 112 |
108 // A bitmask of values defined in TabStripModel::AddTabTypes. Helps | 113 // A bitmask of values defined in TabStripModel::AddTabTypes. Helps |
109 // determine where to insert a new tab and whether or not it should be | 114 // determine where to insert a new tab and whether or not it should be |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // Two URLs with differing refs are same. | 164 // Two URLs with differing refs are same. |
160 IGNORE_REF, | 165 IGNORE_REF, |
161 // Two URLs with differing refs are different. | 166 // Two URLs with differing refs are different. |
162 RESPECT_REF, | 167 RESPECT_REF, |
163 }; | 168 }; |
164 // Default is IGNORE. | 169 // Default is IGNORE. |
165 RefBehavior ref_behavior; | 170 RefBehavior ref_behavior; |
166 | 171 |
167 // [in] Specifies a Browser object where the navigation could occur or the | 172 // [in] Specifies a Browser object where the navigation could occur or the |
168 // tab could be added. Navigate() is not obliged to use this Browser if | 173 // tab could be added. Navigate() is not obliged to use this Browser if |
169 // it is not compatible with the operation being performed. | 174 // it is not compatible with the operation being performed. This can be |
| 175 // NULL, in which case |initiating_profile| must be provided. |
170 // [out] Specifies the Browser object where the navigation occurred or the | 176 // [out] Specifies the Browser object where the navigation occurred or the |
171 // tab was added. Guaranteed non-NULL unless the disposition did not | 177 // tab was added. Guaranteed non-NULL unless the disposition did not |
172 // require a navigation, in which case this is set to NULL | 178 // require a navigation, in which case this is set to NULL |
173 // (SUPPRESS_OPEN, SAVE_TO_DISK, IGNORE_ACTION). | 179 // (SUPPRESS_OPEN, SAVE_TO_DISK, IGNORE_ACTION). |
174 // Note: If |show_window| is set to false and a new Browser is created by | 180 // Note: If |show_window| is set to false and a new Browser is created by |
175 // Navigate(), the caller is responsible for showing it so that its | 181 // Navigate(), the caller is responsible for showing it so that its |
176 // window can assume responsibility for the Browser's lifetime (Browser | 182 // window can assume responsibility for the Browser's lifetime (Browser |
177 // objects are deleted when the user closes a visible browser window). | 183 // objects are deleted when the user closes a visible browser window). |
178 Browser* browser; | 184 Browser* browser; |
179 | 185 |
| 186 // The profile that is initiating the navigation. If there is a non-NULL |
| 187 // browser passed in via |browser|, it's profile will be used instead. |
| 188 Profile* initiating_profile; |
| 189 |
180 // Refers to a navigation that was parked in the browser in order to be | 190 // Refers to a navigation that was parked in the browser in order to be |
181 // transferred to another RVH. Only used in case of a redirection of a request | 191 // transferred to another RVH. Only used in case of a redirection of a request |
182 // to a different site that created a new RVH. | 192 // to a different site that created a new RVH. |
183 content::GlobalRequestID transferred_global_request_id; | 193 content::GlobalRequestID transferred_global_request_id; |
184 | 194 |
185 private: | 195 private: |
186 NavigateParams(); | 196 NavigateParams(); |
187 }; | 197 }; |
188 | 198 |
189 // Navigates according to the configuration specified in |params|. | 199 // Navigates according to the configuration specified in |params|. |
190 void Navigate(NavigateParams* params); | 200 void Navigate(NavigateParams* params); |
191 | 201 |
192 // Returns true if the url is allowed to open in incognito window. | 202 // Returns true if the url is allowed to open in incognito window. |
193 bool IsURLAllowedInIncognito(const GURL& url); | 203 bool IsURLAllowedInIncognito(const GURL& url); |
194 | 204 |
195 } // namespace chrome | 205 } // namespace chrome |
196 | 206 |
197 #endif // CHROME_BROWSER_UI_BROWSER_NAVIGATOR_H_ | 207 #endif // CHROME_BROWSER_UI_BROWSER_NAVIGATOR_H_ |
OLD | NEW |