| 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" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/shell_integration.h" | 13 #include "chrome/browser/shell_integration.h" |
| 13 #include "chrome/browser/ui/gtk/gtk_util.h" | 14 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 15 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 16 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
| 16 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 17 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 18 #include "chrome/browser/web_applications/web_app.h" |
| 17 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
| 18 #include "chrome/common/extensions/extension_resource.h" | 20 #include "chrome/common/extensions/extension_resource.h" |
| 19 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/browser/web_contents_delegate.h" | 23 #include "content/public/browser/web_contents_delegate.h" |
| 22 #include "grit/chromium_strings.h" | 24 #include "grit/chromium_strings.h" |
| 23 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 24 #include "grit/locale_settings.h" | 26 #include "grit/locale_settings.h" |
| 25 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 26 #include "ui/base/gtk/gtk_hig_constants.h" | 28 #include "ui/base/gtk/gtk_hig_constants.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 40 | 42 |
| 41 } // namespace | 43 } // namespace |
| 42 | 44 |
| 43 // static | 45 // static |
| 44 void CreateWebApplicationShortcutsDialogGtk::Show( | 46 void CreateWebApplicationShortcutsDialogGtk::Show( |
| 45 GtkWindow* parent, TabContentsWrapper* tab_contents) { | 47 GtkWindow* parent, TabContentsWrapper* tab_contents) { |
| 46 new CreateWebApplicationShortcutsDialogGtk(parent, tab_contents); | 48 new CreateWebApplicationShortcutsDialogGtk(parent, tab_contents); |
| 47 } | 49 } |
| 48 | 50 |
| 49 void CreateChromeApplicationShortcutsDialogGtk::Show(GtkWindow* parent, | 51 void CreateChromeApplicationShortcutsDialogGtk::Show(GtkWindow* parent, |
| 52 Profile* profile, |
| 50 const Extension* app) { | 53 const Extension* app) { |
| 51 new CreateChromeApplicationShortcutsDialogGtk(parent, app); | 54 new CreateChromeApplicationShortcutsDialogGtk(parent, profile, app); |
| 52 } | 55 } |
| 53 | 56 |
| 54 | 57 |
| 55 CreateApplicationShortcutsDialogGtk::CreateApplicationShortcutsDialogGtk( | 58 CreateApplicationShortcutsDialogGtk::CreateApplicationShortcutsDialogGtk( |
| 56 GtkWindow* parent) | 59 GtkWindow* parent) |
| 57 : parent_(parent), | 60 : parent_(parent), |
| 58 desktop_checkbox_(NULL), | 61 desktop_checkbox_(NULL), |
| 59 menu_checkbox_(NULL), | 62 menu_checkbox_(NULL), |
| 60 favicon_pixbuf_(NULL), | 63 favicon_pixbuf_(NULL), |
| 61 create_dialog_(NULL), | 64 create_dialog_(NULL), |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 297 |
| 295 void CreateWebApplicationShortcutsDialogGtk::OnCreatedShortcut() { | 298 void CreateWebApplicationShortcutsDialogGtk::OnCreatedShortcut() { |
| 296 if (tab_contents_->web_contents()->GetDelegate()) | 299 if (tab_contents_->web_contents()->GetDelegate()) |
| 297 tab_contents_->web_contents()->GetDelegate()->ConvertContentsToApplication( | 300 tab_contents_->web_contents()->GetDelegate()->ConvertContentsToApplication( |
| 298 tab_contents_->web_contents()); | 301 tab_contents_->web_contents()); |
| 299 } | 302 } |
| 300 | 303 |
| 301 CreateChromeApplicationShortcutsDialogGtk:: | 304 CreateChromeApplicationShortcutsDialogGtk:: |
| 302 CreateChromeApplicationShortcutsDialogGtk( | 305 CreateChromeApplicationShortcutsDialogGtk( |
| 303 GtkWindow* parent, | 306 GtkWindow* parent, |
| 307 Profile* profile, |
| 304 const Extension* app) | 308 const Extension* app) |
| 305 : CreateApplicationShortcutsDialogGtk(parent), | 309 : CreateApplicationShortcutsDialogGtk(parent), |
| 306 app_(app), | 310 app_(app), |
| 311 profile_path_(profile->GetPath()), |
| 307 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { | 312 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { |
| 308 | 313 |
| 309 // Get shortcut information now, it's needed for our UI. | 314 // Get shortcut information now, it's needed for our UI. |
| 310 shortcut_info_.extension_id = app_->id(); | 315 shortcut_info_.extension_id = app_->id(); |
| 316 shortcut_info_.extension_path = app_->path(); |
| 317 shortcut_info_.is_platform_app = app_->is_platform_app(); |
| 311 shortcut_info_.url = GURL(app_->launch_web_url()); | 318 shortcut_info_.url = GURL(app_->launch_web_url()); |
| 312 shortcut_info_.title = UTF8ToUTF16(app_->name()); | 319 shortcut_info_.title = UTF8ToUTF16(app_->name()); |
| 313 shortcut_info_.description = UTF8ToUTF16(app_->description()); | 320 shortcut_info_.description = UTF8ToUTF16(app_->description()); |
| 314 | 321 |
| 315 // Get the icon. | 322 // Get the icon. |
| 316 const gfx::Size max_size(kIconPreviewSizePixels, kIconPreviewSizePixels); | 323 const gfx::Size max_size(kIconPreviewSizePixels, kIconPreviewSizePixels); |
| 317 ExtensionResource icon_resource = app_->GetIconResource( | 324 ExtensionResource icon_resource = app_->GetIconResource( |
| 318 kIconPreviewSizePixels, ExtensionIconSet::MATCH_BIGGER); | 325 kIconPreviewSizePixels, ExtensionIconSet::MATCH_BIGGER); |
| 319 | 326 |
| 320 // If no icon exists that is the desired size or larger, get the | 327 // If no icon exists that is the desired size or larger, get the |
| (...skipping 19 matching lines...) Expand all Loading... |
| 340 if (image.IsEmpty()) { | 347 if (image.IsEmpty()) { |
| 341 shortcut_info_.favicon = | 348 shortcut_info_.favicon = |
| 342 ResourceBundle::GetSharedInstance().GetImageNamed(IDR_APP_DEFAULT_ICON); | 349 ResourceBundle::GetSharedInstance().GetImageNamed(IDR_APP_DEFAULT_ICON); |
| 343 } else { | 350 } else { |
| 344 shortcut_info_.favicon = image; | 351 shortcut_info_.favicon = image; |
| 345 } | 352 } |
| 346 | 353 |
| 347 CreateIconPixBuf(shortcut_info_.favicon); | 354 CreateIconPixBuf(shortcut_info_.favicon); |
| 348 CreateDialogBox(parent_); | 355 CreateDialogBox(parent_); |
| 349 } | 356 } |
| 357 |
| 358 void CreateChromeApplicationShortcutsDialogGtk::CreateDesktopShortcut( |
| 359 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 361 |
| 362 if (web_app::CreateShortcutOnFileThread(profile_path_, shortcut_info)) { |
| 363 Release(); |
| 364 } else { |
| 365 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 366 base::Bind(&CreateChromeApplicationShortcutsDialogGtk::ShowErrorDialog, |
| 367 this)); |
| 368 } |
| 369 } |
| OLD | NEW |