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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/sequenced_task_runner_helpers.h"
12 #include "chrome/browser/shell_integration.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "ui/base/gtk/gtk_signal.h"
17 using content::BrowserThread
;
19 typedef struct _GdkPixbuf GdkPixbuf
;
20 typedef struct _GtkWidget GtkWidget
;
21 typedef struct _GtkWindow GtkWindow
;
29 namespace extensions
{
37 class CreateApplicationShortcutsDialogGtk
38 : public base::RefCountedThreadSafe
<CreateApplicationShortcutsDialogGtk
,
39 BrowserThread::DeleteOnUIThread
> {
41 explicit CreateApplicationShortcutsDialogGtk(GtkWindow
* parent
);
42 virtual ~CreateApplicationShortcutsDialogGtk();
44 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk
, void,
45 OnCreateDialogResponse
, int);
47 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk
, void,
48 OnErrorDialogResponse
, int);
50 CHROMEGTK_CALLBACK_0(CreateApplicationShortcutsDialogGtk
, void,
53 virtual void CreateDialogBox(GtkWindow
* parent
);
54 virtual void CreateIconPixBuf(const gfx::ImageFamily
& image
);
56 // This method is called after a shortcut is created.
57 // Subclasses can override it to take some action at that time.
58 virtual void OnCreatedShortcut(void) {}
60 virtual void CreateDesktopShortcut(
61 const ShellIntegration::ShortcutInfo
& shortcut_info
,
62 const ShellIntegration::ShortcutLocations
& creation_locations
);
63 virtual void ShowErrorDialog();
68 GtkWidget
* desktop_checkbox_
;
69 GtkWidget
* menu_checkbox_
;
71 // ShortcutInfo for the new shortcut.
72 ShellIntegration::ShortcutInfo shortcut_info_
;
73 // If false the shortcut will be created in the top-level menu.
74 bool create_in_chrome_apps_subdir_
;
76 // Image associated with the site or app, scaled to the appropriate size to
77 // display in the dialog box.
78 GdkPixbuf
* favicon_pixbuf_
;
80 // Dialog box that allows the user to create an application shortcut.
81 GtkWidget
* create_dialog_
;
83 // Dialog box that shows the error message.
84 GtkWidget
* error_dialog_
;
87 friend struct BrowserThread::DeleteOnThread
<BrowserThread::UI
>;
88 friend class base::DeleteHelper
<CreateApplicationShortcutsDialogGtk
>;
89 DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutsDialogGtk
);
92 class CreateWebApplicationShortcutsDialogGtk
93 : public CreateApplicationShortcutsDialogGtk
{
95 // Displays the dialog box to create application shortcuts for |web_contents|.
96 static void Show(GtkWindow
* parent
, content::WebContents
* web_contents
);
98 CreateWebApplicationShortcutsDialogGtk(GtkWindow
* parent
,
99 content::WebContents
* web_contents
);
101 virtual void OnCreatedShortcut(void) OVERRIDE
;
104 virtual ~CreateWebApplicationShortcutsDialogGtk() {}
107 // WebContents for which the shortcut will be created.
108 content::WebContents
* web_contents_
;
110 DISALLOW_COPY_AND_ASSIGN(CreateWebApplicationShortcutsDialogGtk
);
113 class CreateChromeApplicationShortcutsDialogGtk
114 : public CreateApplicationShortcutsDialogGtk
{
116 CreateChromeApplicationShortcutsDialogGtk(
119 const extensions::Extension
* app
,
120 const base::Closure
& close_callback
);
123 virtual ~CreateChromeApplicationShortcutsDialogGtk();
125 virtual void CreateDesktopShortcut(
126 const ShellIntegration::ShortcutInfo
& shortcut_info
,
127 const ShellIntegration::ShortcutLocations
& creation_locations
) OVERRIDE
;
130 void OnShortcutInfoLoaded(
131 const ShellIntegration::ShortcutInfo
& shortcut_info
);
133 const extensions::Extension
* app_
;
134 base::FilePath profile_path_
;
135 base::Closure close_callback_
;
136 DISALLOW_COPY_AND_ASSIGN(CreateChromeApplicationShortcutsDialogGtk
);
139 #endif // CHROME_BROWSER_UI_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_