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 friend class BrowserThread; |
Aaron Boodman
2010/11/30 00:29:28
I usually see friend declarations inside private b
Sam Kerner (Chrome)
2010/11/30 01:21:04
Done.
| |
26 // Displays the dialog box to create application shortcuts for |tab_contents|. | 28 friend class DeleteTask<CreateApplicationShortcutsDialogGtk>; |
27 static void Show(GtkWindow* parent, TabContents* tab_contents); | |
28 | 29 |
29 private: | 30 protected: |
30 friend class BrowserThread; | 31 explicit CreateApplicationShortcutsDialogGtk(GtkWindow* parent); |
31 friend class DeleteTask<CreateApplicationShortcutsDialogGtk>; | |
32 | |
33 CreateApplicationShortcutsDialogGtk(GtkWindow* parent, | |
34 TabContents* tab_contents); | |
35 virtual ~CreateApplicationShortcutsDialogGtk(); | 32 virtual ~CreateApplicationShortcutsDialogGtk(); |
36 | 33 |
37 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk, void, | 34 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk, void, |
38 OnCreateDialogResponse, int); | 35 OnCreateDialogResponse, int); |
39 | 36 |
40 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk, void, | 37 CHROMEGTK_CALLBACK_1(CreateApplicationShortcutsDialogGtk, void, |
41 OnErrorDialogResponse, int); | 38 OnErrorDialogResponse, int); |
42 | 39 |
43 CHROMEGTK_CALLBACK_0(CreateApplicationShortcutsDialogGtk, void, | 40 CHROMEGTK_CALLBACK_0(CreateApplicationShortcutsDialogGtk, void, |
44 OnToggleCheckbox); | 41 OnToggleCheckbox); |
45 | 42 |
43 virtual void CreateDialogBox(GtkWindow* parent); | |
44 virtual void CreateIconPixBuf(const SkBitmap& bitmap); | |
45 virtual void OnCreatedShortcut(void) = 0; | |
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 DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutsDialogGtk); | 69 DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutsDialogGtk); |
70 }; | 70 }; |
71 | 71 |
72 class CreateWebApplicationShortcutsDialogGtk | |
73 : public CreateApplicationShortcutsDialogGtk { | |
74 public: | |
75 // Displays the dialog box to create application shortcuts for |tab_contents|. | |
76 static void Show(GtkWindow* parent, TabContents* tab_contents); | |
77 | |
78 explicit CreateWebApplicationShortcutsDialogGtk(GtkWindow* parent, | |
79 TabContents* tab_contents); | |
80 virtual ~CreateWebApplicationShortcutsDialogGtk() {} | |
81 | |
82 virtual void OnCreatedShortcut(void); | |
83 | |
84 private: | |
85 | |
86 // TabContents for which the shortcut will be created. | |
87 TabContents* tab_contents_; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(CreateWebApplicationShortcutsDialogGtk); | |
90 }; | |
91 | |
92 class CreateChromeApplicationShortcutsDialogGtk | |
93 : public CreateApplicationShortcutsDialogGtk, | |
94 public ImageLoadingTracker::Observer { | |
95 public: | |
96 // Displays the dialog box to create application shortcuts for |app|. | |
97 static void Show(GtkWindow* parent, const Extension* app); | |
98 | |
99 explicit CreateChromeApplicationShortcutsDialogGtk(GtkWindow* parent, | |
100 const Extension* app); | |
101 virtual ~CreateChromeApplicationShortcutsDialogGtk() {} | |
102 | |
103 virtual void OnCreatedShortcut(void); | |
104 | |
105 // Implement ImageLoadingTracker::Observer. |tracker_| is used to | |
106 // load the app's icon. This method recieves the icon, and adds | |
107 // it to the "Create Shortcut" dailog box. | |
108 virtual void OnImageLoaded(SkBitmap* image, | |
109 ExtensionResource resource, | |
110 int index); | |
111 | |
112 private: | |
113 const Extension* app_; | |
114 ImageLoadingTracker tracker_; | |
115 DISALLOW_COPY_AND_ASSIGN(CreateChromeApplicationShortcutsDialogGtk); | |
116 }; | |
117 | |
72 #endif // CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_ | 118 #endif // CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_ |
OLD | NEW |