| 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/extensions/extension_install_ui_default.h" | 5 #include "chrome/browser/extensions/extension_install_ui_default.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/extensions/extension_install_prompt.h" | 8 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 9 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" | 9 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" |
| 10 #include "chrome/browser/infobars/infobar_tab_helper.h" | 10 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/themes/theme_service.h" | 12 #include "chrome/browser/themes/theme_service.h" |
| 13 #include "chrome/browser/themes/theme_service_factory.h" | 13 #include "chrome/browser/themes/theme_service_factory.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_dialogs.h" | 15 #include "chrome/browser/ui/browser_dialogs.h" |
| 16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
| 17 #include "chrome/browser/ui/browser_navigator.h" | 17 #include "chrome/browser/ui/browser_navigator.h" |
| 18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 19 #include "chrome/browser/ui/simple_message_box.h" | 19 #include "chrome/browser/ui/simple_message_box.h" |
| 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 21 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 21 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 28 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 29 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 const std::string& previous_theme_id, bool previous_using_native_theme, | 123 const std::string& previous_theme_id, bool previous_using_native_theme, |
| 124 const Extension* new_theme, Profile* profile) { | 124 const Extension* new_theme, Profile* profile) { |
| 125 if (!new_theme->is_theme()) | 125 if (!new_theme->is_theme()) |
| 126 return; | 126 return; |
| 127 | 127 |
| 128 // Get last active tabbed browser of profile. | 128 // Get last active tabbed browser of profile. |
| 129 Browser* browser = browser::FindTabbedBrowser(profile, true); | 129 Browser* browser = browser::FindTabbedBrowser(profile, true); |
| 130 if (!browser) | 130 if (!browser) |
| 131 return; | 131 return; |
| 132 | 132 |
| 133 TabContentsWrapper* tab_contents = browser->GetSelectedTabContentsWrapper(); | 133 TabContents* tab_contents = browser->GetActiveTabContents(); |
| 134 if (!tab_contents) | 134 if (!tab_contents) |
| 135 return; | 135 return; |
| 136 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 136 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); |
| 137 | 137 |
| 138 // First find any previous theme preview infobars. | 138 // First find any previous theme preview infobars. |
| 139 InfoBarDelegate* old_delegate = NULL; | 139 InfoBarDelegate* old_delegate = NULL; |
| 140 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { | 140 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { |
| 141 InfoBarDelegate* delegate = infobar_helper->GetInfoBarDelegateAt(i); | 141 InfoBarDelegate* delegate = infobar_helper->GetInfoBarDelegateAt(i); |
| 142 ThemeInstalledInfoBarDelegate* theme_infobar = | 142 ThemeInstalledInfoBarDelegate* theme_infobar = |
| 143 delegate->AsThemePreviewInfobarDelegate(); | 143 delegate->AsThemePreviewInfobarDelegate(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 156 InfoBarDelegate* new_delegate = GetNewThemeInstalledInfoBarDelegate( | 156 InfoBarDelegate* new_delegate = GetNewThemeInstalledInfoBarDelegate( |
| 157 tab_contents, new_theme, previous_theme_id, previous_using_native_theme); | 157 tab_contents, new_theme, previous_theme_id, previous_using_native_theme); |
| 158 | 158 |
| 159 if (old_delegate) | 159 if (old_delegate) |
| 160 infobar_helper->ReplaceInfoBar(old_delegate, new_delegate); | 160 infobar_helper->ReplaceInfoBar(old_delegate, new_delegate); |
| 161 else | 161 else |
| 162 infobar_helper->AddInfoBar(new_delegate); | 162 infobar_helper->AddInfoBar(new_delegate); |
| 163 } | 163 } |
| 164 | 164 |
| 165 InfoBarDelegate* ExtensionInstallUIDefault::GetNewThemeInstalledInfoBarDelegate( | 165 InfoBarDelegate* ExtensionInstallUIDefault::GetNewThemeInstalledInfoBarDelegate( |
| 166 TabContentsWrapper* tab_contents, | 166 TabContents* tab_contents, |
| 167 const Extension* new_theme, | 167 const Extension* new_theme, |
| 168 const std::string& previous_theme_id, | 168 const std::string& previous_theme_id, |
| 169 bool previous_using_native_theme) { | 169 bool previous_using_native_theme) { |
| 170 Profile* profile = tab_contents->profile(); | 170 Profile* profile = tab_contents->profile(); |
| 171 return new ThemeInstalledInfoBarDelegate( | 171 return new ThemeInstalledInfoBarDelegate( |
| 172 tab_contents->infobar_tab_helper(), | 172 tab_contents->infobar_tab_helper(), |
| 173 profile->GetExtensionService(), | 173 profile->GetExtensionService(), |
| 174 ThemeServiceFactory::GetForProfile(profile), | 174 ThemeServiceFactory::GetForProfile(profile), |
| 175 new_theme, | 175 new_theme, |
| 176 previous_theme_id, | 176 previous_theme_id, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 205 #else | 205 #else |
| 206 NOTREACHED(); | 206 NOTREACHED(); |
| 207 #endif | 207 #endif |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 // static | 211 // static |
| 212 void ExtensionInstallUI::DisableFailureUIForTests() { | 212 void ExtensionInstallUI::DisableFailureUIForTests() { |
| 213 disable_failure_ui_for_tests = true; | 213 disable_failure_ui_for_tests = true; |
| 214 } | 214 } |
| OLD | NEW |