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

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 20 matching lines...) Expand all
50 48
51 } // namespace 49 } // namespace
52 50
53 namespace browser { 51 namespace browser {
54 52
55 // Displays the dialog when constructed, deletes itself when dialog is 53 // Displays the dialog when constructed, deletes itself when dialog is
56 // dismissed. Success/failure is passed back through the 54 // dismissed. Success/failure is passed back through the
57 // ExtensionInstallPrompt::Delegate instance. 55 // ExtensionInstallPrompt::Delegate instance.
58 class ExtensionInstallDialog { 56 class ExtensionInstallDialog {
59 public: 57 public:
60 ExtensionInstallDialog(Browser* browser, 58 ExtensionInstallDialog(gfx::NativeWindow parent,
61 GtkWindow* parent, 59 content::PageNavigator* navigator,
62 ExtensionInstallPrompt::Delegate *delegate, 60 ExtensionInstallPrompt::Delegate *delegate,
63 const ExtensionInstallPrompt::Prompt& prompt); 61 const ExtensionInstallPrompt::Prompt& prompt);
64 private: 62 private:
65 ~ExtensionInstallDialog(); 63 ~ExtensionInstallDialog();
66 64
67 CHROMEGTK_CALLBACK_1(ExtensionInstallDialog, void, OnResponse, int); 65 CHROMEGTK_CALLBACK_1(ExtensionInstallDialog, void, OnResponse, int);
68 CHROMEGTK_CALLBACK_0(ExtensionInstallDialog, void, OnStoreLinkClick); 66 CHROMEGTK_CALLBACK_0(ExtensionInstallDialog, void, OnStoreLinkClick);
69 67
70 Browser* browser_; 68 content::PageNavigator* navigator_;
71 ExtensionInstallPrompt::Delegate* delegate_; 69 ExtensionInstallPrompt::Delegate* delegate_;
72 std::string extension_id_; // Set for INLINE_INSTALL_PROMPT. 70 std::string extension_id_; // Set for INLINE_INSTALL_PROMPT.
73 GtkWidget* dialog_; 71 GtkWidget* dialog_;
74 }; 72 };
75 73
76 ExtensionInstallDialog::ExtensionInstallDialog( 74 ExtensionInstallDialog::ExtensionInstallDialog(
77 Browser* browser, 75 gfx::NativeWindow parent,
78 GtkWindow* parent, 76 content::PageNavigator* navigator,
79 ExtensionInstallPrompt::Delegate *delegate, 77 ExtensionInstallPrompt::Delegate *delegate,
80 const ExtensionInstallPrompt::Prompt& prompt) 78 const ExtensionInstallPrompt::Prompt& prompt)
81 : browser_(browser), 79 : navigator_(navigator),
82 delegate_(delegate), 80 delegate_(delegate),
83 dialog_(NULL) { 81 dialog_(NULL) {
84 bool show_permissions = prompt.GetPermissionCount() > 0; 82 bool show_permissions = prompt.GetPermissionCount() > 0;
85 bool show_oauth_issues = prompt.GetOAuthIssueCount() > 0; 83 bool show_oauth_issues = prompt.GetOAuthIssueCount() > 0;
86 bool is_inline_install = 84 bool is_inline_install =
87 prompt.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT; 85 prompt.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT;
88 bool is_bundle_install = 86 bool is_bundle_install =
89 prompt.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT; 87 prompt.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT;
90 88
91 if (is_inline_install) 89 if (is_inline_install)
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 delegate_->InstallUIAbort(true); 278 delegate_->InstallUIAbort(true);
281 } 279 }
282 280
283 gtk_widget_destroy(dialog_); 281 gtk_widget_destroy(dialog_);
284 delete this; 282 delete this;
285 } 283 }
286 284
287 void ExtensionInstallDialog::OnStoreLinkClick(GtkWidget* sender) { 285 void ExtensionInstallDialog::OnStoreLinkClick(GtkWidget* sender) {
288 GURL store_url( 286 GURL store_url(
289 extension_urls::GetWebstoreItemDetailURLPrefix() + extension_id_); 287 extension_urls::GetWebstoreItemDetailURLPrefix() + extension_id_);
290 browser_->OpenURL(OpenURLParams( 288 navigator_->OpenURL(OpenURLParams(
291 store_url, content::Referrer(), NEW_FOREGROUND_TAB, 289 store_url, content::Referrer(), NEW_FOREGROUND_TAB,
292 content::PAGE_TRANSITION_LINK, false)); 290 content::PAGE_TRANSITION_LINK, false));
293 291
294 OnResponse(dialog_, GTK_RESPONSE_CLOSE); 292 OnResponse(dialog_, GTK_RESPONSE_CLOSE);
295 } 293 }
296 294
297 } // namespace browser 295 } // namespace browser
298 296
299 void ShowExtensionInstallDialogImpl( 297 void ShowExtensionInstallDialogImpl(
300 Browser* browser, 298 gfx::NativeWindow parent,
299 content::PageNavigator* navigator,
301 ExtensionInstallPrompt::Delegate* delegate, 300 ExtensionInstallPrompt::Delegate* delegate,
302 const ExtensionInstallPrompt::Prompt& prompt) { 301 const ExtensionInstallPrompt::Prompt& prompt) {
303 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( 302 new browser::ExtensionInstallDialog(parent, navigator, delegate, prompt);
304 browser->window());
305 if (!browser_window) {
306 delegate->InstallUIAbort(false);
307 return;
308 }
309
310 new browser::ExtensionInstallDialog(browser, browser_window->window(),
311 delegate, prompt);
312 } 303 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698