| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/gtk_signal.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "chrome/browser/browser_thread.h" | 12 #include "chrome/browser/browser_thread.h" |
| 13 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 13 #include "chrome/browser/shell_integration.h" | 14 #include "chrome/browser/shell_integration.h" |
| 14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 15 | 16 |
| 16 typedef struct _GdkPixbuf GdkPixbuf; | 17 typedef struct _GdkPixbuf GdkPixbuf; |
| 17 typedef struct _GtkWidget GtkWidget; | 18 typedef struct _GtkWidget GtkWidget; |
| 18 typedef struct _GtkWindow GtkWindow; | 19 typedef struct _GtkWindow GtkWindow; |
| 19 | 20 |
| 21 class Extension; |
| 20 class TabContents; | 22 class TabContents; |
| 21 | 23 |
| 22 class CreateApplicationShortcutsDialogGtk | 24 class CreateApplicationShortcutsDialogGtk |
| 23 : public base::RefCountedThreadSafe<CreateApplicationShortcutsDialogGtk, | 25 : public base::RefCountedThreadSafe<CreateApplicationShortcutsDialogGtk, |
| 24 BrowserThread::DeleteOnUIThread> { | 26 BrowserThread::DeleteOnUIThread> { |
| 25 public: | 27 protected: |
| 26 // Displays the dialog box to create application shortcuts for |tab_contents|. | 28 explicit CreateApplicationShortcutsDialogGtk(GtkWindow* parent); |
| 27 static void Show(GtkWindow* parent, TabContents* tab_contents); | |
| 28 | |
| 29 private: | |
| 30 friend class BrowserThread; | |
| 31 friend class DeleteTask<CreateApplicationShortcutsDialogGtk>; | |
| 32 | |
| 33 CreateApplicationShortcutsDialogGtk(GtkWindow* parent, | |
| 34 TabContents* tab_contents); | |
| 35 virtual ~CreateApplicationShortcutsDialogGtk(); | 29 virtual ~CreateApplicationShortcutsDialogGtk(); |
| 36 | 30 |
| 37 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk, void, | 31 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk, void, |
| 38 OnCreateDialogResponse, int); | 32 OnCreateDialogResponse, int); |
| 39 | 33 |
| 40 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk, void, | 34 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk, void, |
| 41 OnErrorDialogResponse, int); | 35 OnErrorDialogResponse, int); |
| 42 | 36 |
| 43 CHROMEGTK_CALLBACK_0(CreateApplicationShortcutsDialogGtk, void, | 37 CHROMEGTK_CALLBACK_0(CreateApplicationShortcutsDialogGtk, void, |
| 44 OnToggleCheckbox); | 38 OnToggleCheckbox); |
| 45 | 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 |
| 46 void CreateDesktopShortcut( | 47 void CreateDesktopShortcut( |
| 47 const ShellIntegration::ShortcutInfo& shortcut_info); | 48 const ShellIntegration::ShortcutInfo& shortcut_info); |
| 48 void ShowErrorDialog(); | 49 void ShowErrorDialog(); |
| 49 | 50 |
| 51 GtkWindow* parent_; |
| 52 |
| 50 // UI elements. | 53 // UI elements. |
| 51 GtkWidget* desktop_checkbox_; | 54 GtkWidget* desktop_checkbox_; |
| 52 GtkWidget* menu_checkbox_; | 55 GtkWidget* menu_checkbox_; |
| 53 | 56 |
| 54 // TabContents for which the shortcut will be created. | |
| 55 TabContents* tab_contents_; | |
| 56 | |
| 57 // ShortcutInfo for the new shortcut. | 57 // ShortcutInfo for the new shortcut. |
| 58 ShellIntegration::ShortcutInfo shortcut_info_; | 58 ShellIntegration::ShortcutInfo shortcut_info_; |
| 59 | 59 |
| 60 // Image associated with the site. | 60 // Image associated with the site. |
| 61 GdkPixbuf* favicon_pixbuf_; | 61 GdkPixbuf* favicon_pixbuf_; |
| 62 | 62 |
| 63 // Dialog box that allows the user to create an application shortcut. | 63 // Dialog box that allows the user to create an application shortcut. |
| 64 GtkWidget* create_dialog_; | 64 GtkWidget* create_dialog_; |
| 65 | 65 |
| 66 // Dialog box that shows the error message. | 66 // Dialog box that shows the error message. |
| 67 GtkWidget* error_dialog_; | 67 GtkWidget* error_dialog_; |
| 68 | 68 |
| 69 private: |
| 70 friend class BrowserThread; |
| 71 friend class DeleteTask<CreateApplicationShortcutsDialogGtk>; |
| 69 DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutsDialogGtk); | 72 DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutsDialogGtk); |
| 70 }; | 73 }; |
| 71 | 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 |
| 72 #endif // CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_ | 119 #endif // CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_ |
| OLD | NEW |