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

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

Issue 10917026: Switch Extensions::TabHelper to use WebContents, WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 3 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 // Existing shortcuts. 96 // Existing shortcuts.
97 std::vector<FilePath> shortcut_files_; 97 std::vector<FilePath> shortcut_files_;
98 98
99 DISALLOW_COPY_AND_ASSIGN(UpdateShortcutWorker); 99 DISALLOW_COPY_AND_ASSIGN(UpdateShortcutWorker);
100 }; 100 };
101 101
102 UpdateShortcutWorker::UpdateShortcutWorker(TabContents* tab_contents) 102 UpdateShortcutWorker::UpdateShortcutWorker(TabContents* tab_contents)
103 : tab_contents_(tab_contents), 103 : tab_contents_(tab_contents),
104 profile_path_(tab_contents->profile()->GetPath()) { 104 profile_path_(tab_contents->profile()->GetPath()) {
105 extensions::TabHelper* extensions_tab_helper =
106 extensions::TabHelper::FromWebContents(tab_contents->web_contents());
105 web_app::GetShortcutInfoForTab(tab_contents_, &shortcut_info_); 107 web_app::GetShortcutInfoForTab(tab_contents_, &shortcut_info_);
106 web_app::GetIconsInfo(tab_contents_->extension_tab_helper()->web_app_info(), 108 web_app::GetIconsInfo(extensions_tab_helper->web_app_info(),
107 &unprocessed_icons_); 109 &unprocessed_icons_);
108 file_name_ = web_app::internals::GetSanitizedFileName(shortcut_info_.title); 110 file_name_ = web_app::internals::GetSanitizedFileName(shortcut_info_.title);
109 111
110 registrar_.Add( 112 registrar_.Add(
111 this, 113 this,
112 chrome::NOTIFICATION_TAB_CLOSING, 114 chrome::NOTIFICATION_TAB_CLOSING,
113 content::Source<NavigationController>( 115 content::Source<NavigationController>(
114 &tab_contents_->web_contents()->GetController())); 116 &tab_contents_->web_contents()->GetController()));
115 } 117 }
116 118
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 bool errored, 163 bool errored,
162 const SkBitmap& image) { 164 const SkBitmap& image) {
163 if (tab_contents_ == NULL) { 165 if (tab_contents_ == NULL) {
164 DeleteMe(); // We are done if underlying WebContents is gone. 166 DeleteMe(); // We are done if underlying WebContents is gone.
165 return; 167 return;
166 } 168 }
167 169
168 if (!errored && !image.isNull()) { 170 if (!errored && !image.isNull()) {
169 // Update icon with download image and update shortcut. 171 // Update icon with download image and update shortcut.
170 shortcut_info_.favicon = gfx::Image(image); 172 shortcut_info_.favicon = gfx::Image(image);
171 tab_contents_->extension_tab_helper()->SetAppIcon(image); 173 extensions::TabHelper* extensions_tab_helper =
174 extensions::TabHelper::FromWebContents(tab_contents_->web_contents());
175 extensions_tab_helper->SetAppIcon(image);
172 UpdateShortcuts(); 176 UpdateShortcuts();
173 } else { 177 } else {
174 // Try the next icon otherwise. 178 // Try the next icon otherwise.
175 DownloadIcon(); 179 DownloadIcon();
176 } 180 }
177 } 181 }
178 182
179 void UpdateShortcutWorker::CheckExistingShortcuts() { 183 void UpdateShortcutWorker::CheckExistingShortcuts() {
180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
181 185
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 302
299 } // namespace 303 } // namespace
300 304
301 namespace web_app { 305 namespace web_app {
302 306
303 void GetShortcutInfoForTab(TabContents* tab_contents, 307 void GetShortcutInfoForTab(TabContents* tab_contents,
304 ShellIntegration::ShortcutInfo* info) { 308 ShellIntegration::ShortcutInfo* info) {
305 DCHECK(info); // Must provide a valid info. 309 DCHECK(info); // Must provide a valid info.
306 const WebContents* web_contents = tab_contents->web_contents(); 310 const WebContents* web_contents = tab_contents->web_contents();
307 311
308 const WebApplicationInfo& app_info = 312 const extensions::TabHelper* extensions_tab_helper =
309 tab_contents->extension_tab_helper()->web_app_info(); 313 extensions::TabHelper::FromWebContents(web_contents);
314 const WebApplicationInfo& app_info = extensions_tab_helper->web_app_info();
310 315
311 info->url = app_info.app_url.is_empty() ? web_contents->GetURL() : 316 info->url = app_info.app_url.is_empty() ? web_contents->GetURL() :
312 app_info.app_url; 317 app_info.app_url;
313 info->title = app_info.title.empty() ? 318 info->title = app_info.title.empty() ?
314 (web_contents->GetTitle().empty() ? UTF8ToUTF16(info->url.spec()) : 319 (web_contents->GetTitle().empty() ? UTF8ToUTF16(info->url.spec()) :
315 web_contents->GetTitle()) : 320 web_contents->GetTitle()) :
316 app_info.title; 321 app_info.title;
317 info->description = app_info.description; 322 info->description = app_info.description;
318 info->favicon = 323 info->favicon =
319 gfx::Image(tab_contents->favicon_tab_helper()->GetFavicon()); 324 gfx::Image(tab_contents->favicon_tab_helper()->GetFavicon());
320 325
321 info->profile_path = tab_contents->profile()->GetPath(); 326 info->profile_path = tab_contents->profile()->GetPath();
322 } 327 }
323 328
324 void UpdateShortcutForTabContents(TabContents* tab_contents) { 329 void UpdateShortcutForTabContents(TabContents* tab_contents) {
325 #if defined(OS_WIN) 330 #if defined(OS_WIN)
326 // UpdateShortcutWorker will delete itself when it's done. 331 // UpdateShortcutWorker will delete itself when it's done.
327 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); 332 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents);
328 worker->Run(); 333 worker->Run();
329 #endif // defined(OS_WIN) 334 #endif // defined(OS_WIN)
330 } 335 }
331 336
332 } // namespace web_app 337 } // namespace web_app
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698