| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 UpdateShortcutWorker::UpdateShortcutWorker(TabContentsWrapper* tab_contents) | 95 UpdateShortcutWorker::UpdateShortcutWorker(TabContentsWrapper* tab_contents) |
| 96 : tab_contents_(tab_contents), | 96 : tab_contents_(tab_contents), |
| 97 profile_path_(tab_contents->profile()->GetPath()) { | 97 profile_path_(tab_contents->profile()->GetPath()) { |
| 98 web_app::GetShortcutInfoForTab(tab_contents_, &shortcut_info_); | 98 web_app::GetShortcutInfoForTab(tab_contents_, &shortcut_info_); |
| 99 web_app::GetIconsInfo(tab_contents_->extension_tab_helper()->web_app_info(), | 99 web_app::GetIconsInfo(tab_contents_->extension_tab_helper()->web_app_info(), |
| 100 &unprocessed_icons_); | 100 &unprocessed_icons_); |
| 101 file_name_ = web_app::internals::GetSanitizedFileName(shortcut_info_.title); | 101 file_name_ = web_app::internals::GetSanitizedFileName(shortcut_info_.title); |
| 102 | 102 |
| 103 registrar_.Add( | 103 registrar_.Add( |
| 104 this, content::NOTIFICATION_TAB_CLOSING, | 104 this, |
| 105 content::Source<NavigationController>(&tab_contents_->controller())); | 105 content::NOTIFICATION_TAB_CLOSING, |
| 106 content::Source<NavigationController>( |
| 107 &tab_contents_->tab_contents()->controller())); |
| 106 } | 108 } |
| 107 | 109 |
| 108 void UpdateShortcutWorker::Run() { | 110 void UpdateShortcutWorker::Run() { |
| 109 // Starting by downloading app icon. | 111 // Starting by downloading app icon. |
| 110 DownloadIcon(); | 112 DownloadIcon(); |
| 111 } | 113 } |
| 112 | 114 |
| 113 void UpdateShortcutWorker::Observe( | 115 void UpdateShortcutWorker::Observe( |
| 114 int type, | 116 int type, |
| 115 const content::NotificationSource& source, | 117 const content::NotificationSource& source, |
| 116 const content::NotificationDetails& details) { | 118 const content::NotificationDetails& details) { |
| 117 if (type == content::NOTIFICATION_TAB_CLOSING && | 119 if (type == content::NOTIFICATION_TAB_CLOSING && |
| 118 content::Source<NavigationController>(source).ptr() == | 120 content::Source<NavigationController>(source).ptr() == |
| 119 &tab_contents_->controller()) { | 121 &tab_contents_->tab_contents()->controller()) { |
| 120 // Underlying tab is closing. | 122 // Underlying tab is closing. |
| 121 tab_contents_ = NULL; | 123 tab_contents_ = NULL; |
| 122 } | 124 } |
| 123 } | 125 } |
| 124 | 126 |
| 125 void UpdateShortcutWorker::DownloadIcon() { | 127 void UpdateShortcutWorker::DownloadIcon() { |
| 126 // FetchIcon must run on UI thread because it relies on TabContents | 128 // FetchIcon must run on UI thread because it relies on TabContents |
| 127 // to download the icon. | 129 // to download the icon. |
| 128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 129 | 131 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 312 |
| 311 void UpdateShortcutForTabContents(TabContentsWrapper* tab_contents) { | 313 void UpdateShortcutForTabContents(TabContentsWrapper* tab_contents) { |
| 312 #if defined(OS_WIN) | 314 #if defined(OS_WIN) |
| 313 // UpdateShortcutWorker will delete itself when it's done. | 315 // UpdateShortcutWorker will delete itself when it's done. |
| 314 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); | 316 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); |
| 315 worker->Run(); | 317 worker->Run(); |
| 316 #endif // defined(OS_WIN) | 318 #endif // defined(OS_WIN) |
| 317 } | 319 } |
| 318 | 320 |
| 319 } // namespace web_app | 321 } // namespace web_app |
| OLD | NEW |