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