| 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 #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 "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
| 11 #include "chrome/browser/browser_url_handler.h" | 11 #include "chrome/browser/browser_url_handler.h" |
| 12 #include "chrome/browser/browser_window.h" | 12 #include "chrome/browser/browser_window.h" |
| 13 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/tabs/tab_strip_model.h" | 15 #include "chrome/browser/tabs/tab_strip_model.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/status_bubble.h" | 17 #include "chrome/browser/ui/status_bubble.h" |
| 17 #include "chrome/browser/ui/omnibox/location_bar.h" | 18 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 19 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" | 20 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 22 #include "content/browser/site_instance.h" | 23 #include "content/browser/site_instance.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // Find a compatible window and re-execute this command in it. Otherwise | 176 // Find a compatible window and re-execute this command in it. Otherwise |
| 176 // re-run with NEW_WINDOW. | 177 // re-run with NEW_WINDOW. |
| 177 if (profile) | 178 if (profile) |
| 178 return GetOrCreateBrowser(profile); | 179 return GetOrCreateBrowser(profile); |
| 179 return NULL; | 180 return NULL; |
| 180 case NEW_POPUP: { | 181 case NEW_POPUP: { |
| 181 // Make a new popup window. Coerce app-style if |params->browser| or the | 182 // Make a new popup window. Coerce app-style if |params->browser| or the |
| 182 // |source| represents an app. | 183 // |source| represents an app. |
| 183 Browser::Type type = Browser::TYPE_POPUP; | 184 Browser::Type type = Browser::TYPE_POPUP; |
| 184 if ((params->browser && (params->browser->type() & Browser::TYPE_APP)) || | 185 if ((params->browser && (params->browser->type() & Browser::TYPE_APP)) || |
| 185 (params->source_contents && params->source_contents->is_app())) { | 186 (params->source_contents && |
| 187 params->source_contents->extension_tab_helper()->is_app())) { |
| 186 type = Browser::TYPE_APP_POPUP; | 188 type = Browser::TYPE_APP_POPUP; |
| 187 } | 189 } |
| 188 if (profile) { | 190 if (profile) { |
| 189 Browser* browser = new Browser(type, profile); | 191 Browser* browser = new Browser(type, profile); |
| 190 browser->set_override_bounds(params->window_bounds); | 192 browser->set_override_bounds(params->window_bounds); |
| 191 browser->InitBrowserWindow(); | 193 browser->InitBrowserWindow(); |
| 192 return browser; | 194 return browser; |
| 193 } | 195 } |
| 194 return NULL; | 196 return NULL; |
| 195 } | 197 } |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 params->target_contents = | 419 params->target_contents = |
| 418 Browser::TabContentsFactory( | 420 Browser::TabContentsFactory( |
| 419 params->browser->profile(), | 421 params->browser->profile(), |
| 420 GetSiteInstance(source_contents, params->browser->profile(), url), | 422 GetSiteInstance(source_contents, params->browser->profile(), url), |
| 421 MSG_ROUTING_NONE, | 423 MSG_ROUTING_NONE, |
| 422 source_contents, | 424 source_contents, |
| 423 NULL); | 425 NULL); |
| 424 // This function takes ownership of |params->target_contents| until it | 426 // This function takes ownership of |params->target_contents| until it |
| 425 // is added to a TabStripModel. | 427 // is added to a TabStripModel. |
| 426 target_contents_owner.TakeOwnership(); | 428 target_contents_owner.TakeOwnership(); |
| 427 params->target_contents->SetExtensionAppById(params->extension_app_id); | 429 params->target_contents->extension_tab_helper()-> |
| 430 SetExtensionAppById(params->extension_app_id); |
| 428 // TODO(sky): figure out why this is needed. Without it we seem to get | 431 // TODO(sky): figure out why this is needed. Without it we seem to get |
| 429 // failures in startup tests. | 432 // failures in startup tests. |
| 430 // By default, content believes it is not hidden. When adding contents | 433 // By default, content believes it is not hidden. When adding contents |
| 431 // in the background, tell it that it's hidden. | 434 // in the background, tell it that it's hidden. |
| 432 if ((params->tabstrip_add_types & TabStripModel::ADD_SELECTED) == 0) { | 435 if ((params->tabstrip_add_types & TabStripModel::ADD_SELECTED) == 0) { |
| 433 // TabStripModel::AddTabContents invokes HideContents if not foreground. | 436 // TabStripModel::AddTabContents invokes HideContents if not foreground. |
| 434 params->target_contents->tab_contents()->WasHidden(); | 437 params->target_contents->tab_contents()->WasHidden(); |
| 435 } | 438 } |
| 436 } else { | 439 } else { |
| 437 // ... otherwise if we're loading in the current tab, the target is the | 440 // ... otherwise if we're loading in the current tab, the target is the |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 params->url, params->referrer, params->transition); | 489 params->url, params->referrer, params->transition); |
| 487 } | 490 } |
| 488 | 491 |
| 489 // If the singleton tab isn't already selected, select it. | 492 // If the singleton tab isn't already selected, select it. |
| 490 if (params->source_contents != params->target_contents) | 493 if (params->source_contents != params->target_contents) |
| 491 params->browser->SelectTabContentsAt(singleton_index, user_initiated); | 494 params->browser->SelectTabContentsAt(singleton_index, user_initiated); |
| 492 } | 495 } |
| 493 } | 496 } |
| 494 | 497 |
| 495 } // namespace browser | 498 } // namespace browser |
| OLD | NEW |