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

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

Issue 10699057: Move application creation and extension install prompt showing off Browser and onto ExtensionTabHel… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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"
11 #include "chrome/browser/extensions/extension_install_dialog.h" 11 #include "chrome/browser/extensions/extension_install_dialog.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/browser_list.h"
15 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 13 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
17 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" 14 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
18 #include "chrome/browser/ui/gtk/gtk_util.h" 15 #include "chrome/browser/ui/gtk/gtk_util.h"
19 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "content/public/browser/page_navigator.h"
20 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
21 #include "skia/ext/image_operations.h" 19 #include "skia/ext/image_operations.h"
22 #include "ui/base/gtk/gtk_hig_constants.h" 20 #include "ui/base/gtk/gtk_hig_constants.h"
23 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/gfx/gtk_util.h" 23 #include "ui/gfx/gtk_util.h"
26 24
27 using content::OpenURLParams; 25 using content::OpenURLParams;
28 using extensions::BundleInstaller; 26 using extensions::BundleInstaller;
29 27
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 75
78 } // namespace 76 } // namespace
79 77
80 namespace browser { 78 namespace browser {
81 79
82 // Displays the dialog when constructed, deletes itself when dialog is 80 // Displays the dialog when constructed, deletes itself when dialog is
83 // dismissed. Success/failure is passed back through the 81 // dismissed. Success/failure is passed back through the
84 // ExtensionInstallPrompt::Delegate instance. 82 // ExtensionInstallPrompt::Delegate instance.
85 class ExtensionInstallDialog { 83 class ExtensionInstallDialog {
86 public: 84 public:
87 ExtensionInstallDialog(Browser* browser, 85 ExtensionInstallDialog(gfx::NativeWindow parent,
88 GtkWindow* parent, 86 content::PageNavigator* navigator,
89 ExtensionInstallPrompt::Delegate *delegate, 87 ExtensionInstallPrompt::Delegate *delegate,
90 const ExtensionInstallPrompt::Prompt& prompt); 88 const ExtensionInstallPrompt::Prompt& prompt);
91 private: 89 private:
92 ~ExtensionInstallDialog(); 90 ~ExtensionInstallDialog();
93 91
94 CHROMEGTK_CALLBACK_1(ExtensionInstallDialog, void, OnResponse, int); 92 CHROMEGTK_CALLBACK_1(ExtensionInstallDialog, void, OnResponse, int);
95 CHROMEGTK_CALLBACK_0(ExtensionInstallDialog, void, OnStoreLinkClick); 93 CHROMEGTK_CALLBACK_0(ExtensionInstallDialog, void, OnStoreLinkClick);
96 94
97 GtkWidget* CreateWidgetForIssueAdvice( 95 GtkWidget* CreateWidgetForIssueAdvice(
98 const IssueAdviceInfoEntry& issue_advice, int pixel_width); 96 const IssueAdviceInfoEntry& issue_advice, int pixel_width);
99 97
100 Browser* browser_; 98 content::PageNavigator* navigator_;
101 ExtensionInstallPrompt::Delegate* delegate_; 99 ExtensionInstallPrompt::Delegate* delegate_;
102 std::string extension_id_; // Set for INLINE_INSTALL_PROMPT. 100 std::string extension_id_; // Set for INLINE_INSTALL_PROMPT.
103 GtkWidget* dialog_; 101 GtkWidget* dialog_;
104 }; 102 };
105 103
106 ExtensionInstallDialog::ExtensionInstallDialog( 104 ExtensionInstallDialog::ExtensionInstallDialog(
107 Browser* browser, 105 gfx::NativeWindow parent,
108 GtkWindow* parent, 106 content::PageNavigator* navigator,
109 ExtensionInstallPrompt::Delegate *delegate, 107 ExtensionInstallPrompt::Delegate *delegate,
110 const ExtensionInstallPrompt::Prompt& prompt) 108 const ExtensionInstallPrompt::Prompt& prompt)
111 : browser_(browser), 109 : navigator_(navigator),
112 delegate_(delegate), 110 delegate_(delegate),
113 dialog_(NULL) { 111 dialog_(NULL) {
114 bool show_permissions = prompt.GetPermissionCount() > 0; 112 bool show_permissions = prompt.GetPermissionCount() > 0;
115 bool show_oauth_issues = prompt.GetOAuthIssueCount() > 0; 113 bool show_oauth_issues = prompt.GetOAuthIssueCount() > 0;
116 bool is_inline_install = 114 bool is_inline_install =
117 prompt.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT; 115 prompt.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT;
118 bool is_bundle_install = 116 bool is_bundle_install =
119 prompt.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT; 117 prompt.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT;
120 118
121 if (is_inline_install) 119 if (is_inline_install)
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 else 306 else
309 delegate_->InstallUIAbort(true); 307 delegate_->InstallUIAbort(true);
310 308
311 gtk_widget_destroy(dialog_); 309 gtk_widget_destroy(dialog_);
312 delete this; 310 delete this;
313 } 311 }
314 312
315 void ExtensionInstallDialog::OnStoreLinkClick(GtkWidget* sender) { 313 void ExtensionInstallDialog::OnStoreLinkClick(GtkWidget* sender) {
316 GURL store_url( 314 GURL store_url(
317 extension_urls::GetWebstoreItemDetailURLPrefix() + extension_id_); 315 extension_urls::GetWebstoreItemDetailURLPrefix() + extension_id_);
318 browser_->OpenURL(OpenURLParams( 316 navigator_->OpenURL(OpenURLParams(
319 store_url, content::Referrer(), NEW_FOREGROUND_TAB, 317 store_url, content::Referrer(), NEW_FOREGROUND_TAB,
320 content::PAGE_TRANSITION_LINK, false)); 318 content::PAGE_TRANSITION_LINK, false));
321 319
322 OnResponse(dialog_, GTK_RESPONSE_CLOSE); 320 OnResponse(dialog_, GTK_RESPONSE_CLOSE);
323 } 321 }
324 322
325 GtkWidget* ExtensionInstallDialog::CreateWidgetForIssueAdvice( 323 GtkWidget* ExtensionInstallDialog::CreateWidgetForIssueAdvice(
326 const IssueAdviceInfoEntry& issue_advice, int pixel_width) { 324 const IssueAdviceInfoEntry& issue_advice, int pixel_width) {
327 GtkWidget* box = gtk_vbox_new(FALSE, ui::kControlSpacing); 325 GtkWidget* box = gtk_vbox_new(FALSE, ui::kControlSpacing);
328 GtkWidget* header = gtk_hbox_new(FALSE, 0); 326 GtkWidget* header = gtk_hbox_new(FALSE, 0);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 if (arrow) 373 if (arrow)
376 gtk_box_pack_start(GTK_BOX(header), arrow, FALSE, FALSE, 0); 374 gtk_box_pack_start(GTK_BOX(header), arrow, FALSE, FALSE, 0);
377 gtk_box_pack_start(GTK_BOX(header), label, TRUE, TRUE, 0); 375 gtk_box_pack_start(GTK_BOX(header), label, TRUE, TRUE, 0);
378 376
379 return box; 377 return box;
380 } 378 }
381 379
382 } // namespace browser 380 } // namespace browser
383 381
384 void ShowExtensionInstallDialogImpl( 382 void ShowExtensionInstallDialogImpl(
385 Browser* browser, 383 gfx::NativeWindow parent,
384 content::PageNavigator* navigator,
386 ExtensionInstallPrompt::Delegate* delegate, 385 ExtensionInstallPrompt::Delegate* delegate,
387 const ExtensionInstallPrompt::Prompt& prompt) { 386 const ExtensionInstallPrompt::Prompt& prompt) {
388 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( 387 new browser::ExtensionInstallDialog(parent, navigator, delegate, prompt);
389 browser->window());
390 if (!browser_window) {
391 delegate->InstallUIAbort(false);
392 return;
393 }
394
395 new browser::ExtensionInstallDialog(browser, browser_window->window(),
396 delegate, prompt);
397 } 388 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc ('k') | chrome/browser/ui/panels/panel_browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698