Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: chrome/browser/ui/web_applications/web_app_ui.cc

Issue 11011002: Switch FaviconTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 DeleteMe(); // We are done if underlying WebContents is gone. 141 DeleteMe(); // We are done if underlying WebContents is gone.
142 return; 142 return;
143 } 143 }
144 144
145 if (unprocessed_icons_.empty()) { 145 if (unprocessed_icons_.empty()) {
146 // No app icon. Just use the favicon from WebContents. 146 // No app icon. Just use the favicon from WebContents.
147 UpdateShortcuts(); 147 UpdateShortcuts();
148 return; 148 return;
149 } 149 }
150 150
151 tab_contents_->favicon_tab_helper()->DownloadImage( 151 FaviconTabHelper::FromWebContents(tab_contents_->web_contents())->
152 unprocessed_icons_.back().url, 152 DownloadImage(unprocessed_icons_.back().url,
153 std::max(unprocessed_icons_.back().width, 153 std::max(unprocessed_icons_.back().width,
154 unprocessed_icons_.back().height), 154 unprocessed_icons_.back().height),
155 history::FAVICON, 155 history::FAVICON,
156 base::Bind(&UpdateShortcutWorker::OnIconDownloaded, 156 base::Bind(&UpdateShortcutWorker::OnIconDownloaded,
157 base::Unretained(this))); 157 base::Unretained(this)));
158 unprocessed_icons_.pop_back(); 158 unprocessed_icons_.pop_back();
159 } 159 }
160 160
161 void UpdateShortcutWorker::OnIconDownloaded(int download_id, 161 void UpdateShortcutWorker::OnIconDownloaded(int download_id,
162 bool errored, 162 bool errored,
163 const SkBitmap& image) { 163 const SkBitmap& image) {
164 if (tab_contents_ == NULL) { 164 if (tab_contents_ == NULL) {
165 DeleteMe(); // We are done if underlying WebContents is gone. 165 DeleteMe(); // We are done if underlying WebContents is gone.
166 return; 166 return;
167 } 167 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 } // namespace 302 } // namespace
303 303
304 namespace web_app { 304 namespace web_app {
305 305
306 void GetShortcutInfoForTab(TabContents* tab_contents, 306 void GetShortcutInfoForTab(TabContents* tab_contents,
307 ShellIntegration::ShortcutInfo* info) { 307 ShellIntegration::ShortcutInfo* info) {
308 DCHECK(info); // Must provide a valid info. 308 DCHECK(info); // Must provide a valid info.
309 const WebContents* web_contents = tab_contents->web_contents(); 309 const WebContents* web_contents = tab_contents->web_contents();
310 310
311 const FaviconTabHelper* favicon_tab_helper =
312 FaviconTabHelper::FromWebContents(web_contents);
311 const extensions::TabHelper* extensions_tab_helper = 313 const extensions::TabHelper* extensions_tab_helper =
312 extensions::TabHelper::FromWebContents(web_contents); 314 extensions::TabHelper::FromWebContents(web_contents);
313 const WebApplicationInfo& app_info = extensions_tab_helper->web_app_info(); 315 const WebApplicationInfo& app_info = extensions_tab_helper->web_app_info();
314 316
315 info->url = app_info.app_url.is_empty() ? web_contents->GetURL() : 317 info->url = app_info.app_url.is_empty() ? web_contents->GetURL() :
316 app_info.app_url; 318 app_info.app_url;
317 info->title = app_info.title.empty() ? 319 info->title = app_info.title.empty() ?
318 (web_contents->GetTitle().empty() ? UTF8ToUTF16(info->url.spec()) : 320 (web_contents->GetTitle().empty() ? UTF8ToUTF16(info->url.spec()) :
319 web_contents->GetTitle()) : 321 web_contents->GetTitle()) :
320 app_info.title; 322 app_info.title;
321 info->description = app_info.description; 323 info->description = app_info.description;
322 info->favicon = 324 info->favicon = gfx::Image(favicon_tab_helper->GetFavicon());
323 gfx::Image(tab_contents->favicon_tab_helper()->GetFavicon());
324 325
325 info->profile_path = tab_contents->profile()->GetPath(); 326 info->profile_path = tab_contents->profile()->GetPath();
326 } 327 }
327 328
328 void UpdateShortcutForTabContents(TabContents* tab_contents) { 329 void UpdateShortcutForTabContents(TabContents* tab_contents) {
329 #if defined(OS_WIN) 330 #if defined(OS_WIN)
330 // UpdateShortcutWorker will delete itself when it's done. 331 // UpdateShortcutWorker will delete itself when it's done.
331 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); 332 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents);
332 worker->Run(); 333 worker->Run();
333 #endif // defined(OS_WIN) 334 #endif // defined(OS_WIN)
334 } 335 }
335 336
336 } // namespace web_app 337 } // namespace web_app
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc ('k') | chrome/browser/ui/webui/web_ui_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698