Chromium Code Reviews| 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.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #endif // OS_WIN | 10 #endif // OS_WIN |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 DCHECK(extensions_service); | 610 DCHECK(extensions_service); |
| 611 | 611 |
| 612 ExtensionPrefs::LaunchType launch_type = | 612 ExtensionPrefs::LaunchType launch_type = |
| 613 extensions_service->extension_prefs()->GetLaunchType( | 613 extensions_service->extension_prefs()->GetLaunchType( |
| 614 extension->id(), ExtensionPrefs::LAUNCH_REGULAR); | 614 extension->id(), ExtensionPrefs::LAUNCH_REGULAR); |
| 615 UMA_HISTOGRAM_ENUMERATION("Extensions.AppTabLaunchType", launch_type, 100); | 615 UMA_HISTOGRAM_ENUMERATION("Extensions.AppTabLaunchType", launch_type, 100); |
| 616 int add_type = TabStripModel::ADD_SELECTED; | 616 int add_type = TabStripModel::ADD_SELECTED; |
| 617 if (launch_type == ExtensionPrefs::LAUNCH_PINNED) | 617 if (launch_type == ExtensionPrefs::LAUNCH_PINNED) |
| 618 add_type |= TabStripModel::ADD_PINNED; | 618 add_type |= TabStripModel::ADD_PINNED; |
| 619 | 619 |
| 620 // For extensions lacking launch urls, determine a reasonable fallback. | |
| 621 GURL extension_url = extension->GetFullLaunchURL(); | |
| 622 if (!extension_url.is_valid()) { | |
| 623 extension_url = extension->options_url(); | |
| 624 if (!extension_url.is_valid()) | |
| 625 extension_url = GURL("chrome://extensions/"); | |
|
Andrew T Wilson (Slow)
2011/01/22 01:32:14
You should use chrome::kChromeUIExtensionsURL here
The wrong rickcam account
2011/01/22 01:42:30
Done.
| |
| 626 } | |
| 627 | |
| 620 // TODO(erikkay): START_PAGE doesn't seem like the right transition in all | 628 // TODO(erikkay): START_PAGE doesn't seem like the right transition in all |
| 621 // cases. | 629 // cases. |
| 622 browser::NavigateParams params(browser, extension->GetFullLaunchURL(), | 630 browser::NavigateParams params(browser, extension_url, |
| 623 PageTransition::START_PAGE); | 631 PageTransition::START_PAGE); |
| 624 params.tabstrip_add_types = add_type; | 632 params.tabstrip_add_types = add_type; |
| 625 | 633 |
| 626 // Launch the application in the existing TabContents, if it was supplied. | 634 // Launch the application in the existing TabContents, if it was supplied. |
| 627 if (existing_tab) { | 635 if (existing_tab) { |
| 628 TabStripModel* model = browser->tabstrip_model(); | 636 TabStripModel* model = browser->tabstrip_model(); |
| 629 int tab_index = model->GetWrapperIndex(existing_tab); | 637 int tab_index = model->GetWrapperIndex(existing_tab); |
| 630 | 638 |
| 631 existing_tab->OpenURL(extension->GetFullLaunchURL(), existing_tab->GetURL(), | 639 existing_tab->OpenURL(extension->GetFullLaunchURL(), existing_tab->GetURL(), |
| 632 CURRENT_TAB, PageTransition::LINK); | 640 CURRENT_TAB, PageTransition::LINK); |
| (...skipping 3632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4265 // The page transition below is only for the purpose of inserting the tab. | 4273 // The page transition below is only for the purpose of inserting the tab. |
| 4266 browser->AddTab(view_source_contents, PageTransition::LINK); | 4274 browser->AddTab(view_source_contents, PageTransition::LINK); |
| 4267 } | 4275 } |
| 4268 | 4276 |
| 4269 if (profile_->HasSessionService()) { | 4277 if (profile_->HasSessionService()) { |
| 4270 SessionService* session_service = profile_->GetSessionService(); | 4278 SessionService* session_service = profile_->GetSessionService(); |
| 4271 if (session_service) | 4279 if (session_service) |
| 4272 session_service->TabRestored(&view_source_contents->controller(), false); | 4280 session_service->TabRestored(&view_source_contents->controller(), false); |
| 4273 } | 4281 } |
| 4274 } | 4282 } |
| OLD | NEW |