Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc

Issue 231673005: Move ShortcutInfo, ShortcutLocations from ShellIntegration to web_app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windws Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/shell_integration.h"
14 #include "chrome/browser/shell_integration_linux.h" 13 #include "chrome/browser/shell_integration_linux.h"
15 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_commands.h" 15 #include "chrome/browser/ui/browser_commands.h"
17 #include "chrome/browser/ui/browser_dialogs.h" 16 #include "chrome/browser/ui/browser_dialogs.h"
18 #include "chrome/browser/ui/browser_finder.h" 17 #include "chrome/browser/ui/browser_finder.h"
19 #include "chrome/browser/ui/gtk/gtk_util.h" 18 #include "chrome/browser/ui/gtk/gtk_util.h"
20 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 19 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
21 #include "chrome/browser/web_applications/web_app.h"
22 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
24 #include "content/public/browser/web_contents_delegate.h" 22 #include "content/public/browser/web_contents_delegate.h"
25 #include "extensions/common/extension.h" 23 #include "extensions/common/extension.h"
26 #include "extensions/common/manifest_handlers/icons_handler.h" 24 #include "extensions/common/manifest_handlers/icons_handler.h"
27 #include "grit/chromium_strings.h" 25 #include "grit/chromium_strings.h"
28 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
29 #include "grit/locale_settings.h" 27 #include "grit/locale_settings.h"
30 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
31 #include "ui/base/gtk/gtk_hig_constants.h" 29 #include "ui/base/gtk/gtk_hig_constants.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 gtk_widget_destroy(error_dialog_); 199 gtk_widget_destroy(error_dialog_);
202 200
203 g_object_unref(favicon_pixbuf_); 201 g_object_unref(favicon_pixbuf_);
204 } 202 }
205 203
206 void CreateApplicationShortcutsDialogGtk::OnCreateDialogResponse( 204 void CreateApplicationShortcutsDialogGtk::OnCreateDialogResponse(
207 GtkWidget* widget, int response) { 205 GtkWidget* widget, int response) {
208 DCHECK_CURRENTLY_ON(BrowserThread::UI); 206 DCHECK_CURRENTLY_ON(BrowserThread::UI);
209 207
210 if (response == GTK_RESPONSE_ACCEPT) { 208 if (response == GTK_RESPONSE_ACCEPT) {
211 ShellIntegration::ShortcutLocations creation_locations; 209 web_app::ShortcutLocations creation_locations;
212 creation_locations.on_desktop = 210 creation_locations.on_desktop =
213 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(desktop_checkbox_)); 211 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(desktop_checkbox_));
214 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(menu_checkbox_))) { 212 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(menu_checkbox_))) {
215 creation_locations.applications_menu_location = 213 creation_locations.applications_menu_location =
216 create_in_chrome_apps_subdir_ ? 214 create_in_chrome_apps_subdir_ ?
217 ShellIntegration::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS : 215 web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS :
218 ShellIntegration::APP_MENU_LOCATION_ROOT; 216 web_app::APP_MENU_LOCATION_ROOT;
219 } 217 }
220 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 218 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
221 base::Bind(&CreateApplicationShortcutsDialogGtk::CreateDesktopShortcut, 219 base::Bind(&CreateApplicationShortcutsDialogGtk::CreateDesktopShortcut,
222 this, shortcut_info_, creation_locations)); 220 this, shortcut_info_, creation_locations));
223 221
224 OnCreatedShortcut(); 222 OnCreatedShortcut();
225 } else { 223 } else {
226 Release(); 224 Release();
227 } 225 }
228 } 226 }
229 227
230 void CreateApplicationShortcutsDialogGtk::OnErrorDialogResponse( 228 void CreateApplicationShortcutsDialogGtk::OnErrorDialogResponse(
231 GtkWidget* widget, int response) { 229 GtkWidget* widget, int response) {
232 Release(); 230 Release();
233 } 231 }
234 232
235 void CreateApplicationShortcutsDialogGtk::CreateDesktopShortcut( 233 void CreateApplicationShortcutsDialogGtk::CreateDesktopShortcut(
236 const ShellIntegration::ShortcutInfo& shortcut_info, 234 const web_app::ShortcutInfo& shortcut_info,
237 const ShellIntegration::ShortcutLocations& creation_locations) { 235 const web_app::ShortcutLocations& creation_locations) {
238 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 236 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
239 ShellIntegrationLinux::CreateDesktopShortcut(shortcut_info, 237 ShellIntegrationLinux::CreateDesktopShortcut(shortcut_info,
240 creation_locations); 238 creation_locations);
241 Release(); 239 Release();
242 } 240 }
243 241
244 void CreateApplicationShortcutsDialogGtk::ShowErrorDialog() { 242 void CreateApplicationShortcutsDialogGtk::ShowErrorDialog() {
245 DCHECK_CURRENTLY_ON(BrowserThread::UI); 243 DCHECK_CURRENTLY_ON(BrowserThread::UI);
246 244
247 // Hide the create dialog so that the user can no longer interact with it. 245 // Hide the create dialog so that the user can no longer interact with it.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 335 }
338 336
339 CreateChromeApplicationShortcutsDialogGtk:: 337 CreateChromeApplicationShortcutsDialogGtk::
340 ~CreateChromeApplicationShortcutsDialogGtk() { 338 ~CreateChromeApplicationShortcutsDialogGtk() {
341 if (!close_callback_.is_null()) 339 if (!close_callback_.is_null())
342 close_callback_.Run(); 340 close_callback_.Run();
343 } 341 }
344 342
345 // Called when the app's ShortcutInfo (with icon) is loaded. 343 // Called when the app's ShortcutInfo (with icon) is loaded.
346 void CreateChromeApplicationShortcutsDialogGtk::OnShortcutInfoLoaded( 344 void CreateChromeApplicationShortcutsDialogGtk::OnShortcutInfoLoaded(
347 const ShellIntegration::ShortcutInfo& shortcut_info) { 345 const web_app::ShortcutInfo& shortcut_info) {
348 shortcut_info_ = shortcut_info; 346 shortcut_info_ = shortcut_info;
349 347
350 CreateIconPixBuf(shortcut_info_.favicon); 348 CreateIconPixBuf(shortcut_info_.favicon);
351 CreateDialogBox(parent_); 349 CreateDialogBox(parent_);
352 } 350 }
353 351
354 void CreateChromeApplicationShortcutsDialogGtk::CreateDesktopShortcut( 352 void CreateChromeApplicationShortcutsDialogGtk::CreateDesktopShortcut(
355 const ShellIntegration::ShortcutInfo& shortcut_info, 353 const web_app::ShortcutInfo& shortcut_info,
356 const ShellIntegration::ShortcutLocations& creation_locations) { 354 const web_app::ShortcutLocations& creation_locations) {
357 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 355 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
358 356
359 if (web_app::internals::CreateShortcutsOnFileThread( 357 if (web_app::internals::CreateShortcutsOnFileThread(
360 web_app::SHORTCUT_CREATION_BY_USER, 358 web_app::SHORTCUT_CREATION_BY_USER,
361 creation_locations, 359 creation_locations,
362 shortcut_info)) { 360 shortcut_info)) {
363 Release(); 361 Release();
364 } else { 362 } else {
365 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 363 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
366 base::Bind(&CreateChromeApplicationShortcutsDialogGtk::ShowErrorDialog, 364 base::Bind(&CreateChromeApplicationShortcutsDialogGtk::ShowErrorDialog,
367 this)); 365 this));
368 } 366 }
369 } 367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698