| 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.h" | 5 #include "chrome/browser/extensions/extension_install_ui.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "chrome/common/extensions/extension_icon_set.h" | 34 #include "chrome/common/extensions/extension_icon_set.h" |
| 35 #include "chrome/common/extensions/extension_resource.h" | 35 #include "chrome/common/extensions/extension_resource.h" |
| 36 #include "chrome/common/extensions/url_pattern.h" | 36 #include "chrome/common/extensions/url_pattern.h" |
| 37 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
| 38 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
| 39 #include "grit/chromium_strings.h" | 39 #include "grit/chromium_strings.h" |
| 40 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
| 41 #include "grit/theme_resources.h" | 41 #include "grit/theme_resources.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
| 44 #include "ui/gfx/image/image.h" |
| 44 | 45 |
| 45 using content::WebContents; | 46 using content::WebContents; |
| 46 using extensions::BundleInstaller; | 47 using extensions::BundleInstaller; |
| 47 | 48 |
| 48 static const int kTitleIds[ExtensionInstallUI::NUM_PROMPT_TYPES] = { | 49 static const int kTitleIds[ExtensionInstallUI::NUM_PROMPT_TYPES] = { |
| 49 0, // The regular install prompt depends on what's being installed. | 50 0, // The regular install prompt depends on what's being installed. |
| 50 IDS_EXTENSION_INLINE_INSTALL_PROMPT_TITLE, | 51 IDS_EXTENSION_INLINE_INSTALL_PROMPT_TITLE, |
| 51 IDS_EXTENSION_INSTALL_PROMPT_TITLE, | 52 IDS_EXTENSION_INSTALL_PROMPT_TITLE, |
| 52 IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE, | 53 IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE, |
| 53 IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE | 54 IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 if (disable_failure_ui_for_tests || skip_post_install_ui_) | 317 if (disable_failure_ui_for_tests || skip_post_install_ui_) |
| 317 return; | 318 return; |
| 318 | 319 |
| 319 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 320 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
| 320 browser::ShowErrorBox( | 321 browser::ShowErrorBox( |
| 321 browser ? browser->window()->GetNativeHandle() : NULL, | 322 browser ? browser->window()->GetNativeHandle() : NULL, |
| 322 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_FAILURE_TITLE), | 323 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_FAILURE_TITLE), |
| 323 error); | 324 error); |
| 324 } | 325 } |
| 325 | 326 |
| 326 void ExtensionInstallUI::SetIcon(SkBitmap* image) { | 327 void ExtensionInstallUI::SetIcon(const SkBitmap* image) { |
| 327 if (image) | 328 if (image) |
| 328 icon_ = *image; | 329 icon_ = *image; |
| 329 else | 330 else |
| 330 icon_ = SkBitmap(); | 331 icon_ = SkBitmap(); |
| 331 if (icon_.empty()) | 332 if (icon_.empty()) |
| 332 icon_ = Extension::GetDefaultIcon(extension_->is_app()); | 333 icon_ = Extension::GetDefaultIcon(extension_->is_app()); |
| 333 } | 334 } |
| 334 | 335 |
| 335 void ExtensionInstallUI::OnImageLoaded( | 336 void ExtensionInstallUI::OnImageLoaded(const gfx::Image& image, |
| 336 SkBitmap* image, const ExtensionResource& resource, int index) { | 337 const std::string& extension_id, |
| 337 SetIcon(image); | 338 int index) { |
| 339 SetIcon(image.IsEmpty() ? NULL : image.ToSkBitmap()); |
| 338 | 340 |
| 339 switch (prompt_type_) { | 341 switch (prompt_type_) { |
| 340 case PERMISSIONS_PROMPT: | 342 case PERMISSIONS_PROMPT: |
| 341 case RE_ENABLE_PROMPT: | 343 case RE_ENABLE_PROMPT: |
| 342 case INSTALL_PROMPT: { | 344 case INSTALL_PROMPT: { |
| 343 content::NotificationService* service = | 345 content::NotificationService* service = |
| 344 content::NotificationService::current(); | 346 content::NotificationService::current(); |
| 345 service->Notify(chrome::NOTIFICATION_EXTENSION_WILL_SHOW_CONFIRM_DIALOG, | 347 service->Notify(chrome::NOTIFICATION_EXTENSION_WILL_SHOW_CONFIRM_DIALOG, |
| 346 content::Source<ExtensionInstallUI>(this), | 348 content::Source<ExtensionInstallUI>(this), |
| 347 content::NotificationService::NoDetails()); | 349 content::NotificationService::NoDetails()); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 bool previous_using_native_theme) { | 441 bool previous_using_native_theme) { |
| 440 Profile* profile = tab_contents->profile(); | 442 Profile* profile = tab_contents->profile(); |
| 441 return new ThemeInstalledInfoBarDelegate( | 443 return new ThemeInstalledInfoBarDelegate( |
| 442 tab_contents->infobar_tab_helper(), | 444 tab_contents->infobar_tab_helper(), |
| 443 profile->GetExtensionService(), | 445 profile->GetExtensionService(), |
| 444 ThemeServiceFactory::GetForProfile(profile), | 446 ThemeServiceFactory::GetForProfile(profile), |
| 445 new_theme, | 447 new_theme, |
| 446 previous_theme_id, | 448 previous_theme_id, |
| 447 previous_using_native_theme); | 449 previous_using_native_theme); |
| 448 } | 450 } |
| OLD | NEW |