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 #include "chrome/browser/ui/browser_navigator.h" | 5 #include "chrome/browser/ui/browser_navigator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 bool AdjustNavigateParamsForURL(chrome::NavigateParams* params) { | 95 bool AdjustNavigateParamsForURL(chrome::NavigateParams* params) { |
96 if (params->target_contents != NULL || | 96 if (params->target_contents != NULL || |
97 chrome::IsURLAllowedInIncognito(params->url, | 97 chrome::IsURLAllowedInIncognito(params->url, |
98 params->initiating_profile) || | 98 params->initiating_profile) || |
99 params->initiating_profile->IsGuestSession()) { | 99 params->initiating_profile->IsGuestSession()) { |
100 return true; | 100 return true; |
101 } | 101 } |
102 | 102 |
103 Profile* profile = params->initiating_profile; | 103 Profile* profile = params->initiating_profile; |
104 | 104 |
105 if (profile->IsOffTheRecord() || params->disposition == OFF_THE_RECORD) { | 105 if (profile->IsOffTheRecord() || |
| 106 params->disposition == WindowOpenDisposition::OFF_THE_RECORD) { |
106 profile = profile->GetOriginalProfile(); | 107 profile = profile->GetOriginalProfile(); |
107 | 108 |
108 // If incognito is forced, we punt. | 109 // If incognito is forced, we punt. |
109 PrefService* prefs = profile->GetPrefs(); | 110 PrefService* prefs = profile->GetPrefs(); |
110 if (prefs && IncognitoModePrefs::GetAvailability(prefs) == | 111 if (prefs && IncognitoModePrefs::GetAvailability(prefs) == |
111 IncognitoModePrefs::FORCED) { | 112 IncognitoModePrefs::FORCED) { |
112 return false; | 113 return false; |
113 } | 114 } |
114 | 115 |
115 params->disposition = SINGLETON_TAB; | 116 params->disposition = WindowOpenDisposition::SINGLETON_TAB; |
116 params->browser = GetOrCreateBrowser(profile); | 117 params->browser = GetOrCreateBrowser(profile); |
117 params->window_action = chrome::NavigateParams::SHOW_WINDOW; | 118 params->window_action = chrome::NavigateParams::SHOW_WINDOW; |
118 } | 119 } |
119 | 120 |
120 return true; | 121 return true; |
121 } | 122 } |
122 | 123 |
123 // Returns a Browser that can host the navigation or tab addition specified in | 124 // Returns a Browser that can host the navigation or tab addition specified in |
124 // |params|. This might just return the same Browser specified in |params|, or | 125 // |params|. This might just return the same Browser specified in |params|, or |
125 // some other if that Browser is deemed incompatible. | 126 // some other if that Browser is deemed incompatible. |
126 Browser* GetBrowserForDisposition(chrome::NavigateParams* params) { | 127 Browser* GetBrowserForDisposition(chrome::NavigateParams* params) { |
127 // If no source WebContents was specified, we use the selected one from | 128 // If no source WebContents was specified, we use the selected one from |
128 // the target browser. This must happen first, before | 129 // the target browser. This must happen first, before |
129 // GetBrowserForDisposition() has a chance to replace |params->browser| with | 130 // GetBrowserForDisposition() has a chance to replace |params->browser| with |
130 // another one. | 131 // another one. |
131 if (!params->source_contents && params->browser) { | 132 if (!params->source_contents && params->browser) { |
132 params->source_contents = | 133 params->source_contents = |
133 params->browser->tab_strip_model()->GetActiveWebContents(); | 134 params->browser->tab_strip_model()->GetActiveWebContents(); |
134 } | 135 } |
135 | 136 |
136 Profile* profile = params->initiating_profile; | 137 Profile* profile = params->initiating_profile; |
137 | 138 |
138 switch (params->disposition) { | 139 switch (params->disposition) { |
139 case CURRENT_TAB: | 140 case WindowOpenDisposition::CURRENT_TAB: |
140 if (params->browser) | 141 if (params->browser) |
141 return params->browser; | 142 return params->browser; |
142 // Find a compatible window and re-execute this command in it. Otherwise | 143 // Find a compatible window and re-execute this command in it. Otherwise |
143 // re-run with NEW_WINDOW. | 144 // re-run with NEW_WINDOW. |
144 return GetOrCreateBrowser(profile); | 145 return GetOrCreateBrowser(profile); |
145 case SINGLETON_TAB: | 146 case WindowOpenDisposition::SINGLETON_TAB: |
146 case NEW_FOREGROUND_TAB: | 147 case WindowOpenDisposition::NEW_FOREGROUND_TAB: |
147 case NEW_BACKGROUND_TAB: | 148 case WindowOpenDisposition::NEW_BACKGROUND_TAB: |
148 // See if we can open the tab in the window this navigator is bound to. | 149 // See if we can open the tab in the window this navigator is bound to. |
149 if (params->browser && WindowCanOpenTabs(params->browser)) | 150 if (params->browser && WindowCanOpenTabs(params->browser)) |
150 return params->browser; | 151 return params->browser; |
151 // Find a compatible window and re-execute this command in it. Otherwise | 152 // Find a compatible window and re-execute this command in it. Otherwise |
152 // re-run with NEW_WINDOW. | 153 // re-run with NEW_WINDOW. |
153 return GetOrCreateBrowser(profile); | 154 return GetOrCreateBrowser(profile); |
154 case NEW_POPUP: { | 155 case WindowOpenDisposition::NEW_POPUP: { |
155 // Make a new popup window. | 156 // Make a new popup window. |
156 // Coerce app-style if |source| represents an app. | 157 // Coerce app-style if |source| represents an app. |
157 std::string app_name; | 158 std::string app_name; |
158 #if defined(ENABLE_EXTENSIONS) | 159 #if defined(ENABLE_EXTENSIONS) |
159 if (!params->extension_app_id.empty()) { | 160 if (!params->extension_app_id.empty()) { |
160 app_name = web_app::GenerateApplicationNameFromExtensionId( | 161 app_name = web_app::GenerateApplicationNameFromExtensionId( |
161 params->extension_app_id); | 162 params->extension_app_id); |
162 } else if (params->browser && !params->browser->app_name().empty()) { | 163 } else if (params->browser && !params->browser->app_name().empty()) { |
163 app_name = params->browser->app_name(); | 164 app_name = params->browser->app_name(); |
164 } else if (params->source_contents) { | 165 } else if (params->source_contents) { |
165 extensions::TabHelper* extensions_tab_helper = | 166 extensions::TabHelper* extensions_tab_helper = |
166 extensions::TabHelper::FromWebContents(params->source_contents); | 167 extensions::TabHelper::FromWebContents(params->source_contents); |
167 if (extensions_tab_helper && extensions_tab_helper->is_app()) { | 168 if (extensions_tab_helper && extensions_tab_helper->is_app()) { |
168 app_name = web_app::GenerateApplicationNameFromExtensionId( | 169 app_name = web_app::GenerateApplicationNameFromExtensionId( |
169 extensions_tab_helper->extension_app()->id()); | 170 extensions_tab_helper->extension_app()->id()); |
170 } | 171 } |
171 } | 172 } |
172 #endif | 173 #endif |
173 if (app_name.empty()) { | 174 if (app_name.empty()) { |
174 Browser::CreateParams browser_params(Browser::TYPE_POPUP, profile); | 175 Browser::CreateParams browser_params(Browser::TYPE_POPUP, profile); |
175 browser_params.trusted_source = params->trusted_source; | 176 browser_params.trusted_source = params->trusted_source; |
176 browser_params.initial_bounds = params->window_bounds; | 177 browser_params.initial_bounds = params->window_bounds; |
177 return new Browser(browser_params); | 178 return new Browser(browser_params); |
178 } | 179 } |
179 | 180 |
180 return new Browser(Browser::CreateParams::CreateForApp( | 181 return new Browser(Browser::CreateParams::CreateForApp( |
181 app_name, params->trusted_source, params->window_bounds, profile)); | 182 app_name, params->trusted_source, params->window_bounds, profile)); |
182 } | 183 } |
183 case NEW_WINDOW: { | 184 case WindowOpenDisposition::NEW_WINDOW: { |
184 // Make a new normal browser window. | 185 // Make a new normal browser window. |
185 return new Browser(Browser::CreateParams(profile)); | 186 return new Browser(Browser::CreateParams(profile)); |
186 } | 187 } |
187 case OFF_THE_RECORD: | 188 case WindowOpenDisposition::OFF_THE_RECORD: |
188 // Make or find an incognito window. | 189 // Make or find an incognito window. |
189 return GetOrCreateBrowser(profile->GetOffTheRecordProfile()); | 190 return GetOrCreateBrowser(profile->GetOffTheRecordProfile()); |
190 // The following types result in no navigation. | 191 // The following types result in no navigation. |
191 case SAVE_TO_DISK: | 192 case WindowOpenDisposition::SAVE_TO_DISK: |
192 case IGNORE_ACTION: | 193 case WindowOpenDisposition::IGNORE_ACTION: |
193 return NULL; | 194 return NULL; |
194 default: | 195 default: |
195 NOTREACHED(); | 196 NOTREACHED(); |
196 } | 197 } |
197 return NULL; | 198 return NULL; |
198 } | 199 } |
199 | 200 |
200 // Fix disposition and other parameter values depending on prevailing | 201 // Fix disposition and other parameter values depending on prevailing |
201 // conditions. | 202 // conditions. |
202 void NormalizeDisposition(chrome::NavigateParams* params) { | 203 void NormalizeDisposition(chrome::NavigateParams* params) { |
203 // Calculate the WindowOpenDisposition if necessary. | 204 // Calculate the WindowOpenDisposition if necessary. |
204 if (params->browser->tab_strip_model()->empty() && | 205 if (params->browser->tab_strip_model()->empty() && |
205 (params->disposition == NEW_BACKGROUND_TAB || | 206 (params->disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB || |
206 params->disposition == CURRENT_TAB || | 207 params->disposition == WindowOpenDisposition::CURRENT_TAB || |
207 params->disposition == SINGLETON_TAB)) { | 208 params->disposition == WindowOpenDisposition::SINGLETON_TAB)) { |
208 params->disposition = NEW_FOREGROUND_TAB; | 209 params->disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
209 } | 210 } |
210 if (params->browser->profile()->IsOffTheRecord() && | 211 if (params->browser->profile()->IsOffTheRecord() && |
211 params->disposition == OFF_THE_RECORD) { | 212 params->disposition == WindowOpenDisposition::OFF_THE_RECORD) { |
212 params->disposition = NEW_FOREGROUND_TAB; | 213 params->disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
213 } | 214 } |
214 if (!params->source_contents && params->disposition == CURRENT_TAB) | 215 if (!params->source_contents && |
215 params->disposition = NEW_FOREGROUND_TAB; | 216 params->disposition == WindowOpenDisposition::CURRENT_TAB) |
| 217 params->disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
216 | 218 |
217 switch (params->disposition) { | 219 switch (params->disposition) { |
218 case NEW_BACKGROUND_TAB: | 220 case WindowOpenDisposition::NEW_BACKGROUND_TAB: |
219 // Disposition trumps add types. ADD_ACTIVE is a default, so we need to | 221 // Disposition trumps add types. ADD_ACTIVE is a default, so we need to |
220 // remove it if disposition implies the tab is going to open in the | 222 // remove it if disposition implies the tab is going to open in the |
221 // background. | 223 // background. |
222 params->tabstrip_add_types &= ~TabStripModel::ADD_ACTIVE; | 224 params->tabstrip_add_types &= ~TabStripModel::ADD_ACTIVE; |
223 break; | 225 break; |
224 | 226 |
225 case NEW_WINDOW: | 227 case WindowOpenDisposition::NEW_WINDOW: |
226 case NEW_POPUP: | 228 case WindowOpenDisposition::NEW_POPUP: { |
227 // Code that wants to open a new window typically expects it to be shown | 229 // Code that wants to open a new window typically expects it to be shown |
228 // automatically. | 230 // automatically. |
229 if (params->window_action == chrome::NavigateParams::NO_ACTION) | 231 if (params->window_action == chrome::NavigateParams::NO_ACTION) |
230 params->window_action = chrome::NavigateParams::SHOW_WINDOW; | 232 params->window_action = chrome::NavigateParams::SHOW_WINDOW; |
231 // Fall-through. | 233 // Fall-through. |
232 case NEW_FOREGROUND_TAB: | 234 } |
233 case SINGLETON_TAB: | 235 case WindowOpenDisposition::NEW_FOREGROUND_TAB: |
| 236 case WindowOpenDisposition::SINGLETON_TAB: |
234 params->tabstrip_add_types |= TabStripModel::ADD_ACTIVE; | 237 params->tabstrip_add_types |= TabStripModel::ADD_ACTIVE; |
235 break; | 238 break; |
236 | 239 |
237 default: | 240 default: |
238 break; | 241 break; |
239 } | 242 } |
240 } | 243 } |
241 | 244 |
242 // Obtain the profile used by the code that originated the Navigate() request. | 245 // Obtain the profile used by the code that originated the Navigate() request. |
243 Profile* GetSourceProfile(chrome::NavigateParams* params) { | 246 Profile* GetSourceProfile(chrome::NavigateParams* params) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 explicit ScopedBrowserShower(chrome::NavigateParams* params) | 282 explicit ScopedBrowserShower(chrome::NavigateParams* params) |
280 : params_(params) { | 283 : params_(params) { |
281 } | 284 } |
282 ~ScopedBrowserShower() { | 285 ~ScopedBrowserShower() { |
283 if (params_->window_action == | 286 if (params_->window_action == |
284 chrome::NavigateParams::SHOW_WINDOW_INACTIVE) { | 287 chrome::NavigateParams::SHOW_WINDOW_INACTIVE) { |
285 params_->browser->window()->ShowInactive(); | 288 params_->browser->window()->ShowInactive(); |
286 } else if (params_->window_action == chrome::NavigateParams::SHOW_WINDOW) { | 289 } else if (params_->window_action == chrome::NavigateParams::SHOW_WINDOW) { |
287 params_->browser->window()->Show(); | 290 params_->browser->window()->Show(); |
288 // If a user gesture opened a popup window, focus the contents. | 291 // If a user gesture opened a popup window, focus the contents. |
289 if (params_->user_gesture && params_->disposition == NEW_POPUP && | 292 if (params_->user_gesture && |
| 293 params_->disposition == WindowOpenDisposition::NEW_POPUP && |
290 params_->target_contents) { | 294 params_->target_contents) { |
291 params_->target_contents->Focus(); | 295 params_->target_contents->Focus(); |
292 } | 296 } |
293 } | 297 } |
294 } | 298 } |
295 | 299 |
296 private: | 300 private: |
297 chrome::NavigateParams* params_; | 301 chrome::NavigateParams* params_; |
298 DISALLOW_COPY_AND_ASSIGN(ScopedBrowserShower); | 302 DISALLOW_COPY_AND_ASSIGN(ScopedBrowserShower); |
299 }; | 303 }; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 params.browser->profile(), | 342 params.browser->profile(), |
339 params.source_site_instance | 343 params.source_site_instance |
340 ? params.source_site_instance | 344 ? params.source_site_instance |
341 : tab_util::GetSiteInstanceForNewTab(params.browser->profile(), url)); | 345 : tab_util::GetSiteInstanceForNewTab(params.browser->profile(), url)); |
342 create_params.main_frame_name = params.frame_name; | 346 create_params.main_frame_name = params.frame_name; |
343 if (params.source_contents) { | 347 if (params.source_contents) { |
344 create_params.initial_size = | 348 create_params.initial_size = |
345 params.source_contents->GetContainerBounds().size(); | 349 params.source_contents->GetContainerBounds().size(); |
346 create_params.created_with_opener = params.created_with_opener; | 350 create_params.created_with_opener = params.created_with_opener; |
347 } | 351 } |
348 if (params.disposition == NEW_BACKGROUND_TAB) | 352 if (params.disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB) |
349 create_params.initially_hidden = true; | 353 create_params.initially_hidden = true; |
350 | 354 |
351 #if defined(USE_AURA) | 355 #if defined(USE_AURA) |
352 if (params.browser->window() && | 356 if (params.browser->window() && |
353 params.browser->window()->GetNativeWindow()) { | 357 params.browser->window()->GetNativeWindow()) { |
354 create_params.context = | 358 create_params.context = |
355 params.browser->window()->GetNativeWindow(); | 359 params.browser->window()->GetNativeWindow(); |
356 } | 360 } |
357 #endif | 361 #endif |
358 | 362 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 #if defined(ENABLE_EXTENSIONS) | 407 #if defined(ENABLE_EXTENSIONS) |
404 const extensions::Extension* extension = | 408 const extensions::Extension* extension = |
405 extensions::ExtensionRegistry::Get(params->initiating_profile)-> | 409 extensions::ExtensionRegistry::Get(params->initiating_profile)-> |
406 enabled_extensions().GetExtensionOrAppByURL(params->url); | 410 enabled_extensions().GetExtensionOrAppByURL(params->url); |
407 // Platform apps cannot navigate. Block the request. | 411 // Platform apps cannot navigate. Block the request. |
408 if (extension && extension->is_platform_app()) | 412 if (extension && extension->is_platform_app()) |
409 params->url = GURL(chrome::kExtensionInvalidRequestURL); | 413 params->url = GURL(chrome::kExtensionInvalidRequestURL); |
410 #endif | 414 #endif |
411 | 415 |
412 // The browser window may want to adjust the disposition. | 416 // The browser window may want to adjust the disposition. |
413 if (params->disposition == NEW_POPUP && | 417 if (params->disposition == WindowOpenDisposition::NEW_POPUP && |
414 source_browser && | 418 source_browser && source_browser->window()) { |
415 source_browser->window()) { | |
416 params->disposition = | 419 params->disposition = |
417 source_browser->window()->GetDispositionForPopupBounds( | 420 source_browser->window()->GetDispositionForPopupBounds( |
418 params->window_bounds); | 421 params->window_bounds); |
419 } | 422 } |
420 | 423 |
421 params->browser = GetBrowserForDisposition(params); | 424 params->browser = GetBrowserForDisposition(params); |
422 if (!params->browser) | 425 if (!params->browser) |
423 return; | 426 return; |
424 | 427 |
425 #if defined(USE_ASH) | 428 #if defined(USE_ASH) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 469 |
467 // If a new window has been created, it needs to be shown. | 470 // If a new window has been created, it needs to be shown. |
468 if (params->window_action == NavigateParams::NO_ACTION && | 471 if (params->window_action == NavigateParams::NO_ACTION && |
469 source_browser != params->browser && | 472 source_browser != params->browser && |
470 params->browser->tab_strip_model()->empty()) { | 473 params->browser->tab_strip_model()->empty()) { |
471 params->window_action = NavigateParams::SHOW_WINDOW; | 474 params->window_action = NavigateParams::SHOW_WINDOW; |
472 } | 475 } |
473 | 476 |
474 // If we create a popup window from a non user-gesture, don't activate it. | 477 // If we create a popup window from a non user-gesture, don't activate it. |
475 if (params->window_action == NavigateParams::SHOW_WINDOW && | 478 if (params->window_action == NavigateParams::SHOW_WINDOW && |
476 params->disposition == NEW_POPUP && | 479 params->disposition == WindowOpenDisposition::NEW_POPUP && |
477 params->user_gesture == false) { | 480 params->user_gesture == false) { |
478 params->window_action = NavigateParams::SHOW_WINDOW_INACTIVE; | 481 params->window_action = NavigateParams::SHOW_WINDOW_INACTIVE; |
479 } | 482 } |
480 | 483 |
481 // Determine if the navigation was user initiated. If it was, we need to | 484 // Determine if the navigation was user initiated. If it was, we need to |
482 // inform the target WebContents, and we may need to update the UI. | 485 // inform the target WebContents, and we may need to update the UI. |
483 bool user_initiated = | 486 bool user_initiated = |
484 params->transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR || | 487 params->transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR || |
485 ui::PageTransitionCoreTypeIs(params->transition, | 488 ui::PageTransitionCoreTypeIs(params->transition, |
486 ui::PAGE_TRANSITION_TYPED) || | 489 ui::PAGE_TRANSITION_TYPED) || |
(...skipping 12 matching lines...) Expand all Loading... |
499 int singleton_index = chrome::GetIndexOfSingletonTab(params); | 502 int singleton_index = chrome::GetIndexOfSingletonTab(params); |
500 | 503 |
501 // Did we use a prerender? | 504 // Did we use a prerender? |
502 bool swapped_in_prerender = false; | 505 bool swapped_in_prerender = false; |
503 | 506 |
504 // If no target WebContents was specified, we need to construct one if | 507 // If no target WebContents was specified, we need to construct one if |
505 // we are supposed to target a new tab; unless it's a singleton that already | 508 // we are supposed to target a new tab; unless it's a singleton that already |
506 // exists. | 509 // exists. |
507 if (!params->target_contents && singleton_index < 0) { | 510 if (!params->target_contents && singleton_index < 0) { |
508 DCHECK(!params->url.is_empty()); | 511 DCHECK(!params->url.is_empty()); |
509 if (params->disposition != CURRENT_TAB) { | 512 if (params->disposition != WindowOpenDisposition::CURRENT_TAB) { |
510 params->target_contents = CreateTargetContents(*params, params->url); | 513 params->target_contents = CreateTargetContents(*params, params->url); |
511 | 514 |
512 // This function takes ownership of |params->target_contents| until it | 515 // This function takes ownership of |params->target_contents| until it |
513 // is added to a TabStripModel. | 516 // is added to a TabStripModel. |
514 target_contents_owner.TakeOwnership(); | 517 target_contents_owner.TakeOwnership(); |
515 } else { | 518 } else { |
516 // ... otherwise if we're loading in the current tab, the target is the | 519 // ... otherwise if we're loading in the current tab, the target is the |
517 // same as the source. | 520 // same as the source. |
518 DCHECK(params->source_contents); | 521 DCHECK(params->source_contents); |
519 params->target_contents = params->source_contents; | 522 params->target_contents = params->source_contents; |
(...skipping 19 matching lines...) Expand all Loading... |
539 } else { | 542 } else { |
540 // |target_contents| was specified non-NULL, and so we assume it has already | 543 // |target_contents| was specified non-NULL, and so we assume it has already |
541 // been navigated appropriately. We need to do nothing more other than | 544 // been navigated appropriately. We need to do nothing more other than |
542 // add it to the appropriate tabstrip. | 545 // add it to the appropriate tabstrip. |
543 } | 546 } |
544 | 547 |
545 // If the user navigated from the omnibox, and the selected tab is going to | 548 // If the user navigated from the omnibox, and the selected tab is going to |
546 // lose focus, then make sure the focus for the source tab goes away from the | 549 // lose focus, then make sure the focus for the source tab goes away from the |
547 // omnibox. | 550 // omnibox. |
548 if (params->source_contents && | 551 if (params->source_contents && |
549 (params->disposition == NEW_FOREGROUND_TAB || | 552 (params->disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB || |
550 params->disposition == NEW_WINDOW) && | 553 params->disposition == WindowOpenDisposition::NEW_WINDOW) && |
551 (params->tabstrip_add_types & TabStripModel::ADD_INHERIT_OPENER)) | 554 (params->tabstrip_add_types & TabStripModel::ADD_INHERIT_OPENER)) |
552 params->source_contents->Focus(); | 555 params->source_contents->Focus(); |
553 | 556 |
554 if (params->source_contents == params->target_contents || | 557 if (params->source_contents == params->target_contents || |
555 (swapped_in_prerender && params->disposition == CURRENT_TAB)) { | 558 (swapped_in_prerender && |
| 559 params->disposition == WindowOpenDisposition::CURRENT_TAB)) { |
556 // The navigation occurred in the source tab. | 560 // The navigation occurred in the source tab. |
557 params->browser->UpdateUIForNavigationInTab( | 561 params->browser->UpdateUIForNavigationInTab( |
558 params->target_contents, params->transition, params->window_action, | 562 params->target_contents, params->transition, params->window_action, |
559 user_initiated); | 563 user_initiated); |
560 } else if (singleton_index == -1) { | 564 } else if (singleton_index == -1) { |
561 // If some non-default value is set for the index, we should tell the | 565 // If some non-default value is set for the index, we should tell the |
562 // TabStripModel to respect it. | 566 // TabStripModel to respect it. |
563 if (params->tabstrip_index != -1) | 567 if (params->tabstrip_index != -1) |
564 params->tabstrip_add_types |= TabStripModel::ADD_FORCE_INDEX; | 568 params->tabstrip_add_types |= TabStripModel::ADD_FORCE_INDEX; |
565 | 569 |
(...skipping 19 matching lines...) Expand all Loading... |
585 LoadURLInContents(target, params->url, params); | 589 LoadURLInContents(target, params->url, params); |
586 } | 590 } |
587 | 591 |
588 // If the singleton tab isn't already selected, select it. | 592 // If the singleton tab isn't already selected, select it. |
589 if (params->source_contents != params->target_contents) { | 593 if (params->source_contents != params->target_contents) { |
590 params->browser->tab_strip_model()->ActivateTabAt(singleton_index, | 594 params->browser->tab_strip_model()->ActivateTabAt(singleton_index, |
591 user_initiated); | 595 user_initiated); |
592 } | 596 } |
593 } | 597 } |
594 | 598 |
595 if (params->disposition != CURRENT_TAB) { | 599 if (params->disposition != WindowOpenDisposition::CURRENT_TAB) { |
596 content::NotificationService::current()->Notify( | 600 content::NotificationService::current()->Notify( |
597 chrome::NOTIFICATION_TAB_ADDED, | 601 chrome::NOTIFICATION_TAB_ADDED, |
598 content::Source<content::WebContentsDelegate>(params->browser), | 602 content::Source<content::WebContentsDelegate>(params->browser), |
599 content::Details<WebContents>(params->target_contents)); | 603 content::Details<WebContents>(params->target_contents)); |
600 } | 604 } |
601 } | 605 } |
602 | 606 |
603 bool IsURLAllowedInIncognito(const GURL& url, | 607 bool IsURLAllowedInIncognito(const GURL& url, |
604 content::BrowserContext* browser_context) { | 608 content::BrowserContext* browser_context) { |
605 if (url.scheme() == content::kViewSourceScheme) { | 609 if (url.scheme() == content::kViewSourceScheme) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 bool reverse_on_redirect = false; | 655 bool reverse_on_redirect = false; |
652 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 656 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
653 &rewritten_url, browser_context, &reverse_on_redirect); | 657 &rewritten_url, browser_context, &reverse_on_redirect); |
654 | 658 |
655 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 659 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
656 return !(rewritten_url.scheme() == content::kChromeUIScheme && | 660 return !(rewritten_url.scheme() == content::kChromeUIScheme && |
657 rewritten_url.host() == chrome::kChromeUIUberHost); | 661 rewritten_url.host() == chrome::kChromeUIUberHost); |
658 } | 662 } |
659 | 663 |
660 } // namespace chrome | 664 } // namespace chrome |
OLD | NEW |