| 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/bundle_installer.h" | 10 #include "chrome/browser/extensions/bundle_installer.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // Adds a Skia image as an icon control to the given container. | 42 // Adds a Skia image as an icon control to the given container. |
| 43 void AddResourceIcon(const SkBitmap* icon, void* data) { | 43 void AddResourceIcon(const SkBitmap* icon, void* data) { |
| 44 GtkWidget* container = static_cast<GtkWidget*>(data); | 44 GtkWidget* container = static_cast<GtkWidget*>(data); |
| 45 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(*icon); | 45 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(*icon); |
| 46 GtkWidget* icon_widget = gtk_image_new_from_pixbuf(icon_pixbuf); | 46 GtkWidget* icon_widget = gtk_image_new_from_pixbuf(icon_pixbuf); |
| 47 g_object_unref(icon_pixbuf); | 47 g_object_unref(icon_pixbuf); |
| 48 gtk_box_pack_start(GTK_BOX(container), icon_widget, FALSE, FALSE, 0); | 48 gtk_box_pack_start(GTK_BOX(container), icon_widget, FALSE, FALSE, 0); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Displays the dialog when constructed, deletes itself when dialog is | 51 // Displays the dialog when constructed, deletes itself when dialog is |
| 52 // dismissed. Success/failure is passed back through the ExtensionInstallUI:: | 52 // dismissed. Success/failure is passed back through the |
| 53 // Delegate instance. | 53 // ExtensionInstallPrompt::Delegate instance. |
| 54 class ExtensionInstallDialog { | 54 class ExtensionInstallDialog { |
| 55 public: | 55 public: |
| 56 ExtensionInstallDialog(GtkWindow* parent, | 56 ExtensionInstallDialog(GtkWindow* parent, |
| 57 ExtensionInstallUI::Delegate *delegate, | 57 ExtensionInstallPrompt::Delegate *delegate, |
| 58 const ExtensionInstallUI::Prompt& prompt); | 58 const ExtensionInstallPrompt::Prompt& prompt); |
| 59 private: | 59 private: |
| 60 ~ExtensionInstallDialog(); | 60 ~ExtensionInstallDialog(); |
| 61 | 61 |
| 62 CHROMEGTK_CALLBACK_1(ExtensionInstallDialog, void, OnResponse, int); | 62 CHROMEGTK_CALLBACK_1(ExtensionInstallDialog, void, OnResponse, int); |
| 63 CHROMEGTK_CALLBACK_0(ExtensionInstallDialog, void, OnStoreLinkClick); | 63 CHROMEGTK_CALLBACK_0(ExtensionInstallDialog, void, OnStoreLinkClick); |
| 64 | 64 |
| 65 ExtensionInstallUI::Delegate* delegate_; | 65 ExtensionInstallPrompt::Delegate* delegate_; |
| 66 std::string extension_id_; // Set for INLINE_INSTALL_PROMPT. | 66 std::string extension_id_; // Set for INLINE_INSTALL_PROMPT. |
| 67 GtkWidget* dialog_; | 67 GtkWidget* dialog_; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 ExtensionInstallDialog::ExtensionInstallDialog( | 70 ExtensionInstallDialog::ExtensionInstallDialog( |
| 71 GtkWindow* parent, | 71 GtkWindow* parent, |
| 72 ExtensionInstallUI::Delegate *delegate, | 72 ExtensionInstallPrompt::Delegate *delegate, |
| 73 const ExtensionInstallUI::Prompt& prompt) | 73 const ExtensionInstallPrompt::Prompt& prompt) |
| 74 : delegate_(delegate), | 74 : delegate_(delegate), |
| 75 dialog_(NULL) { | 75 dialog_(NULL) { |
| 76 bool show_permissions = prompt.GetPermissionCount() > 0; | 76 bool show_permissions = prompt.GetPermissionCount() > 0; |
| 77 bool is_inline_install = | 77 bool is_inline_install = |
| 78 prompt.type() == ExtensionInstallUI::INLINE_INSTALL_PROMPT; | 78 prompt.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT; |
| 79 bool is_bundle_install = | 79 bool is_bundle_install = |
| 80 prompt.type() == ExtensionInstallUI::BUNDLE_INSTALL_PROMPT; | 80 prompt.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT; |
| 81 | 81 |
| 82 if (is_inline_install) | 82 if (is_inline_install) |
| 83 extension_id_ = prompt.extension()->id(); | 83 extension_id_ = prompt.extension()->id(); |
| 84 | 84 |
| 85 // Build the dialog. | 85 // Build the dialog. |
| 86 dialog_ = gtk_dialog_new_with_buttons( | 86 dialog_ = gtk_dialog_new_with_buttons( |
| 87 UTF16ToUTF8(prompt.GetDialogTitle()).c_str(), | 87 UTF16ToUTF8(prompt.GetDialogTitle()).c_str(), |
| 88 parent, | 88 parent, |
| 89 GTK_DIALOG_MODAL, | 89 GTK_DIALOG_MODAL, |
| 90 NULL); | 90 NULL); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 store_url, content::Referrer(), NEW_FOREGROUND_TAB, | 257 store_url, content::Referrer(), NEW_FOREGROUND_TAB, |
| 258 content::PAGE_TRANSITION_LINK, false)); | 258 content::PAGE_TRANSITION_LINK, false)); |
| 259 | 259 |
| 260 OnResponse(dialog_, GTK_RESPONSE_CLOSE); | 260 OnResponse(dialog_, GTK_RESPONSE_CLOSE); |
| 261 } | 261 } |
| 262 | 262 |
| 263 } // namespace | 263 } // namespace |
| 264 | 264 |
| 265 void ShowExtensionInstallDialogImpl( | 265 void ShowExtensionInstallDialogImpl( |
| 266 Profile* profile, | 266 Profile* profile, |
| 267 ExtensionInstallUI::Delegate* delegate, | 267 ExtensionInstallPrompt::Delegate* delegate, |
| 268 const ExtensionInstallUI::Prompt& prompt) { | 268 const ExtensionInstallPrompt::Prompt& prompt) { |
| 269 Browser* browser = browser::FindLastActiveWithProfile(profile); | 269 Browser* browser = browser::FindLastActiveWithProfile(profile); |
| 270 if (!browser) { | 270 if (!browser) { |
| 271 delegate->InstallUIAbort(false); | 271 delegate->InstallUIAbort(false); |
| 272 return; | 272 return; |
| 273 } | 273 } |
| 274 | 274 |
| 275 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( | 275 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( |
| 276 browser->window()); | 276 browser->window()); |
| 277 if (!browser_window) { | 277 if (!browser_window) { |
| 278 delegate->InstallUIAbort(false); | 278 delegate->InstallUIAbort(false); |
| 279 return; | 279 return; |
| 280 } | 280 } |
| 281 | 281 |
| 282 new ExtensionInstallDialog(browser_window->window(), delegate, prompt); | 282 new ExtensionInstallDialog(browser_window->window(), delegate, prompt); |
| 283 } | 283 } |
| OLD | NEW |