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 <string> | 5 #include <string> |
6 | 6 |
7 #include "win8/metro_driver/stdafx.h" | 7 #include "win8/metro_driver/stdafx.h" |
8 #include "win8/metro_driver/toast_notification_handler.h" | 8 #include "win8/metro_driver/toast_notification_handler.h" |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 // TODO(ananta) | 14 #include "chrome/installer/util/browser_distribution.h" |
15 // Refactor the chrome_util and shell_util code from chrome into a common lib | 15 #include "chrome/installer/util/install_util.h" |
16 #include "win8/delegate_execute/chrome_util.h" | 16 #include "chrome/installer/util/shell_util.h" |
| 17 |
17 #include "win8/metro_driver/winrt_utils.h" | 18 #include "win8/metro_driver/winrt_utils.h" |
18 | 19 |
19 typedef winfoundtn::ITypedEventHandler< | 20 typedef winfoundtn::ITypedEventHandler< |
20 winui::Notifications::ToastNotification*, IInspectable*> | 21 winui::Notifications::ToastNotification*, IInspectable*> |
21 ToastActivationHandler; | 22 ToastActivationHandler; |
22 | 23 |
23 typedef winfoundtn::ITypedEventHandler< | 24 typedef winfoundtn::ITypedEventHandler< |
24 winui::Notifications::ToastNotification*, | 25 winui::Notifications::ToastNotification*, |
25 winui::Notifications::ToastDismissedEventArgs*> ToastDismissedHandler; | 26 winui::Notifications::ToastDismissedEventArgs*> ToastDismissedHandler; |
26 | 27 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 195 |
195 hr = toast_notification_factory->CreateToastNotification( | 196 hr = toast_notification_factory->CreateToastNotification( |
196 toast_xml.Get(), ¬ification_); | 197 toast_xml.Get(), ¬ification_); |
197 CheckHR(hr); | 198 CheckHR(hr); |
198 | 199 |
199 base::FilePath chrome_path; | 200 base::FilePath chrome_path; |
200 if (!PathService::Get(base::FILE_EXE, &chrome_path)) { | 201 if (!PathService::Get(base::FILE_EXE, &chrome_path)) { |
201 NOTREACHED() << "Failed to get chrome exe path"; | 202 NOTREACHED() << "Failed to get chrome exe path"; |
202 return; | 203 return; |
203 } | 204 } |
204 string16 appid = delegate_execute::GetAppId(chrome_path); | 205 |
| 206 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 207 bool is_per_user_install = InstallUtil::IsPerUserInstall( |
| 208 chrome_path.value().c_str()); |
| 209 string16 appid = ShellUtil::GetBrowserModelId(dist, is_per_user_install); |
205 DVLOG(1) << "Chrome Appid is " << appid.c_str(); | 210 DVLOG(1) << "Chrome Appid is " << appid.c_str(); |
206 | 211 |
207 // TODO(ananta) | |
208 // We should probably use BrowserDistribution here to get the product name. | |
209 mswrw::HString app_user_model_id; | 212 mswrw::HString app_user_model_id; |
210 app_user_model_id.Attach(MakeHString(appid)); | 213 app_user_model_id.Attach(MakeHString(appid)); |
211 | 214 |
212 hr = toast_manager->CreateToastNotifierWithId(app_user_model_id.Get(), | 215 hr = toast_manager->CreateToastNotifierWithId(app_user_model_id.Get(), |
213 ¬ifier_); | 216 ¬ifier_); |
214 CheckHR(hr); | 217 CheckHR(hr); |
215 | 218 |
216 hr = notification_->add_Activated( | 219 hr = notification_->add_Activated( |
217 mswr::Callback<ToastActivationHandler>( | 220 mswr::Callback<ToastActivationHandler>( |
218 this, &ToastNotificationHandler::OnActivate).Get(), | 221 this, &ToastNotificationHandler::OnActivate).Get(), |
(...skipping 21 matching lines...) Expand all Loading... |
240 // etc to ChromeAppView which would enable it to ensure that the | 243 // etc to ChromeAppView which would enable it to ensure that the |
241 // correct tab in chrome is activated. | 244 // correct tab in chrome is activated. |
242 DVLOG(1) << __FUNCTION__; | 245 DVLOG(1) << __FUNCTION__; |
243 | 246 |
244 if (notification_info_.notification_handler) { | 247 if (notification_info_.notification_handler) { |
245 notification_info_.notification_handler( | 248 notification_info_.notification_handler( |
246 notification_info_.notification_context.c_str()); | 249 notification_info_.notification_context.c_str()); |
247 } | 250 } |
248 return S_OK; | 251 return S_OK; |
249 } | 252 } |
OLD | NEW |