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

Unified Diff: chrome/browser/extensions/extension_generic_dialog.cc

Issue 6721013: extensions: Refactor ExtensionInstallUI class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add SetIcon and call it Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_generic_dialog.cc
diff --git a/chrome/browser/extensions/extension_generic_dialog.cc b/chrome/browser/extensions/extension_generic_dialog.cc
new file mode 100644
index 0000000000000000000000000000000000000000..78b6fb8f677265b1e41a3fcd2ff91dda0971fd51
--- /dev/null
+++ b/chrome/browser/extensions/extension_generic_dialog.cc
@@ -0,0 +1,92 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_generic_dialog.h"
+
+#include "base/logging.h"
+#include "base/message_loop.h"
+#include "chrome/browser/extensions/extension_install_dialog.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_icon_set.h"
+#include "chrome/common/extensions/extension_resource.h"
+#include "grit/theme_resources.h"
+#include "ui/base/resource/resource_bundle.h"
+
+// Size of extension icon in top left of dialog.
+static const int kIconSize = 69;
+
+ExtensionGenericDialog::ExtensionGenericDialog(Profile* profile)
+ : profile_(profile),
+ ui_loop_(MessageLoop::current()),
+ delegate_(NULL),
+ extension_(NULL),
+ dialog_type_(DIALOG_NUM_TYPES),
+ ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) {
+}
+
+ExtensionGenericDialog::~ExtensionGenericDialog() {
+}
+
+void ExtensionGenericDialog::ConfirmUninstall(Delegate* delegate,
+ const Extension* extension) {
+ DCHECK(ui_loop_ == MessageLoop::current());
+ delegate_ = delegate;
+ extension_ = extension;
+
+ ShowConfirmation(DIALOG_UNINSTALL);
+}
+
+void ExtensionGenericDialog::ConfirmReenable(Delegate* delegate,
+ const Extension* extension) {
+ DCHECK(ui_loop_ == MessageLoop::current());
+ delegate_ = delegate;
+ extension_ = extension;
+
+ ShowConfirmation(DIALOG_RE_ENABLE);
+}
+
+void ExtensionGenericDialog::ShowConfirmation(DialogType dialog_type) {
+ dialog_type_ = dialog_type;
+ ExtensionResource image =
+ extension_->GetIconResource(Extension::EXTENSION_ICON_LARGE,
+ ExtensionIconSet::MATCH_EXACTLY);
+ // Load the image asynchronously. The response will be sent to OnImageLoaded.
+ tracker_.LoadImage(extension_, image,
+ gfx::Size(kIconSize, kIconSize),
+ ImageLoadingTracker::DONT_CACHE);
+}
+
+void ExtensionGenericDialog::SetIcon(SkBitmap* image) {
+ if (image)
+ icon_ = *image;
+ else
+ icon_ = SkBitmap();
+ if (icon_.empty()) {
+ if (extension_->is_app()) {
+ icon_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_APP_DEFAULT_ICON);
+ } else {
+ icon_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_EXTENSION_DEFAULT_ICON);
+ }
+ }
+}
+
+void ExtensionGenericDialog::OnImageLoaded(SkBitmap* image,
+ const ExtensionResource& resource,
+ int index) {
+ SetIcon(image);
+
+ switch (dialog_type_) {
+ case DIALOG_UNINSTALL: {
+// ShowGenericExtensionDialog(
+// profile_, delegate_, extension_, &icon_, DIALOG_UNINSTALL);
+ break;
+ }
+ default:
+ NOTREACHED() << "Unknown message";
+ break;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698