| 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/extensions/extension_install_ui.h" | 5 #include "chrome/browser/extensions/extension_install_ui.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 const int kIconSize = 69; | 62 const int kIconSize = 69; |
| 63 | 63 |
| 64 // Shows the application install animation on the new tab page for the app | 64 // Shows the application install animation on the new tab page for the app |
| 65 // with |app_id|. If a NTP already exists on the active |browser|, this will | 65 // with |app_id|. If a NTP already exists on the active |browser|, this will |
| 66 // select that tab and show the animation there. Otherwise, it will create | 66 // select that tab and show the animation there. Otherwise, it will create |
| 67 // a new NTP. | 67 // a new NTP. |
| 68 void ShowAppInstalledAnimation(Browser* browser, const std::string& app_id) { | 68 void ShowAppInstalledAnimation(Browser* browser, const std::string& app_id) { |
| 69 // Select an already open NTP, if there is one. Existing NTPs will | 69 // Select an already open NTP, if there is one. Existing NTPs will |
| 70 // automatically show the install animation for any new apps. | 70 // automatically show the install animation for any new apps. |
| 71 for (int i = 0; i < browser->tab_count(); ++i) { | 71 for (int i = 0; i < browser->tab_count(); ++i) { |
| 72 TabContents* tab_contents = browser->GetTabContentsAt(i); | 72 GURL url = browser->GetTabContentsAt(i)->GetURL(); |
| 73 GURL url = tab_contents->GetURL(); | 73 if (chrome::IsChromeURL(url, chrome::kChromeUINewTabHost)) { |
| 74 if (StartsWithASCII(url.spec(), chrome::kChromeUINewTabURL, false)) { | |
| 75 browser->ActivateTabAt(i, false); | 74 browser->ActivateTabAt(i, false); |
| 76 return; | 75 return; |
| 77 } | 76 } |
| 78 } | 77 } |
| 79 | 78 |
| 80 // If there isn't an NTP, open one and pass it the ID of the installed app. | 79 // If there isn't an NTP, open one and pass it the ID of the installed app. |
| 81 std::string url = base::StringPrintf( | 80 std::string url = base::StringPrintf( |
| 82 "%s/#app-id=%s", chrome::kChromeUINewTabURL, app_id.c_str()); | 81 "%s#app-id=%s", chrome::kChromeUINewTabURL, app_id.c_str()); |
| 83 browser->AddSelectedTabWithURL(GURL(url), PageTransition::TYPED); | 82 browser->AddSelectedTabWithURL(GURL(url), PageTransition::TYPED); |
| 84 } | 83 } |
| 85 | 84 |
| 86 } // namespace | 85 } // namespace |
| 87 | 86 |
| 88 ExtensionInstallUI::ExtensionInstallUI(Profile* profile) | 87 ExtensionInstallUI::ExtensionInstallUI(Profile* profile) |
| 89 : profile_(profile), | 88 : profile_(profile), |
| 90 ui_loop_(MessageLoop::current()), | 89 ui_loop_(MessageLoop::current()), |
| 91 previous_using_native_theme_(false), | 90 previous_using_native_theme_(false), |
| 92 extension_(NULL), | 91 extension_(NULL), |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 274 |
| 276 InfoBarDelegate* ExtensionInstallUI::GetNewThemeInstalledInfoBarDelegate( | 275 InfoBarDelegate* ExtensionInstallUI::GetNewThemeInstalledInfoBarDelegate( |
| 277 TabContents* tab_contents, | 276 TabContents* tab_contents, |
| 278 const Extension* new_theme, | 277 const Extension* new_theme, |
| 279 const std::string& previous_theme_id, | 278 const std::string& previous_theme_id, |
| 280 bool previous_using_native_theme) { | 279 bool previous_using_native_theme) { |
| 281 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, | 280 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, |
| 282 previous_theme_id, | 281 previous_theme_id, |
| 283 previous_using_native_theme); | 282 previous_using_native_theme); |
| 284 } | 283 } |
| OLD | NEW |