| 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/extensions/image_loader.h" | 12 #include "chrome/browser/extensions/image_loader.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/shell_integration.h" | 14 #include "chrome/browser/shell_integration.h" |
| 15 #include "chrome/browser/shell_integration_linux.h" | 15 #include "chrome/browser/shell_integration_linux.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_commands.h" | 17 #include "chrome/browser/ui/browser_commands.h" |
| 18 #include "chrome/browser/ui/browser_dialogs.h" | 18 #include "chrome/browser/ui/browser_dialogs.h" |
| 19 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
| 20 #include "chrome/browser/ui/gtk/gtk_util.h" | 20 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 21 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 21 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
| 22 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 22 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 23 #include "chrome/browser/web_applications/web_app.h" | 23 #include "chrome/browser/web_applications/web_app.h" |
| 24 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 24 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/extension_resource.h" | 26 #include "chrome/common/extensions/extension_resource.h" |
| 26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/browser/web_contents_delegate.h" | 29 #include "content/public/browser/web_contents_delegate.h" |
| 29 #include "grit/chromium_strings.h" | 30 #include "grit/chromium_strings.h" |
| 30 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 31 #include "grit/locale_settings.h" | 32 #include "grit/locale_settings.h" |
| 32 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
| 33 #include "ui/base/gtk/gtk_hig_constants.h" | 34 #include "ui/base/gtk/gtk_hig_constants.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 const Extension* app) | 318 const Extension* app) |
| 318 : CreateApplicationShortcutsDialogGtk(parent), | 319 : CreateApplicationShortcutsDialogGtk(parent), |
| 319 app_(app), | 320 app_(app), |
| 320 profile_path_(profile->GetPath()) { | 321 profile_path_(profile->GetPath()) { |
| 321 | 322 |
| 322 // Get shortcut information now, it's needed for our UI. | 323 // Get shortcut information now, it's needed for our UI. |
| 323 web_app::UpdateShortcutInfoForApp(*app, profile, &shortcut_info_); | 324 web_app::UpdateShortcutInfoForApp(*app, profile, &shortcut_info_); |
| 324 | 325 |
| 325 // Get the icon. | 326 // Get the icon. |
| 326 const gfx::Size max_size(kIconPreviewSizePixels, kIconPreviewSizePixels); | 327 const gfx::Size max_size(kIconPreviewSizePixels, kIconPreviewSizePixels); |
| 327 ExtensionResource icon_resource = app_->GetIconResource( | 328 ExtensionResource icon_resource = extensions::IconsInfo::GetIconResource( |
| 328 kIconPreviewSizePixels, ExtensionIconSet::MATCH_BIGGER); | 329 app_, kIconPreviewSizePixels, ExtensionIconSet::MATCH_BIGGER); |
| 329 | 330 |
| 330 // If no icon exists that is the desired size or larger, get the | 331 // If no icon exists that is the desired size or larger, get the |
| 331 // largest icon available: | 332 // largest icon available: |
| 332 if (icon_resource.empty()) | 333 if (icon_resource.empty()) |
| 333 icon_resource = app_->GetIconResource( | 334 icon_resource = extensions::IconsInfo::GetIconResource( |
| 334 kIconPreviewSizePixels, ExtensionIconSet::MATCH_SMALLER); | 335 app_, kIconPreviewSizePixels, ExtensionIconSet::MATCH_SMALLER); |
| 335 | 336 |
| 336 // Load icon asynchronously | 337 // Load icon asynchronously |
| 337 extensions::ImageLoader* loader = extensions::ImageLoader::Get(profile); | 338 extensions::ImageLoader* loader = extensions::ImageLoader::Get(profile); |
| 338 loader->LoadImageAsync(app_, icon_resource, max_size, | 339 loader->LoadImageAsync(app_, icon_resource, max_size, |
| 339 base::Bind(&CreateChromeApplicationShortcutsDialogGtk::OnImageLoaded, | 340 base::Bind(&CreateChromeApplicationShortcutsDialogGtk::OnImageLoaded, |
| 340 this)); | 341 this)); |
| 341 } | 342 } |
| 342 | 343 |
| 343 // Called when the app's icon is loaded. | 344 // Called when the app's icon is loaded. |
| 344 void CreateChromeApplicationShortcutsDialogGtk::OnImageLoaded( | 345 void CreateChromeApplicationShortcutsDialogGtk::OnImageLoaded( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 360 | 361 |
| 361 if (web_app::CreateShortcutsOnFileThread(shortcut_info)) { | 362 if (web_app::CreateShortcutsOnFileThread(shortcut_info)) { |
| 362 Release(); | 363 Release(); |
| 363 } else { | 364 } else { |
| 364 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 365 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 365 base::Bind(&CreateChromeApplicationShortcutsDialogGtk::ShowErrorDialog, | 366 base::Bind(&CreateChromeApplicationShortcutsDialogGtk::ShowErrorDialog, |
| 366 this)); | 367 this)); |
| 367 } | 368 } |
| 368 } | 369 } |
| OLD | NEW |