Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: chrome/browser/ui/extensions/extension_install_ui_default.cc

Issue 1993583002: Show notification instead of opening app launcher after extension installation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.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/infobar_service.h" 13 #include "chrome/browser/infobars/infobar_service.h"
14 #include "chrome/browser/prefs/incognito_mode_prefs.h" 14 #include "chrome/browser/prefs/incognito_mode_prefs.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/themes/theme_service.h" 16 #include "chrome/browser/themes/theme_service.h"
17 #include "chrome/browser/themes/theme_service_factory.h" 17 #include "chrome/browser/themes/theme_service_factory.h"
18 #include "chrome/browser/ui/app_list/app_list_service.h"
19 #include "chrome/browser/ui/app_list/app_list_util.h"
20 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_finder.h" 19 #include "chrome/browser/ui/browser_finder.h"
22 #include "chrome/browser/ui/browser_navigator.h" 20 #include "chrome/browser/ui/browser_navigator.h"
23 #include "chrome/browser/ui/browser_navigator_params.h" 21 #include "chrome/browser/ui/browser_navigator_params.h"
24 #include "chrome/browser/ui/browser_tabstrip.h" 22 #include "chrome/browser/ui/browser_tabstrip.h"
25 #include "chrome/browser/ui/browser_window.h" 23 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/extensions/extension_installed_bubble.h" 24 #include "chrome/browser/ui/extensions/extension_installed_bubble.h"
27 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 25 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
28 #include "chrome/browser/ui/simple_message_box.h" 26 #include "chrome/browser/ui/simple_message_box.h"
29 #include "chrome/browser/ui/singleton_tabs.h" 27 #include "chrome/browser/ui/singleton_tabs.h"
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" 28 #include "chrome/browser/ui/tabs/tab_strip_model.h"
31 #include "chrome/common/url_constants.h"
32 #include "chrome/grit/generated_resources.h" 29 #include "chrome/grit/generated_resources.h"
33 #include "components/infobars/core/confirm_infobar_delegate.h" 30 #include "components/infobars/core/confirm_infobar_delegate.h"
34 #include "components/infobars/core/infobar.h" 31 #include "components/infobars/core/infobar.h"
35 #include "components/search/search.h" 32 #include "components/search/search.h"
36 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
37 #include "content/public/browser/notification_service.h"
38 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
39 #include "extensions/browser/install/crx_install_error.h" 35 #include "extensions/browser/install/crx_install_error.h"
40 #include "extensions/common/extension.h" 36 #include "extensions/common/extension.h"
41 #include "grit/components_strings.h" 37 #include "grit/components_strings.h"
42 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
43 39
40 #if defined(OS_CHROMEOS)
41 #include "chrome/browser/ui/extensions/extension_installed_notification.h"
42 #else
43 #include "chrome/common/url_constants.h"
44 #include "content/public/browser/notification_service.h"
45 #endif
46
44 #if defined(USE_ASH) 47 #if defined(USE_ASH)
45 #include "ash/shell.h" 48 #include "ash/shell.h"
46 #endif 49 #endif
47 50
48 using content::BrowserThread; 51 using content::BrowserThread;
49 using content::WebContents; 52 using content::WebContents;
50 using extensions::Extension; 53 using extensions::Extension;
51 54
52 namespace { 55 namespace {
53 56
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // Extensions aren't enabled by default in incognito so we confirm 180 // Extensions aren't enabled by default in incognito so we confirm
178 // the install in a normal window. 181 // the install in a normal window.
179 Profile* current_profile = profile_->GetOriginalProfile(); 182 Profile* current_profile = profile_->GetOriginalProfile();
180 if (extension->is_app()) { 183 if (extension->is_app()) {
181 bool use_bubble = false; 184 bool use_bubble = false;
182 185
183 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) 186 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)
184 use_bubble = use_app_installed_bubble_; 187 use_bubble = use_app_installed_bubble_;
185 #endif 188 #endif
186 189
187 if (IsAppLauncherEnabled()) {
188 AppListService::Get()->ShowForAppInstall(current_profile, extension->id(),
189 false);
190 return;
191 }
192
193 if (use_bubble) { 190 if (use_bubble) {
194 ShowExtensionInstalledBubble(extension, current_profile, *icon); 191 ShowExtensionInstalledBubble(extension, current_profile, *icon);
195 return; 192 return;
196 } 193 }
197 194
195 #if defined(OS_CHROMEOS)
196 ExtensionInstalledNotification::Show(extension, current_profile);
197 #else // defined(OS_CHROMEOS)
198 OpenAppInstalledUI(extension->id()); 198 OpenAppInstalledUI(extension->id());
199 #endif // defined(OS_CHROMEOS)
199 return; 200 return;
200 } 201 }
201 202
202 ShowExtensionInstalledBubble(extension, current_profile, *icon); 203 ShowExtensionInstalledBubble(extension, current_profile, *icon);
203 } 204 }
204 205
205 void ExtensionInstallUIDefault::OnInstallFailure( 206 void ExtensionInstallUIDefault::OnInstallFailure(
206 const extensions::CrxInstallError& error) { 207 const extensions::CrxInstallError& error) {
207 DCHECK_CURRENTLY_ON(BrowserThread::UI); 208 DCHECK_CURRENTLY_ON(BrowserThread::UI);
208 if (disable_failure_ui_for_tests() || skip_post_install_ui_) 209 if (disable_failure_ui_for_tests() || skip_post_install_ui_)
209 return; 210 return;
210 211
211 Browser* browser = chrome::FindLastActiveWithProfile(profile_); 212 Browser* browser = chrome::FindLastActiveWithProfile(profile_);
212 if (!browser) // Can be NULL in unittests. 213 if (!browser) // Can be NULL in unittests.
213 return; 214 return;
214 WebContents* web_contents = 215 WebContents* web_contents =
215 browser->tab_strip_model()->GetActiveWebContents(); 216 browser->tab_strip_model()->GetActiveWebContents();
216 if (!web_contents) 217 if (!web_contents)
217 return; 218 return;
218 ErrorInfoBarDelegate::Create(InfoBarService::FromWebContents(web_contents), 219 ErrorInfoBarDelegate::Create(InfoBarService::FromWebContents(web_contents),
219 error); 220 error);
220 } 221 }
221 222
222 void ExtensionInstallUIDefault::OpenAppInstalledUI(const std::string& app_id) { 223 void ExtensionInstallUIDefault::OpenAppInstalledUI(const std::string& app_id) {
223 #if defined(OS_CHROMEOS) 224 #if defined(OS_CHROMEOS)
224 // App Launcher always enabled on ChromeOS, so always handled in 225 // Notification always enabled on ChromeOS, so always handled in
225 // OnInstallSuccess. 226 // OnInstallSuccess.
226 NOTREACHED(); 227 NOTREACHED();
227 #else 228 #else
228 Profile* current_profile = profile_->GetOriginalProfile(); 229 Profile* current_profile = profile_->GetOriginalProfile();
229 Browser* browser = FindOrCreateVisibleBrowser(current_profile); 230 Browser* browser = FindOrCreateVisibleBrowser(current_profile);
230 if (browser) { 231 if (browser) {
231 GURL url(search::IsInstantExtendedAPIEnabled() 232 GURL url(search::IsInstantExtendedAPIEnabled()
232 ? chrome::kChromeUIAppsURL 233 ? chrome::kChromeUIAppsURL
233 : chrome::kChromeUINewTabURL); 234 : chrome::kChromeUINewTabURL);
234 chrome::NavigateParams params( 235 chrome::NavigateParams params(
(...skipping 18 matching lines...) Expand all
253 254
254 gfx::NativeWindow ExtensionInstallUIDefault::GetDefaultInstallDialogParent() { 255 gfx::NativeWindow ExtensionInstallUIDefault::GetDefaultInstallDialogParent() {
255 Browser* browser = chrome::FindLastActiveWithProfile(profile_); 256 Browser* browser = chrome::FindLastActiveWithProfile(profile_);
256 if (browser) { 257 if (browser) {
257 content::WebContents* contents = 258 content::WebContents* contents =
258 browser->tab_strip_model()->GetActiveWebContents(); 259 browser->tab_strip_model()->GetActiveWebContents();
259 return contents->GetTopLevelNativeWindow(); 260 return contents->GetTopLevelNativeWindow();
260 } 261 }
261 return NULL; 262 return NULL;
262 } 263 }
OLDNEW
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | chrome/browser/ui/extensions/extension_installed_notification.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698