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

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

Issue 10699057: Move application creation and extension install prompt showing off Browser and onto ExtensionTabHel… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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/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 "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_install_prompt.h" 9 #include "chrome/browser/extensions/extension_install_prompt.h"
10 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" 10 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 chrome::Navigate(&params); 80 chrome::Navigate(&params);
81 return false; 81 return false;
82 } 82 }
83 83
84 Browser* browser_; 84 Browser* browser_;
85 CrxInstallerError error_; 85 CrxInstallerError error_;
86 }; 86 };
87 87
88 } // namespace 88 } // namespace
89 89
90 ExtensionInstallUIDefault::ExtensionInstallUIDefault(Browser* browser) 90 ExtensionInstallUIDefault::ExtensionInstallUIDefault(Profile* profile)
91 : skip_post_install_ui_(false), 91 : skip_post_install_ui_(false),
92 previous_using_native_theme_(false), 92 previous_using_native_theme_(false),
93 use_app_installed_bubble_(false) { 93 use_app_installed_bubble_(false) {
94 browser_ = browser; 94 profile_ = profile;
95 95
96 // Remember the current theme in case the user presses undo. 96 // |profile_| can be NULL during tests.
97 if (browser) { 97 if (profile_) {
98 Profile* profile = browser->profile(); 98 // Remember the current theme in case the user presses undo.
99 const Extension* previous_theme = 99 const Extension* previous_theme =
100 ThemeServiceFactory::GetThemeForProfile(profile); 100 ThemeServiceFactory::GetThemeForProfile(profile);
101 if (previous_theme) 101 if (previous_theme)
102 previous_theme_id_ = previous_theme->id(); 102 previous_theme_id_ = previous_theme->id();
103 previous_using_native_theme_ = 103 previous_using_native_theme_ =
104 ThemeServiceFactory::GetForProfile(profile)->UsingNativeTheme(); 104 ThemeServiceFactory::GetForProfile(profile)->UsingNativeTheme();
105 } 105 }
106 } 106 }
107 107
108 ExtensionInstallUIDefault::~ExtensionInstallUIDefault() { 108 ExtensionInstallUIDefault::~ExtensionInstallUIDefault() {
109 } 109 }
110 110
111 void ExtensionInstallUIDefault::OnInstallSuccess(const Extension* extension, 111 void ExtensionInstallUIDefault::OnInstallSuccess(const Extension* extension,
112 SkBitmap* icon) { 112 SkBitmap* icon) {
113 if (skip_post_install_ui_) 113 if (skip_post_install_ui_)
114 return; 114 return;
115 115
116 if (extension->is_theme()) { 116 if (extension->is_theme()) {
117 ShowThemeInfoBar(previous_theme_id_, previous_using_native_theme_, 117 ShowThemeInfoBar(previous_theme_id_, previous_using_native_theme_,
118 extension, browser_->profile()); 118 extension, profile_);
119 return; 119 return;
120 } 120 }
121 121
122 // Extensions aren't enabled by default in incognito so we confirm 122 // Extensions aren't enabled by default in incognito so we confirm
123 // the install in a normal window. 123 // the install in a normal window.
124 Profile* current_profile = browser_->profile()->GetOriginalProfile(); 124 Profile* current_profile = profile_->GetOriginalProfile();
125 Browser* browser = browser::FindOrCreateTabbedBrowser(current_profile); 125 Browser* browser = browser::FindOrCreateTabbedBrowser(current_profile);
126 if (browser->tab_count() == 0) 126 if (browser->tab_count() == 0)
127 browser->AddBlankTab(true); 127 browser->AddBlankTab(true);
128 browser->window()->Show(); 128 browser->window()->Show();
129 129
130 bool use_bubble_for_apps = false; 130 bool use_bubble_for_apps = false;
131 131
132 #if defined(TOOLKIT_VIEWS) 132 #if defined(TOOLKIT_VIEWS)
133 CommandLine* cmdline = CommandLine::ForCurrentProcess(); 133 CommandLine* cmdline = CommandLine::ForCurrentProcess();
134 use_bubble_for_apps = (use_app_installed_bubble_ || 134 use_bubble_for_apps = (use_app_installed_bubble_ ||
135 cmdline->HasSwitch(switches::kAppsNewInstallBubble)); 135 cmdline->HasSwitch(switches::kAppsNewInstallBubble));
136 #endif 136 #endif
137 137
138 if (extension->is_app() && !use_bubble_for_apps) { 138 if (extension->is_app() && !use_bubble_for_apps) {
139 ExtensionInstallUI::OpenAppInstalledUI(browser, extension->id()); 139 ExtensionInstallUI::OpenAppInstalledUI(browser, extension->id());
140 return; 140 return;
141 } 141 }
142 142
143 chrome::ShowExtensionInstalledBubble(extension, browser, *icon); 143 chrome::ShowExtensionInstalledBubble(extension, browser, *icon);
144 } 144 }
145 145
146 void ExtensionInstallUIDefault::OnInstallFailure( 146 void ExtensionInstallUIDefault::OnInstallFailure(
147 const CrxInstallerError& error) { 147 const CrxInstallerError& error) {
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
149 if (disable_failure_ui_for_tests || skip_post_install_ui_) 149 if (disable_failure_ui_for_tests || skip_post_install_ui_)
150 return; 150 return;
151 151
152 Browser* browser = browser::FindLastActiveWithProfile(browser_->profile()); 152 Browser* browser = browser::FindLastActiveWithProfile(profile_);
153 TabContents* tab_contents = chrome::GetActiveTabContents(browser); 153 TabContents* tab_contents = chrome::GetActiveTabContents(browser);
154 if (!tab_contents) 154 if (!tab_contents)
155 return; 155 return;
156 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); 156 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper();
157 infobar_helper->AddInfoBar( 157 infobar_helper->AddInfoBar(
158 new ErrorInfobarDelegate(infobar_helper, browser, error)); 158 new ErrorInfobarDelegate(infobar_helper, browser, error));
159 } 159 }
160 160
161 void ExtensionInstallUIDefault::SetSkipPostInstallUI(bool skip_ui) { 161 void ExtensionInstallUIDefault::SetSkipPostInstallUI(bool skip_ui) {
162 skip_post_install_ui_ = skip_ui; 162 skip_post_install_ui_ = skip_ui;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return new ThemeInstalledInfoBarDelegate( 219 return new ThemeInstalledInfoBarDelegate(
220 tab_contents->infobar_tab_helper(), 220 tab_contents->infobar_tab_helper(),
221 profile->GetExtensionService(), 221 profile->GetExtensionService(),
222 ThemeServiceFactory::GetForProfile(profile), 222 ThemeServiceFactory::GetForProfile(profile),
223 new_theme, 223 new_theme,
224 previous_theme_id, 224 previous_theme_id,
225 previous_using_native_theme); 225 previous_using_native_theme);
226 } 226 }
227 227
228 // static 228 // static
229 ExtensionInstallUI* ExtensionInstallUI::Create(Browser* browser) { 229 ExtensionInstallUI* ExtensionInstallUI::Create(Profile* profile) {
230 return new ExtensionInstallUIDefault(browser); 230 return new ExtensionInstallUIDefault(profile);
231 } 231 }
232 232
233 // static 233 // static
234 void ExtensionInstallUI::OpenAppInstalledUI(Browser* browser, 234 void ExtensionInstallUI::OpenAppInstalledUI(Browser* browser,
235 const std::string& app_id) { 235 const std::string& app_id) {
236 if (NewTabUI::ShouldShowApps()) { 236 if (NewTabUI::ShouldShowApps()) {
237 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams( 237 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams(
238 browser, GURL(chrome::kChromeUINewTabURL))); 238 browser, GURL(chrome::kChromeUINewTabURL)));
239 chrome::Navigate(&params); 239 chrome::Navigate(&params);
240 240
(...skipping 12 matching lines...) Expand all
253 #else 253 #else
254 NOTREACHED(); 254 NOTREACHED();
255 #endif 255 #endif
256 } 256 }
257 } 257 }
258 258
259 // static 259 // static
260 void ExtensionInstallUI::DisableFailureUIForTests() { 260 void ExtensionInstallUI::DisableFailureUIForTests() {
261 disable_failure_ui_for_tests = true; 261 disable_failure_ui_for_tests = true;
262 } 262 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_ui_default.h ('k') | chrome/browser/extensions/extension_management_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698