OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/ui/gtk/create_application_shortcuts_dialog_gtk.h" | 5 #include "chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 void CreateApplicationShortcutsDialogGtk::OnCreateDialogResponse( | 208 void CreateApplicationShortcutsDialogGtk::OnCreateDialogResponse( |
209 GtkWidget* widget, int response) { | 209 GtkWidget* widget, int response) { |
210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
211 | 211 |
212 if (response == GTK_RESPONSE_ACCEPT) { | 212 if (response == GTK_RESPONSE_ACCEPT) { |
213 ShellIntegration::ShortcutLocations creation_locations; | 213 ShellIntegration::ShortcutLocations creation_locations; |
214 creation_locations.on_desktop = | 214 creation_locations.on_desktop = |
215 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(desktop_checkbox_)); | 215 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(desktop_checkbox_)); |
216 creation_locations.in_applications_menu = | 216 creation_locations.in_applications_menu = |
217 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(menu_checkbox_)); | 217 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(menu_checkbox_)); |
| 218 creation_locations.applications_menu_subdir = shortcut_menu_subdir_; |
218 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 219 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
219 base::Bind(&CreateApplicationShortcutsDialogGtk::CreateDesktopShortcut, | 220 base::Bind(&CreateApplicationShortcutsDialogGtk::CreateDesktopShortcut, |
220 this, shortcut_info_, creation_locations)); | 221 this, shortcut_info_, creation_locations)); |
221 | 222 |
222 OnCreatedShortcut(); | 223 OnCreatedShortcut(); |
223 } else { | 224 } else { |
224 Release(); | 225 Release(); |
225 } | 226 } |
226 } | 227 } |
227 | 228 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 CreateWebApplicationShortcutsDialogGtk::CreateWebApplicationShortcutsDialogGtk( | 294 CreateWebApplicationShortcutsDialogGtk::CreateWebApplicationShortcutsDialogGtk( |
294 GtkWindow* parent, | 295 GtkWindow* parent, |
295 content::WebContents* web_contents) | 296 content::WebContents* web_contents) |
296 : CreateApplicationShortcutsDialogGtk(parent), | 297 : CreateApplicationShortcutsDialogGtk(parent), |
297 web_contents_(web_contents) { | 298 web_contents_(web_contents) { |
298 | 299 |
299 // Get shortcut information now, it's needed for our UI. | 300 // Get shortcut information now, it's needed for our UI. |
300 web_app::GetShortcutInfoForTab(web_contents, &shortcut_info_); | 301 web_app::GetShortcutInfoForTab(web_contents, &shortcut_info_); |
301 CreateIconPixBuf(shortcut_info_.favicon); | 302 CreateIconPixBuf(shortcut_info_.favicon); |
302 | 303 |
| 304 // NOTE: Leave shortcut_menu_subdir_ blank to create URL app shortcuts in the |
| 305 // top-level menu. |
| 306 |
303 CreateDialogBox(parent); | 307 CreateDialogBox(parent); |
304 } | 308 } |
305 | 309 |
306 void CreateWebApplicationShortcutsDialogGtk::OnCreatedShortcut() { | 310 void CreateWebApplicationShortcutsDialogGtk::OnCreatedShortcut() { |
307 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | 311 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
308 if (browser) | 312 if (browser) |
309 chrome::ConvertTabToAppWindow(browser, web_contents_); | 313 chrome::ConvertTabToAppWindow(browser, web_contents_); |
310 } | 314 } |
311 | 315 |
312 CreateChromeApplicationShortcutsDialogGtk:: | 316 CreateChromeApplicationShortcutsDialogGtk:: |
313 CreateChromeApplicationShortcutsDialogGtk( | 317 CreateChromeApplicationShortcutsDialogGtk( |
314 GtkWindow* parent, | 318 GtkWindow* parent, |
315 Profile* profile, | 319 Profile* profile, |
316 const Extension* app) | 320 const Extension* app) |
317 : CreateApplicationShortcutsDialogGtk(parent), | 321 : CreateApplicationShortcutsDialogGtk(parent), |
318 app_(app), | 322 app_(app), |
319 profile_path_(profile->GetPath()) { | 323 profile_path_(profile->GetPath()) { |
320 | 324 |
| 325 // Place Chrome app shortcuts in the "Chrome Apps" submenu. |
| 326 shortcut_menu_subdir_ = |
| 327 l10n_util::GetStringUTF16(IDS_APP_SHORTCUTS_SUBDIR_NAME); |
| 328 |
321 // Get shortcut information and icon now; they are needed for our UI. | 329 // Get shortcut information and icon now; they are needed for our UI. |
322 web_app::UpdateShortcutInfoAndIconForApp( | 330 web_app::UpdateShortcutInfoAndIconForApp( |
323 *app, profile, | 331 *app, profile, |
324 base::Bind( | 332 base::Bind( |
325 &CreateChromeApplicationShortcutsDialogGtk::OnShortcutInfoLoaded, | 333 &CreateChromeApplicationShortcutsDialogGtk::OnShortcutInfoLoaded, |
326 this)); | 334 this)); |
327 } | 335 } |
328 | 336 |
329 // Called when the app's ShortcutInfo (with icon) is loaded. | 337 // Called when the app's ShortcutInfo (with icon) is loaded. |
330 void CreateChromeApplicationShortcutsDialogGtk::OnShortcutInfoLoaded( | 338 void CreateChromeApplicationShortcutsDialogGtk::OnShortcutInfoLoaded( |
(...skipping 10 matching lines...) Expand all Loading... |
341 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 349 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
342 | 350 |
343 if (web_app::CreateShortcutsOnFileThread(shortcut_info, creation_locations)) { | 351 if (web_app::CreateShortcutsOnFileThread(shortcut_info, creation_locations)) { |
344 Release(); | 352 Release(); |
345 } else { | 353 } else { |
346 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 354 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
347 base::Bind(&CreateChromeApplicationShortcutsDialogGtk::ShowErrorDialog, | 355 base::Bind(&CreateChromeApplicationShortcutsDialogGtk::ShowErrorDialog, |
348 this)); | 356 this)); |
349 } | 357 } |
350 } | 358 } |
OLD | NEW |