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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 205 } |
206 | 206 |
207 void CreateApplicationShortcutsDialogGtk::OnCreateDialogResponse( | 207 void CreateApplicationShortcutsDialogGtk::OnCreateDialogResponse( |
208 GtkWidget* widget, int response) { | 208 GtkWidget* widget, int response) { |
209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
210 | 210 |
211 if (response == GTK_RESPONSE_ACCEPT) { | 211 if (response == GTK_RESPONSE_ACCEPT) { |
212 ShellIntegration::ShortcutLocations creation_locations; | 212 ShellIntegration::ShortcutLocations creation_locations; |
213 creation_locations.on_desktop = | 213 creation_locations.on_desktop = |
214 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(desktop_checkbox_)); | 214 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(desktop_checkbox_)); |
215 creation_locations.in_applications_menu = | 215 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(menu_checkbox_))) { |
216 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(menu_checkbox_)); | 216 creation_locations.applications_menu_location = |
217 creation_locations.applications_menu_subdir = shortcut_menu_subdir_; | 217 create_in_chrome_apps_subdir_ ? |
| 218 ShellIntegration::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS : |
| 219 ShellIntegration::APP_MENU_LOCATION_ROOT; |
| 220 } |
218 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 221 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
219 base::Bind(&CreateApplicationShortcutsDialogGtk::CreateDesktopShortcut, | 222 base::Bind(&CreateApplicationShortcutsDialogGtk::CreateDesktopShortcut, |
220 this, shortcut_info_, creation_locations)); | 223 this, shortcut_info_, creation_locations)); |
221 | 224 |
222 OnCreatedShortcut(); | 225 OnCreatedShortcut(); |
223 } else { | 226 } else { |
224 Release(); | 227 Release(); |
225 } | 228 } |
226 } | 229 } |
227 | 230 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 CreateWebApplicationShortcutsDialogGtk::CreateWebApplicationShortcutsDialogGtk( | 296 CreateWebApplicationShortcutsDialogGtk::CreateWebApplicationShortcutsDialogGtk( |
294 GtkWindow* parent, | 297 GtkWindow* parent, |
295 content::WebContents* web_contents) | 298 content::WebContents* web_contents) |
296 : CreateApplicationShortcutsDialogGtk(parent), | 299 : CreateApplicationShortcutsDialogGtk(parent), |
297 web_contents_(web_contents) { | 300 web_contents_(web_contents) { |
298 | 301 |
299 // Get shortcut information now, it's needed for our UI. | 302 // Get shortcut information now, it's needed for our UI. |
300 web_app::GetShortcutInfoForTab(web_contents, &shortcut_info_); | 303 web_app::GetShortcutInfoForTab(web_contents, &shortcut_info_); |
301 CreateIconPixBuf(shortcut_info_.favicon); | 304 CreateIconPixBuf(shortcut_info_.favicon); |
302 | 305 |
303 // NOTE: Leave shortcut_menu_subdir_ blank to create URL app shortcuts in the | 306 // Create URL app shortcuts in the top-level menu. |
304 // top-level menu. | 307 create_in_chrome_apps_subdir_ = false; |
305 | 308 |
306 CreateDialogBox(parent); | 309 CreateDialogBox(parent); |
307 } | 310 } |
308 | 311 |
309 void CreateWebApplicationShortcutsDialogGtk::OnCreatedShortcut() { | 312 void CreateWebApplicationShortcutsDialogGtk::OnCreatedShortcut() { |
310 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | 313 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
311 if (browser) | 314 if (browser) |
312 chrome::ConvertTabToAppWindow(browser, web_contents_); | 315 chrome::ConvertTabToAppWindow(browser, web_contents_); |
313 } | 316 } |
314 | 317 |
315 CreateChromeApplicationShortcutsDialogGtk:: | 318 CreateChromeApplicationShortcutsDialogGtk:: |
316 CreateChromeApplicationShortcutsDialogGtk( | 319 CreateChromeApplicationShortcutsDialogGtk( |
317 GtkWindow* parent, | 320 GtkWindow* parent, |
318 Profile* profile, | 321 Profile* profile, |
319 const Extension* app, | 322 const Extension* app, |
320 const base::Closure& close_callback) | 323 const base::Closure& close_callback) |
321 : CreateApplicationShortcutsDialogGtk(parent), | 324 : CreateApplicationShortcutsDialogGtk(parent), |
322 app_(app), | 325 app_(app), |
323 profile_path_(profile->GetPath()), | 326 profile_path_(profile->GetPath()), |
324 close_callback_(close_callback) { | 327 close_callback_(close_callback) { |
325 | 328 |
326 // Place Chrome app shortcuts in the "Chrome Apps" submenu. | 329 // Place Chrome app shortcuts in the "Chrome Apps" submenu. |
327 shortcut_menu_subdir_ = web_app::GetAppShortcutsSubdirName(); | 330 create_in_chrome_apps_subdir_ = true; |
328 | 331 |
329 // Get shortcut information and icon now; they are needed for our UI. | 332 // Get shortcut information and icon now; they are needed for our UI. |
330 web_app::UpdateShortcutInfoAndIconForApp( | 333 web_app::UpdateShortcutInfoAndIconForApp( |
331 *app, profile, | 334 *app, profile, |
332 base::Bind( | 335 base::Bind( |
333 &CreateChromeApplicationShortcutsDialogGtk::OnShortcutInfoLoaded, | 336 &CreateChromeApplicationShortcutsDialogGtk::OnShortcutInfoLoaded, |
334 this)); | 337 this)); |
335 } | 338 } |
336 | 339 |
337 CreateChromeApplicationShortcutsDialogGtk:: | 340 CreateChromeApplicationShortcutsDialogGtk:: |
(...skipping 19 matching lines...) Expand all Loading... |
357 if (web_app::CreateShortcutsOnFileThread( | 360 if (web_app::CreateShortcutsOnFileThread( |
358 shortcut_info, creation_locations, | 361 shortcut_info, creation_locations, |
359 web_app::SHORTCUT_CREATION_BY_USER)) { | 362 web_app::SHORTCUT_CREATION_BY_USER)) { |
360 Release(); | 363 Release(); |
361 } else { | 364 } else { |
362 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 365 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
363 base::Bind(&CreateChromeApplicationShortcutsDialogGtk::ShowErrorDialog, | 366 base::Bind(&CreateChromeApplicationShortcutsDialogGtk::ShowErrorDialog, |
364 this)); | 367 this)); |
365 } | 368 } |
366 } | 369 } |
OLD | NEW |