| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| 11 #include "chrome/browser/extensions/extension_tab_helper.h" | 11 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 12 #include "chrome/browser/favicon_tab_helper.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/web_applications/web_app.h" | 14 #include "chrome/browser/web_applications/web_app.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/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 16 #include "content/browser/browser_thread.h" | 17 #include "content/browser/browser_thread.h" |
| 17 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
| 18 #include "content/common/notification_registrar.h" | 19 #include "content/common/notification_registrar.h" |
| 19 | 20 |
| 20 #if defined(OS_LINUX) | 21 #if defined(OS_LINUX) |
| 21 #include "base/environment.h" | 22 #include "base/environment.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 DeleteMe(); // We are done if underlying TabContents is gone. | 127 DeleteMe(); // We are done if underlying TabContents is gone. |
| 127 return; | 128 return; |
| 128 } | 129 } |
| 129 | 130 |
| 130 if (unprocessed_icons_.empty()) { | 131 if (unprocessed_icons_.empty()) { |
| 131 // No app icon. Just use the favicon from TabContents. | 132 // No app icon. Just use the favicon from TabContents. |
| 132 UpdateShortcuts(); | 133 UpdateShortcuts(); |
| 133 return; | 134 return; |
| 134 } | 135 } |
| 135 | 136 |
| 136 tab_contents_->tab_contents()->favicon_helper().DownloadImage( | 137 tab_contents_->favicon_tab_helper()->DownloadImage( |
| 137 unprocessed_icons_.back().url, | 138 unprocessed_icons_.back().url, |
| 138 std::max(unprocessed_icons_.back().width, | 139 std::max(unprocessed_icons_.back().width, |
| 139 unprocessed_icons_.back().height), | 140 unprocessed_icons_.back().height), |
| 140 NewCallback(this, &UpdateShortcutWorker::OnIconDownloaded)); | 141 NewCallback(this, &UpdateShortcutWorker::OnIconDownloaded)); |
| 141 unprocessed_icons_.pop_back(); | 142 unprocessed_icons_.pop_back(); |
| 142 } | 143 } |
| 143 | 144 |
| 144 void UpdateShortcutWorker::OnIconDownloaded(int download_id, | 145 void UpdateShortcutWorker::OnIconDownloaded(int download_id, |
| 145 bool errored, | 146 bool errored, |
| 146 const SkBitmap& image) { | 147 const SkBitmap& image) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 const WebApplicationInfo& app_info = | 297 const WebApplicationInfo& app_info = |
| 297 tab_contents_wrapper->extension_tab_helper()->web_app_info(); | 298 tab_contents_wrapper->extension_tab_helper()->web_app_info(); |
| 298 | 299 |
| 299 info->url = app_info.app_url.is_empty() ? tab_contents->GetURL() : | 300 info->url = app_info.app_url.is_empty() ? tab_contents->GetURL() : |
| 300 app_info.app_url; | 301 app_info.app_url; |
| 301 info->title = app_info.title.empty() ? | 302 info->title = app_info.title.empty() ? |
| 302 (tab_contents->GetTitle().empty() ? UTF8ToUTF16(info->url.spec()) : | 303 (tab_contents->GetTitle().empty() ? UTF8ToUTF16(info->url.spec()) : |
| 303 tab_contents->GetTitle()) : | 304 tab_contents->GetTitle()) : |
| 304 app_info.title; | 305 app_info.title; |
| 305 info->description = app_info.description; | 306 info->description = app_info.description; |
| 306 info->favicon = tab_contents->GetFavicon(); | 307 info->favicon = tab_contents_wrapper->favicon_tab_helper()->GetFavicon(); |
| 307 } | 308 } |
| 308 | 309 |
| 309 void UpdateShortcutForTabContents(TabContentsWrapper* tab_contents) { | 310 void UpdateShortcutForTabContents(TabContentsWrapper* tab_contents) { |
| 310 #if defined(OS_WIN) | 311 #if defined(OS_WIN) |
| 311 // UpdateShortcutWorker will delete itself when it's done. | 312 // UpdateShortcutWorker will delete itself when it's done. |
| 312 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); | 313 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); |
| 313 worker->Run(); | 314 worker->Run(); |
| 314 #endif // defined(OS_WIN) | 315 #endif // defined(OS_WIN) |
| 315 } | 316 } |
| 316 | 317 |
| 317 } // namespace web_app | 318 } // namespace web_app |
| OLD | NEW |