| 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/web_applications/web_app_ui.h" | 5 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/extensions/image_loader.h" | 13 #include "chrome/browser/extensions/image_loader.h" |
| 14 #include "chrome/browser/extensions/tab_helper.h" | 14 #include "chrome/browser/extensions/tab_helper.h" |
| 15 #include "chrome/browser/favicon/favicon_tab_helper.h" | 15 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 16 #include "chrome/browser/favicon/favicon_util.h" | 16 #include "chrome/browser/favicon/favicon_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/web_applications/web_app.h" | 18 #include "chrome/browser/web_applications/web_app.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/extensions/api/icons/icons_handler.h" | 20 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 21 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
| 22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
| 24 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
| 25 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| 26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/common/content_constants.h" |
| 27 #include "googleurl/src/gurl.h" | 28 #include "googleurl/src/gurl.h" |
| 28 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 29 #include "skia/ext/image_operations.h" | 30 #include "skia/ext/image_operations.h" |
| 30 #include "third_party/skia/include/core/SkBitmap.h" | 31 #include "third_party/skia/include/core/SkBitmap.h" |
| 31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 32 | 33 |
| 33 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 34 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 34 #include "base/environment.h" | 35 #include "base/environment.h" |
| 35 #endif | 36 #endif |
| 36 | 37 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 166 } |
| 166 | 167 |
| 167 if (unprocessed_icons_.empty()) { | 168 if (unprocessed_icons_.empty()) { |
| 168 // No app icon. Just use the favicon from WebContents. | 169 // No app icon. Just use the favicon from WebContents. |
| 169 UpdateShortcuts(); | 170 UpdateShortcuts(); |
| 170 return; | 171 return; |
| 171 } | 172 } |
| 172 | 173 |
| 173 web_contents_->DownloadFavicon( | 174 web_contents_->DownloadFavicon( |
| 174 unprocessed_icons_.back().url, | 175 unprocessed_icons_.back().url, |
| 176 content::DOWNLOAD_FAVICON, |
| 175 std::max(unprocessed_icons_.back().width, | 177 std::max(unprocessed_icons_.back().width, |
| 176 unprocessed_icons_.back().height), | 178 unprocessed_icons_.back().height), |
| 177 base::Bind(&UpdateShortcutWorker::DidDownloadFavicon, | 179 base::Bind(&UpdateShortcutWorker::DidDownloadFavicon, |
| 178 base::Unretained(this))); | 180 base::Unretained(this))); |
| 179 unprocessed_icons_.pop_back(); | 181 unprocessed_icons_.pop_back(); |
| 180 } | 182 } |
| 181 | 183 |
| 182 void UpdateShortcutWorker::DidDownloadFavicon( | 184 void UpdateShortcutWorker::DidDownloadFavicon( |
| 183 int id, | 185 int id, |
| 184 const GURL& image_url, | 186 const GURL& image_url, |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 } | 438 } |
| 437 | 439 |
| 438 // |info_list| may still be empty at this point, in which case LoadImage | 440 // |info_list| may still be empty at this point, in which case LoadImage |
| 439 // will call the OnImageLoaded callback with an empty image and exit | 441 // will call the OnImageLoaded callback with an empty image and exit |
| 440 // immediately. | 442 // immediately. |
| 441 extensions::ImageLoader::Get(profile)->LoadImagesAsync(&extension, info_list, | 443 extensions::ImageLoader::Get(profile)->LoadImagesAsync(&extension, info_list, |
| 442 base::Bind(&OnImageLoaded, shortcut_info, callback)); | 444 base::Bind(&OnImageLoaded, shortcut_info, callback)); |
| 443 } | 445 } |
| 444 | 446 |
| 445 } // namespace web_app | 447 } // namespace web_app |
| OLD | NEW |