|
2 | 2 |
|
3 | 3 | #include "base/command_line.h" |
4 | 4 | #include "base/memory/ptr_util.h" |
| 5 | +#include "base/strings/utf_string_conversions.h" |
5 | 6 | #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
6 | 7 | #include "chrome/browser/browsing_data/browsing_data_helper.h" |
7 | 8 | #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
8 | 9 | #include "chrome/browser/devtools/devtools_window.h" |
9 | 10 | #include "chrome/browser/extensions/devtools_util.h" |
10 | 11 | #include "chrome/browser/extensions/extension_service.h" |
| 12 | +#include "chrome/browser/profiles/profile.h" |
| 13 | +#include "chrome/browser/web_applications/web_app.h" |
| 14 | +#include "content/nw/src/common/shell_switches.h" |
11 | 15 | #include "content/nw/src/nw_base.h" |
12 | 16 | #include "content/public/browser/render_process_host.h" |
13 | 17 | #include "content/public/browser/render_view_host.h" |
|
24 | 28 | #include "net/url_request/url_request_context.h" |
25 | 29 | #include "net/url_request/url_request_context_getter.h" |
26 | 30 |
|
| 31 | +#if defined(OS_WIN) |
| 32 | +#include "chrome/browser/shell_integration_win.h" |
| 33 | +#endif |
| 34 | + |
27 | 35 | namespace { |
28 | 36 | void SetProxyConfigCallback( |
29 | 37 | base::WaitableEvent* done, |
@@ -182,5 +190,35 @@ bool NwAppCrashBrowserFunction::RunAsync() { |
182 | 190 | return true; |
183 | 191 | } |
184 | 192 |
|
| 193 | +bool NwAppGetDefaultAppUserModelIDFunction::RunNWSync(base::ListValue* response, std::string* error) { |
| 194 | +#if defined(OS_WIN) |
| 195 | + base::string16 app_id; |
| 196 | + nw::Package* package = nw::package(); |
| 197 | + if (package->root()->GetString(::switches::kmAppUserModelID, &app_id)) { |
| 198 | + response->AppendString(app_id); |
| 199 | + } else { |
| 200 | + std::string app_name = |
| 201 | + web_app::GenerateApplicationNameFromExtensionId(extension_id()); |
| 202 | + base::string16 app_name_wide = base::UTF8ToWide(app_name); |
| 203 | + Profile* profile = |
| 204 | + Profile::FromBrowserContext(browser_context()); |
| 205 | + app_id = shell_integration::win::GetAppModelIdForProfile( |
| 206 | + app_name_wide, profile->GetPath()); |
| 207 | + response->AppendString(app_id); |
| 208 | + } |
| 209 | +#endif |
| 210 | + return true; |
| 211 | +} |
| 212 | + |
| 213 | +bool NwAppSetDefaultAppUserModelIDFunction::RunNWSync(base::ListValue* response, std::string* error) { |
| 214 | +#if defined(OS_WIN) |
| 215 | + std::string app_id; |
| 216 | + EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &app_id)); |
| 217 | + |
| 218 | + nw::Package* package = nw::package(); |
| 219 | + package->root()->SetString(::switches::kmAppUserModelID, app_id); |
| 220 | +#endif |
| 221 | + return true; |
| 222 | +} |
185 | 223 |
|
186 | 224 | } // namespace extensions |
0 commit comments