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

Side by Side Diff: chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc

Issue 10388252: Refactoring ExtenionInstallUI to abstract the Browser references. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced + mac fix Created 8 years, 6 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 <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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 } // namespace 51 } // namespace
52 52
53 namespace browser { 53 namespace browser {
54 54
55 // Displays the dialog when constructed, deletes itself when dialog is 55 // Displays the dialog when constructed, deletes itself when dialog is
56 // dismissed. Success/failure is passed back through the ExtensionInstallUI:: 56 // dismissed. Success/failure is passed back through the
57 // Delegate instance. 57 // ExtensionInstallPrompt::Delegate instance.
58 class ExtensionInstallDialog { 58 class ExtensionInstallDialog {
59 public: 59 public:
60 ExtensionInstallDialog(GtkWindow* parent, 60 ExtensionInstallDialog(GtkWindow* parent,
61 ExtensionInstallUI::Delegate *delegate, 61 ExtensionInstallPrompt::Delegate *delegate,
62 const ExtensionInstallUI::Prompt& prompt); 62 const ExtensionInstallPrompt::Prompt& prompt);
63 private: 63 private:
64 ~ExtensionInstallDialog(); 64 ~ExtensionInstallDialog();
65 65
66 CHROMEGTK_CALLBACK_1(ExtensionInstallDialog, void, OnResponse, int); 66 CHROMEGTK_CALLBACK_1(ExtensionInstallDialog, void, OnResponse, int);
67 CHROMEGTK_CALLBACK_0(ExtensionInstallDialog, void, OnStoreLinkClick); 67 CHROMEGTK_CALLBACK_0(ExtensionInstallDialog, void, OnStoreLinkClick);
68 68
69 ExtensionInstallUI::Delegate* delegate_; 69 ExtensionInstallPrompt::Delegate* delegate_;
70 std::string extension_id_; // Set for INLINE_INSTALL_PROMPT. 70 std::string extension_id_; // Set for INLINE_INSTALL_PROMPT.
71 GtkWidget* dialog_; 71 GtkWidget* dialog_;
72 }; 72 };
73 73
74 ExtensionInstallDialog::ExtensionInstallDialog( 74 ExtensionInstallDialog::ExtensionInstallDialog(
75 GtkWindow* parent, 75 GtkWindow* parent,
76 ExtensionInstallUI::Delegate *delegate, 76 ExtensionInstallPrompt::Delegate *delegate,
77 const ExtensionInstallUI::Prompt& prompt) 77 const ExtensionInstallPrompt::Prompt& prompt)
78 : delegate_(delegate), 78 : delegate_(delegate),
79 dialog_(NULL) { 79 dialog_(NULL) {
80 bool show_permissions = prompt.GetPermissionCount() > 0; 80 bool show_permissions = prompt.GetPermissionCount() > 0;
81 bool is_inline_install = 81 bool is_inline_install =
82 prompt.type() == ExtensionInstallUI::INLINE_INSTALL_PROMPT; 82 prompt.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT;
83 bool is_bundle_install = 83 bool is_bundle_install =
84 prompt.type() == ExtensionInstallUI::BUNDLE_INSTALL_PROMPT; 84 prompt.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT;
85 85
86 if (is_inline_install) 86 if (is_inline_install)
87 extension_id_ = prompt.extension()->id(); 87 extension_id_ = prompt.extension()->id();
88 88
89 // Build the dialog. 89 // Build the dialog.
90 dialog_ = gtk_dialog_new_with_buttons( 90 dialog_ = gtk_dialog_new_with_buttons(
91 UTF16ToUTF8(prompt.GetDialogTitle()).c_str(), 91 UTF16ToUTF8(prompt.GetDialogTitle()).c_str(),
92 parent, 92 parent,
93 GTK_DIALOG_MODAL, 93 GTK_DIALOG_MODAL,
94 NULL); 94 NULL);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 store_url, content::Referrer(), NEW_FOREGROUND_TAB, 261 store_url, content::Referrer(), NEW_FOREGROUND_TAB,
262 content::PAGE_TRANSITION_LINK, false)); 262 content::PAGE_TRANSITION_LINK, false));
263 263
264 OnResponse(dialog_, GTK_RESPONSE_CLOSE); 264 OnResponse(dialog_, GTK_RESPONSE_CLOSE);
265 } 265 }
266 266
267 } // namespace browser 267 } // namespace browser
268 268
269 void ShowExtensionInstallDialogImpl( 269 void ShowExtensionInstallDialogImpl(
270 Profile* profile, 270 Profile* profile,
271 ExtensionInstallUI::Delegate* delegate, 271 ExtensionInstallPrompt::Delegate* delegate,
272 const ExtensionInstallUI::Prompt& prompt) { 272 const ExtensionInstallPrompt::Prompt& prompt) {
273 Browser* browser = browser::FindLastActiveWithProfile(profile); 273 Browser* browser = browser::FindLastActiveWithProfile(profile);
274 if (!browser) { 274 if (!browser) {
275 delegate->InstallUIAbort(false); 275 delegate->InstallUIAbort(false);
276 return; 276 return;
277 } 277 }
278 278
279 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( 279 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>(
280 browser->window()); 280 browser->window());
281 if (!browser_window) { 281 if (!browser_window) {
282 delegate->InstallUIAbort(false); 282 delegate->InstallUIAbort(false);
283 return; 283 return;
284 } 284 }
285 285
286 new browser::ExtensionInstallDialog(browser_window->window(), delegate, 286 new browser::ExtensionInstallDialog(browser_window->window(), delegate,
287 prompt); 287 prompt);
288 } 288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698