OLD | NEW |
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" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/win/windows_version.h" | 12 #include "base/win/windows_version.h" |
13 #include "chrome/browser/extensions/extension_tab_helper.h" | 13 #include "chrome/browser/extensions/extension_tab_helper.h" |
14 #include "chrome/browser/favicon/favicon_tab_helper.h" | 14 #include "chrome/browser/favicon/favicon_tab_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
17 #include "chrome/browser/web_applications/web_app.h" | 17 #include "chrome/browser/web_applications/web_app.h" |
| 18 #include "chrome/common/chrome_notification_types.h" |
18 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
21 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
22 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
23 #include "content/public/browser/notification_types.h" | |
24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
25 | 25 |
26 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 26 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
27 #include "base/environment.h" | 27 #include "base/environment.h" |
28 #endif | 28 #endif |
29 | 29 |
30 using content::BrowserThread; | 30 using content::BrowserThread; |
31 using content::NavigationController; | 31 using content::NavigationController; |
32 using content::WebContents; | 32 using content::WebContents; |
33 | 33 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 UpdateShortcutWorker::UpdateShortcutWorker(TabContentsWrapper* tab_contents) | 97 UpdateShortcutWorker::UpdateShortcutWorker(TabContentsWrapper* tab_contents) |
98 : tab_contents_(tab_contents), | 98 : tab_contents_(tab_contents), |
99 profile_path_(tab_contents->profile()->GetPath()) { | 99 profile_path_(tab_contents->profile()->GetPath()) { |
100 web_app::GetShortcutInfoForTab(tab_contents_, &shortcut_info_); | 100 web_app::GetShortcutInfoForTab(tab_contents_, &shortcut_info_); |
101 web_app::GetIconsInfo(tab_contents_->extension_tab_helper()->web_app_info(), | 101 web_app::GetIconsInfo(tab_contents_->extension_tab_helper()->web_app_info(), |
102 &unprocessed_icons_); | 102 &unprocessed_icons_); |
103 file_name_ = web_app::internals::GetSanitizedFileName(shortcut_info_.title); | 103 file_name_ = web_app::internals::GetSanitizedFileName(shortcut_info_.title); |
104 | 104 |
105 registrar_.Add( | 105 registrar_.Add( |
106 this, | 106 this, |
107 content::NOTIFICATION_TAB_CLOSING, | 107 chrome::NOTIFICATION_TAB_CLOSING, |
108 content::Source<NavigationController>( | 108 content::Source<NavigationController>( |
109 &tab_contents_->web_contents()->GetController())); | 109 &tab_contents_->web_contents()->GetController())); |
110 } | 110 } |
111 | 111 |
112 void UpdateShortcutWorker::Run() { | 112 void UpdateShortcutWorker::Run() { |
113 // Starting by downloading app icon. | 113 // Starting by downloading app icon. |
114 DownloadIcon(); | 114 DownloadIcon(); |
115 } | 115 } |
116 | 116 |
117 void UpdateShortcutWorker::Observe( | 117 void UpdateShortcutWorker::Observe( |
118 int type, | 118 int type, |
119 const content::NotificationSource& source, | 119 const content::NotificationSource& source, |
120 const content::NotificationDetails& details) { | 120 const content::NotificationDetails& details) { |
121 if (type == content::NOTIFICATION_TAB_CLOSING && | 121 if (type == chrome::NOTIFICATION_TAB_CLOSING && |
122 content::Source<NavigationController>(source).ptr() == | 122 content::Source<NavigationController>(source).ptr() == |
123 &tab_contents_->web_contents()->GetController()) { | 123 &tab_contents_->web_contents()->GetController()) { |
124 // Underlying tab is closing. | 124 // Underlying tab is closing. |
125 tab_contents_ = NULL; | 125 tab_contents_ = NULL; |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 void UpdateShortcutWorker::DownloadIcon() { | 129 void UpdateShortcutWorker::DownloadIcon() { |
130 // FetchIcon must run on UI thread because it relies on TabContents | 130 // FetchIcon must run on UI thread because it relies on TabContents |
131 // to download the icon. | 131 // to download the icon. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 318 |
319 void UpdateShortcutForTabContents(TabContentsWrapper* tab_contents) { | 319 void UpdateShortcutForTabContents(TabContentsWrapper* tab_contents) { |
320 #if defined(OS_WIN) | 320 #if defined(OS_WIN) |
321 // UpdateShortcutWorker will delete itself when it's done. | 321 // UpdateShortcutWorker will delete itself when it's done. |
322 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); | 322 UpdateShortcutWorker* worker = new UpdateShortcutWorker(tab_contents); |
323 worker->Run(); | 323 worker->Run(); |
324 #endif // defined(OS_WIN) | 324 #endif // defined(OS_WIN) |
325 } | 325 } |
326 | 326 |
327 } // namespace web_app | 327 } // namespace web_app |
OLD | NEW |