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 #include "chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h" | 5 #include "chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/env_var.h" | 10 #include "base/env_var.h" |
11 #include "chrome/browser/chrome_thread.h" | 11 #include "chrome/browser/chrome_thread.h" |
12 #include "chrome/browser/gtk/gtk_util.h" | 12 #include "chrome/browser/gtk/gtk_util.h" |
13 #include "chrome/browser/shell_integration.h" | 13 #include "chrome/browser/shell_integration.h" |
14 #include "chrome/browser/tab_contents/tab_contents.h" | 14 #include "chrome/browser/tab_contents/tab_contents.h" |
15 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 15 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
| 16 #include "chrome/browser/web_applications/web_app.h" |
16 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
18 #include "grit/locale_settings.h" | 19 #include "grit/locale_settings.h" |
19 | 20 |
20 // static | 21 // static |
21 void CreateApplicationShortcutsDialogGtk::Show(GtkWindow* parent, | 22 void CreateApplicationShortcutsDialogGtk::Show(GtkWindow* parent, |
22 TabContents* tab_contents) { | 23 TabContents* tab_contents) { |
23 new CreateApplicationShortcutsDialogGtk(parent, tab_contents); | 24 new CreateApplicationShortcutsDialogGtk(parent, tab_contents); |
24 } | 25 } |
25 | 26 |
26 CreateApplicationShortcutsDialogGtk::CreateApplicationShortcutsDialogGtk( | 27 CreateApplicationShortcutsDialogGtk::CreateApplicationShortcutsDialogGtk( |
27 GtkWindow* parent, | 28 GtkWindow* parent, |
28 TabContents* tab_contents) | 29 TabContents* tab_contents) |
29 : tab_contents_(tab_contents), | 30 : tab_contents_(tab_contents), |
30 url_(tab_contents->GetURL()), | |
31 title_(tab_contents->GetTitle()), | |
32 favicon_(tab_contents->FavIconIsValid() ? tab_contents->GetFavIcon() : | |
33 SkBitmap()), | |
34 error_dialog_(NULL) { | 31 error_dialog_(NULL) { |
35 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 32 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
36 | 33 |
37 // Will be balanced by Release later. | 34 // Will be balanced by Release later. |
38 AddRef(); | 35 AddRef(); |
39 | 36 |
40 // Build the dialog. | 37 // Build the dialog. |
41 create_dialog_ = gtk_dialog_new_with_buttons( | 38 create_dialog_ = gtk_dialog_new_with_buttons( |
42 l10n_util::GetStringUTF8(IDS_CREATE_SHORTCUTS_TITLE).c_str(), | 39 l10n_util::GetStringUTF8(IDS_CREATE_SHORTCUTS_TITLE).c_str(), |
43 parent, | 40 parent, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 if (error_dialog_) | 88 if (error_dialog_) |
92 gtk_widget_destroy(error_dialog_); | 89 gtk_widget_destroy(error_dialog_); |
93 } | 90 } |
94 | 91 |
95 void CreateApplicationShortcutsDialogGtk::OnCreateDialogResponse( | 92 void CreateApplicationShortcutsDialogGtk::OnCreateDialogResponse( |
96 GtkWidget* widget, int response) { | 93 GtkWidget* widget, int response) { |
97 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 94 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
98 | 95 |
99 if (response == GTK_RESPONSE_ACCEPT) { | 96 if (response == GTK_RESPONSE_ACCEPT) { |
100 ShellIntegration::ShortcutInfo shortcut_info; | 97 ShellIntegration::ShortcutInfo shortcut_info; |
101 shortcut_info.url = url_; | 98 web_app::GetShortcutInfoForTab(tab_contents_, &shortcut_info); |
102 shortcut_info.title = title_; | |
103 shortcut_info.favicon = favicon_; | |
104 shortcut_info.create_on_desktop = | 99 shortcut_info.create_on_desktop = |
105 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(desktop_checkbox_)); | 100 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(desktop_checkbox_)); |
106 shortcut_info.create_in_applications_menu = | 101 shortcut_info.create_in_applications_menu = |
107 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(menu_checkbox_)); | 102 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(menu_checkbox_)); |
108 ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE, | 103 ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE, |
109 NewRunnableMethod(this, | 104 NewRunnableMethod(this, |
110 &CreateApplicationShortcutsDialogGtk::CreateDesktopShortcut, | 105 &CreateApplicationShortcutsDialogGtk::CreateDesktopShortcut, |
111 shortcut_info)); | 106 shortcut_info)); |
112 | 107 |
113 if (tab_contents_->delegate()) | 108 if (tab_contents_->delegate()) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 IDS_CREATE_SHORTCUTS_ERROR_LABEL, | 167 IDS_CREATE_SHORTCUTS_ERROR_LABEL, |
173 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)).c_str()); | 168 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)).c_str()); |
174 gtk_label_set_line_wrap(GTK_LABEL(description), TRUE); | 169 gtk_label_set_line_wrap(GTK_LABEL(description), TRUE); |
175 gtk_misc_set_alignment(GTK_MISC(description), 0, 0); | 170 gtk_misc_set_alignment(GTK_MISC(description), 0, 0); |
176 gtk_box_pack_start(GTK_BOX(vbox), description, FALSE, FALSE, 0); | 171 gtk_box_pack_start(GTK_BOX(vbox), description, FALSE, FALSE, 0); |
177 | 172 |
178 g_signal_connect(error_dialog_, "response", | 173 g_signal_connect(error_dialog_, "response", |
179 G_CALLBACK(OnErrorDialogResponseThunk), this); | 174 G_CALLBACK(OnErrorDialogResponseThunk), this); |
180 gtk_widget_show_all(error_dialog_); | 175 gtk_widget_show_all(error_dialog_); |
181 } | 176 } |
OLD | NEW |