| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_ | 6 #define CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/gtk_signal.h" | 9 #include "chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h" |
| 10 #include "base/basictypes.h" | 10 // TODO(msw): remove this file once all includes have been updated. |
| 11 #include "base/ref_counted.h" | |
| 12 #include "chrome/browser/browser_thread.h" | |
| 13 #include "chrome/browser/extensions/image_loading_tracker.h" | |
| 14 #include "chrome/browser/shell_integration.h" | |
| 15 #include "googleurl/src/gurl.h" | |
| 16 | |
| 17 typedef struct _GdkPixbuf GdkPixbuf; | |
| 18 typedef struct _GtkWidget GtkWidget; | |
| 19 typedef struct _GtkWindow GtkWindow; | |
| 20 | |
| 21 class Extension; | |
| 22 class TabContents; | |
| 23 | |
| 24 class CreateApplicationShortcutsDialogGtk | |
| 25 : public base::RefCountedThreadSafe<CreateApplicationShortcutsDialogGtk, | |
| 26 BrowserThread::DeleteOnUIThread> { | |
| 27 protected: | |
| 28 explicit CreateApplicationShortcutsDialogGtk(GtkWindow* parent); | |
| 29 virtual ~CreateApplicationShortcutsDialogGtk(); | |
| 30 | |
| 31 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk, void, | |
| 32 OnCreateDialogResponse, int); | |
| 33 | |
| 34 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk, void, | |
| 35 OnErrorDialogResponse, int); | |
| 36 | |
| 37 CHROMEGTK_CALLBACK_0(CreateApplicationShortcutsDialogGtk, void, | |
| 38 OnToggleCheckbox); | |
| 39 | |
| 40 virtual void CreateDialogBox(GtkWindow* parent); | |
| 41 virtual void CreateIconPixBuf(const SkBitmap& bitmap); | |
| 42 | |
| 43 // This method is called after a shortcut is created. | |
| 44 // Subclasses can override it to take some action at that time. | |
| 45 virtual void OnCreatedShortcut(void) {} | |
| 46 | |
| 47 void CreateDesktopShortcut( | |
| 48 const ShellIntegration::ShortcutInfo& shortcut_info); | |
| 49 void ShowErrorDialog(); | |
| 50 | |
| 51 GtkWindow* parent_; | |
| 52 | |
| 53 // UI elements. | |
| 54 GtkWidget* desktop_checkbox_; | |
| 55 GtkWidget* menu_checkbox_; | |
| 56 | |
| 57 // ShortcutInfo for the new shortcut. | |
| 58 ShellIntegration::ShortcutInfo shortcut_info_; | |
| 59 | |
| 60 // Image associated with the site. | |
| 61 GdkPixbuf* favicon_pixbuf_; | |
| 62 | |
| 63 // Dialog box that allows the user to create an application shortcut. | |
| 64 GtkWidget* create_dialog_; | |
| 65 | |
| 66 // Dialog box that shows the error message. | |
| 67 GtkWidget* error_dialog_; | |
| 68 | |
| 69 private: | |
| 70 friend class BrowserThread; | |
| 71 friend class DeleteTask<CreateApplicationShortcutsDialogGtk>; | |
| 72 DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutsDialogGtk); | |
| 73 }; | |
| 74 | |
| 75 class CreateWebApplicationShortcutsDialogGtk | |
| 76 : public CreateApplicationShortcutsDialogGtk { | |
| 77 public: | |
| 78 // Displays the dialog box to create application shortcuts for |tab_contents|. | |
| 79 static void Show(GtkWindow* parent, TabContents* tab_contents); | |
| 80 | |
| 81 explicit CreateWebApplicationShortcutsDialogGtk(GtkWindow* parent, | |
| 82 TabContents* tab_contents); | |
| 83 virtual ~CreateWebApplicationShortcutsDialogGtk() {} | |
| 84 | |
| 85 virtual void OnCreatedShortcut(void); | |
| 86 | |
| 87 private: | |
| 88 | |
| 89 // TabContents for which the shortcut will be created. | |
| 90 TabContents* tab_contents_; | |
| 91 | |
| 92 DISALLOW_COPY_AND_ASSIGN(CreateWebApplicationShortcutsDialogGtk); | |
| 93 }; | |
| 94 | |
| 95 class CreateChromeApplicationShortcutsDialogGtk | |
| 96 : public CreateApplicationShortcutsDialogGtk, | |
| 97 public ImageLoadingTracker::Observer { | |
| 98 public: | |
| 99 // Displays the dialog box to create application shortcuts for |app|. | |
| 100 static void Show(GtkWindow* parent, const Extension* app); | |
| 101 | |
| 102 explicit CreateChromeApplicationShortcutsDialogGtk(GtkWindow* parent, | |
| 103 const Extension* app); | |
| 104 virtual ~CreateChromeApplicationShortcutsDialogGtk() {} | |
| 105 | |
| 106 // Implement ImageLoadingTracker::Observer. |tracker_| is used to | |
| 107 // load the app's icon. This method recieves the icon, and adds | |
| 108 // it to the "Create Shortcut" dailog box. | |
| 109 virtual void OnImageLoaded(SkBitmap* image, | |
| 110 ExtensionResource resource, | |
| 111 int index); | |
| 112 | |
| 113 private: | |
| 114 const Extension* app_; | |
| 115 ImageLoadingTracker tracker_; | |
| 116 DISALLOW_COPY_AND_ASSIGN(CreateChromeApplicationShortcutsDialogGtk); | |
| 117 }; | |
| 118 | 11 |
| 119 #endif // CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_ | 12 #endif // CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_ |
| OLD | NEW |