Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 | 115 |
| 116 void ExtensionInstallUI::ConfirmUninstall(Delegate* delegate, | 116 void ExtensionInstallUI::ConfirmUninstall(Delegate* delegate, |
| 117 const Extension* extension) { | 117 const Extension* extension) { |
| 118 DCHECK(ui_loop_ == MessageLoop::current()); | 118 DCHECK(ui_loop_ == MessageLoop::current()); |
| 119 extension_ = extension; | 119 extension_ = extension; |
| 120 delegate_ = delegate; | 120 delegate_ = delegate; |
| 121 | 121 |
| 122 ShowConfirmation(UNINSTALL_PROMPT); | 122 ShowConfirmation(UNINSTALL_PROMPT); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void ExtensionInstallUI::OnInstallSuccess(const Extension* extension) { | 125 void ExtensionInstallUI::OnInstallSuccess(const Extension* extension, |
| 126 SkBitmap* icon) { | |
| 127 extension_ = extension; | |
| 128 SetIcon(icon); | |
| 129 | |
| 126 if (extension->is_theme()) { | 130 if (extension->is_theme()) { |
| 127 ShowThemeInfoBar(previous_theme_id_, previous_use_system_theme_, | 131 ShowThemeInfoBar(previous_theme_id_, previous_use_system_theme_, |
| 128 extension, profile_); | 132 extension, profile_); |
| 129 return; | 133 return; |
| 130 } | 134 } |
| 131 | 135 |
| 132 // Note that browser actions don't appear in incognito mode initially, | 136 // Note that browser actions don't appear in incognito mode initially, |
| 133 // so be sure to use a normal browser window. | 137 // so be sure to use a normal browser window. |
| 134 Profile* profile = profile_; | 138 Profile* profile = profile_; |
| 135 if (extension->browser_action()) | 139 if (extension->browser_action()) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 void ExtensionInstallUI::OnInstallFailure(const std::string& error) { | 178 void ExtensionInstallUI::OnInstallFailure(const std::string& error) { |
| 175 DCHECK(ui_loop_ == MessageLoop::current()); | 179 DCHECK(ui_loop_ == MessageLoop::current()); |
| 176 | 180 |
| 177 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 181 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
| 178 platform_util::SimpleErrorBox( | 182 platform_util::SimpleErrorBox( |
| 179 browser ? browser->window()->GetNativeHandle() : NULL, | 183 browser ? browser->window()->GetNativeHandle() : NULL, |
| 180 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_FAILURE_TITLE), | 184 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_FAILURE_TITLE), |
| 181 UTF8ToUTF16(error)); | 185 UTF8ToUTF16(error)); |
| 182 } | 186 } |
| 183 | 187 |
| 184 void ExtensionInstallUI::OnImageLoaded( | 188 void ExtensionInstallUI::SetIcon(SkBitmap* image) { |
| 185 SkBitmap* image, ExtensionResource resource, int index) { | |
| 186 if (image) | 189 if (image) |
| 187 icon_ = *image; | 190 icon_ = *image; |
| 188 else | 191 else |
| 189 icon_ = SkBitmap(); | 192 icon_ = SkBitmap(); |
| 190 if (icon_.empty()) { | 193 if (icon_.empty()) { |
| 191 if (extension_->is_app()) { | 194 if (extension_->is_app()) { |
| 192 icon_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed( | 195 icon_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 193 IDR_APP_DEFAULT_ICON); | 196 IDR_APP_DEFAULT_ICON); |
| 194 } else { | 197 } else { |
| 195 icon_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed( | 198 icon_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 196 IDR_EXTENSION_DEFAULT_ICON); | 199 IDR_EXTENSION_DEFAULT_ICON); |
| 197 } | 200 } |
| 198 } | 201 } |
| 202 } | |
| 203 | |
| 204 void ExtensionInstallUI::OnImageLoaded( | |
| 205 SkBitmap* image, ExtensionResource resource, int index) { | |
| 206 SetIcon(image); | |
| 199 | 207 |
| 200 switch (prompt_type_) { | 208 switch (prompt_type_) { |
| 201 case INSTALL_PROMPT: { | 209 case INSTALL_PROMPT: { |
| 202 // TODO(jcivelli): http://crbug.com/44771 We should not show an install | 210 // TODO(jcivelli): http://crbug.com/44771 We should not show an install |
| 203 // dialog when installing an app from the gallery. | 211 // dialog when installing an app from the gallery. |
| 204 NotificationService* service = NotificationService::current(); | 212 NotificationService* service = NotificationService::current(); |
| 205 service->Notify(NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG, | 213 service->Notify(NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG, |
| 206 Source<ExtensionInstallUI>(this), | 214 Source<ExtensionInstallUI>(this), |
| 207 NotificationService::NoDetails()); | 215 NotificationService::NoDetails()); |
| 208 | 216 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 tab_contents, new_theme, | 270 tab_contents, new_theme, |
| 263 previous_theme_id, previous_use_system_theme); | 271 previous_theme_id, previous_use_system_theme); |
| 264 | 272 |
| 265 if (old_delegate) | 273 if (old_delegate) |
| 266 tab_contents->ReplaceInfoBar(old_delegate, new_delegate); | 274 tab_contents->ReplaceInfoBar(old_delegate, new_delegate); |
| 267 else | 275 else |
| 268 tab_contents->AddInfoBar(new_delegate); | 276 tab_contents->AddInfoBar(new_delegate); |
| 269 } | 277 } |
| 270 | 278 |
| 271 void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) { | 279 void ExtensionInstallUI::ShowConfirmation(PromptType prompt_type) { |
| 272 // Load the image asynchronously. For the response, check OnImageLoaded. | 280 // Load the image asynchronously. For the response, check OnImageLoaded. |
|
asargent_no_longer_on_chrome
2010/12/13 18:05:11
Would it make sense to check here if the icon was
| |
| 273 prompt_type_ = prompt_type; | 281 prompt_type_ = prompt_type; |
| 274 ExtensionResource image = | 282 ExtensionResource image = |
| 275 extension_->GetIconResource(Extension::EXTENSION_ICON_LARGE, | 283 extension_->GetIconResource(Extension::EXTENSION_ICON_LARGE, |
| 276 ExtensionIconSet::MATCH_EXACTLY); | 284 ExtensionIconSet::MATCH_EXACTLY); |
| 277 tracker_.LoadImage(extension_, image, | 285 tracker_.LoadImage(extension_, image, |
| 278 gfx::Size(kIconSize, kIconSize), | 286 gfx::Size(kIconSize, kIconSize), |
| 279 ImageLoadingTracker::DONT_CACHE); | 287 ImageLoadingTracker::DONT_CACHE); |
| 280 } | 288 } |
| 281 | 289 |
| 282 #if defined(OS_MACOSX) | 290 #if defined(OS_MACOSX) |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 307 TabContents* tab_contents, const Extension* new_theme, | 315 TabContents* tab_contents, const Extension* new_theme, |
| 308 const std::string& previous_theme_id, bool previous_use_system_theme) { | 316 const std::string& previous_theme_id, bool previous_use_system_theme) { |
| 309 #if defined(TOOLKIT_GTK) | 317 #if defined(TOOLKIT_GTK) |
| 310 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, | 318 return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme, |
| 311 previous_theme_id, previous_use_system_theme); | 319 previous_theme_id, previous_use_system_theme); |
| 312 #else | 320 #else |
| 313 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, | 321 return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme, |
| 314 previous_theme_id); | 322 previous_theme_id); |
| 315 #endif | 323 #endif |
| 316 } | 324 } |
| OLD | NEW |