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/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" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 void UpdateShortcutWorker::OnIconDownloaded(int download_id, | 155 void UpdateShortcutWorker::OnIconDownloaded(int download_id, |
156 bool errored, | 156 bool errored, |
157 const SkBitmap& image) { | 157 const SkBitmap& image) { |
158 if (tab_contents_ == NULL) { | 158 if (tab_contents_ == NULL) { |
159 DeleteMe(); // We are done if underlying TabContents is gone. | 159 DeleteMe(); // We are done if underlying TabContents is gone. |
160 return; | 160 return; |
161 } | 161 } |
162 | 162 |
163 if (!errored && !image.isNull()) { | 163 if (!errored && !image.isNull()) { |
164 // Update icon with download image and update shortcut. | 164 // Update icon with download image and update shortcut. |
165 shortcut_info_.favicon = image; | 165 shortcut_info_.favicon = gfx::Image(image); |
166 tab_contents_->extension_tab_helper()->SetAppIcon(image); | 166 tab_contents_->extension_tab_helper()->SetAppIcon(image); |
167 UpdateShortcuts(); | 167 UpdateShortcuts(); |
168 } else { | 168 } else { |
169 // Try the next icon otherwise. | 169 // Try the next icon otherwise. |
170 DownloadIcon(); | 170 DownloadIcon(); |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 void UpdateShortcutWorker::CheckExistingShortcuts() { | 174 void UpdateShortcutWorker::CheckExistingShortcuts() { |
175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 const WebApplicationInfo& app_info = | 302 const WebApplicationInfo& app_info = |
303 tab_contents_wrapper->extension_tab_helper()->web_app_info(); | 303 tab_contents_wrapper->extension_tab_helper()->web_app_info(); |
304 | 304 |
305 info->url = app_info.app_url.is_empty() ? web_contents->GetURL() : | 305 info->url = app_info.app_url.is_empty() ? web_contents->GetURL() : |
306 app_info.app_url; | 306 app_info.app_url; |
307 info->title = app_info.title.empty() ? | 307 info->title = app_info.title.empty() ? |
308 (web_contents->GetTitle().empty() ? UTF8ToUTF16(info->url.spec()) : | 308 (web_contents->GetTitle().empty() ? UTF8ToUTF16(info->url.spec()) : |
309 web_contents->GetTitle()) : | 309 web_contents->GetTitle()) : |
310 app_info.title; | 310 app_info.title; |
311 info->description = app_info.description; | 311 info->description = app_info.description; |
312 info->favicon = tab_contents_wrapper->favicon_tab_helper()->GetFavicon(); | 312 info->favicon = |
| 313 gfx::Image(tab_contents_wrapper->favicon_tab_helper()->GetFavicon()); |
313 } | 314 } |
314 | 315 |
315 void UpdateShortcutForTabContents(TabContentsWrapper* tab_contents) { | 316 void UpdateShortcutForTabContents(TabContentsWrapper* tab_contents) { |
316 #if defined(OS_WIN) | 317 #if defined(OS_WIN) |
317 // UpdateShortcutWorker will delete itself when it's done. | 318 // UpdateShortcutWorker will delete itself when it's done. |
318 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); | 319 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); |
319 worker->Run(); | 320 worker->Run(); |
320 #endif // defined(OS_WIN) | 321 #endif // defined(OS_WIN) |
321 } | 322 } |
322 | 323 |
323 } // namespace web_app | 324 } // namespace web_app |
OLD | NEW |