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/extensions/extension_install_ui_default.h" | 5 #include "chrome/browser/ui/extensions/extension_install_ui_default.h" |
6 | 6 |
7 #include "apps/app_launcher.h" | 7 #include "apps/app_launcher.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/extensions/extension_install_prompt.h" | 11 #include "chrome/browser/extensions/extension_install_prompt.h" |
12 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" | 12 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" |
13 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 13 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
14 #include "chrome/browser/infobars/infobar_service.h" | 14 #include "chrome/browser/infobars/infobar_service.h" |
| 15 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
17 #include "chrome/browser/themes/theme_service.h" | 18 #include "chrome/browser/themes/theme_service.h" |
18 #include "chrome/browser/themes/theme_service_factory.h" | 19 #include "chrome/browser/themes/theme_service_factory.h" |
19 #include "chrome/browser/ui/app_list/app_list_service.h" | 20 #include "chrome/browser/ui/app_list/app_list_service.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_dialogs.h" | 22 #include "chrome/browser/ui/browser_dialogs.h" |
22 #include "chrome/browser/ui/browser_finder.h" | 23 #include "chrome/browser/ui/browser_finder.h" |
23 #include "chrome/browser/ui/browser_navigator.h" | 24 #include "chrome/browser/ui/browser_navigator.h" |
24 #include "chrome/browser/ui/browser_tabstrip.h" | 25 #include "chrome/browser/ui/browser_tabstrip.h" |
(...skipping 23 matching lines...) Expand all Loading... |
48 using extensions::Extension; | 49 using extensions::Extension; |
49 | 50 |
50 namespace { | 51 namespace { |
51 | 52 |
52 | 53 |
53 // Helpers -------------------------------------------------------------------- | 54 // Helpers -------------------------------------------------------------------- |
54 | 55 |
55 bool disable_failure_ui_for_tests = false; | 56 bool disable_failure_ui_for_tests = false; |
56 | 57 |
57 Browser* FindOrCreateVisibleBrowser(Profile* profile) { | 58 Browser* FindOrCreateVisibleBrowser(Profile* profile) { |
| 59 // TODO(mpcomplete): remove this workaround for http://crbug.com/244246 |
| 60 // after fixing http://crbug.com/38676. |
| 61 if (!IncognitoModePrefs::CanOpenBrowser(profile)) |
| 62 return NULL; |
58 Browser* browser = | 63 Browser* browser = |
59 chrome::FindOrCreateTabbedBrowser(profile, chrome::GetActiveDesktop()); | 64 chrome::FindOrCreateTabbedBrowser(profile, chrome::GetActiveDesktop()); |
60 if (browser->tab_strip_model()->count() == 0) | 65 if (browser->tab_strip_model()->count() == 0) |
61 chrome::AddBlankTabAt(browser, -1, true); | 66 chrome::AddBlankTabAt(browser, -1, true); |
62 browser->window()->Show(); | 67 browser->window()->Show(); |
63 return browser; | 68 return browser; |
64 } | 69 } |
65 | 70 |
66 void ShowExtensionInstalledBubble(const extensions::Extension* extension, | 71 void ShowExtensionInstalledBubble(const extensions::Extension* extension, |
67 Profile* profile, | 72 Profile* profile, |
68 const SkBitmap& icon) { | 73 const SkBitmap& icon) { |
69 Browser* browser = FindOrCreateVisibleBrowser(profile); | 74 Browser* browser = FindOrCreateVisibleBrowser(profile); |
70 chrome::ShowExtensionInstalledBubble(extension, browser, icon); | 75 if (browser) |
| 76 chrome::ShowExtensionInstalledBubble(extension, browser, icon); |
71 } | 77 } |
72 | 78 |
73 void OnAppLauncherEnabledCompleted(const extensions::Extension* extension, | 79 void OnAppLauncherEnabledCompleted(const extensions::Extension* extension, |
74 Profile* profile, | 80 Profile* profile, |
75 SkBitmap* icon, | 81 SkBitmap* icon, |
76 bool use_bubble, | 82 bool use_bubble, |
77 bool use_launcher) { | 83 bool use_launcher) { |
78 if (use_launcher) { | 84 if (use_launcher) { |
79 AppListService::Get()->ShowAppList(profile); | 85 AppListService::Get()->ShowAppList(profile); |
80 | 86 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 const std::string& app_id) { | 175 const std::string& app_id) { |
170 #if defined(OS_CHROMEOS) | 176 #if defined(OS_CHROMEOS) |
171 AppListService::Get()->ShowAppList(profile); | 177 AppListService::Get()->ShowAppList(profile); |
172 | 178 |
173 content::NotificationService::current()->Notify( | 179 content::NotificationService::current()->Notify( |
174 chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, | 180 chrome::NOTIFICATION_APP_INSTALLED_TO_APPLIST, |
175 content::Source<Profile>(profile), | 181 content::Source<Profile>(profile), |
176 content::Details<const std::string>(&app_id)); | 182 content::Details<const std::string>(&app_id)); |
177 #else | 183 #else |
178 Browser* browser = FindOrCreateVisibleBrowser(profile); | 184 Browser* browser = FindOrCreateVisibleBrowser(profile); |
179 GURL url(chrome::IsInstantExtendedAPIEnabled() ? | 185 if (browser) { |
180 chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL); | 186 GURL url(chrome::IsInstantExtendedAPIEnabled() ? |
181 chrome::NavigateParams params( | 187 chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL); |
182 chrome::GetSingletonTabNavigateParams(browser, url)); | 188 chrome::NavigateParams params( |
183 chrome::Navigate(¶ms); | 189 chrome::GetSingletonTabNavigateParams(browser, url)); |
| 190 chrome::Navigate(¶ms); |
184 | 191 |
185 content::NotificationService::current()->Notify( | 192 content::NotificationService::current()->Notify( |
186 chrome::NOTIFICATION_APP_INSTALLED_TO_NTP, | 193 chrome::NOTIFICATION_APP_INSTALLED_TO_NTP, |
187 content::Source<WebContents>(params.target_contents), | 194 content::Source<WebContents>(params.target_contents), |
188 content::Details<const std::string>(&app_id)); | 195 content::Details<const std::string>(&app_id)); |
| 196 } |
189 #endif | 197 #endif |
190 } | 198 } |
191 | 199 |
192 // static | 200 // static |
193 void ExtensionInstallUI::DisableFailureUIForTests() { | 201 void ExtensionInstallUI::DisableFailureUIForTests() { |
194 disable_failure_ui_for_tests = true; | 202 disable_failure_ui_for_tests = true; |
195 } | 203 } |
196 | 204 |
197 // static | 205 // static |
198 ExtensionInstallPrompt* ExtensionInstallUI::CreateInstallPromptWithBrowser( | 206 ExtensionInstallPrompt* ExtensionInstallUI::CreateInstallPromptWithBrowser( |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 error); | 300 error); |
293 } | 301 } |
294 | 302 |
295 void ExtensionInstallUIDefault::SetSkipPostInstallUI(bool skip_ui) { | 303 void ExtensionInstallUIDefault::SetSkipPostInstallUI(bool skip_ui) { |
296 skip_post_install_ui_ = skip_ui; | 304 skip_post_install_ui_ = skip_ui; |
297 } | 305 } |
298 | 306 |
299 void ExtensionInstallUIDefault::SetUseAppInstalledBubble(bool use_bubble) { | 307 void ExtensionInstallUIDefault::SetUseAppInstalledBubble(bool use_bubble) { |
300 use_app_installed_bubble_ = use_bubble; | 308 use_app_installed_bubble_ = use_bubble; |
301 } | 309 } |
OLD | NEW |