|
1 | 1 | #include "content/nw/src/api/nw_app_api.h"
|
2 | 2 |
|
| 3 | +#include "chrome/browser/lifetime/browser_close_manager.h" |
| 4 | +#include "chrome/browser/lifetime/application_lifetime.h" |
| 5 | +#include "content/public/common/content_features.h" |
| 6 | + |
3 | 7 | #include "base/command_line.h"
|
4 | 8 | #include "base/memory/ptr_util.h"
|
5 | 9 | #include "base/task/post_task.h"
|
@@ -50,19 +54,31 @@ NwAppQuitFunction::NwAppQuitFunction() {
|
50 | 54 | NwAppQuitFunction::~NwAppQuitFunction() {
|
51 | 55 | }
|
52 | 56 |
|
| 57 | +void NwAppQuitFunction::DoJob(ExtensionService* service, std::string extension_id) { |
| 58 | + if (base::FeatureList::IsEnabled(::features::kNWNewWin)) { |
| 59 | + chrome::CloseAllBrowsersAndQuit(true); |
| 60 | + return; |
| 61 | + } |
| 62 | + base::MessageLoop::current()->task_runner()->PostTask( |
| 63 | + FROM_HERE, |
| 64 | + base::Bind(&ExtensionService::TerminateExtension, |
| 65 | + service->AsWeakPtr(), |
| 66 | + extension_id)); |
| 67 | +} |
| 68 | + |
53 | 69 | ExtensionFunction::ResponseAction
|
54 | 70 | NwAppQuitFunction::Run() {
|
55 |
| - ExtensionService* service = |
56 |
| - ExtensionSystem::Get(browser_context())->extension_service(); |
| 71 | + ExtensionService* service = ExtensionSystem::Get(browser_context())->extension_service(); |
57 | 72 | base::MessageLoop::current()->task_runner()->PostTask(
|
58 |
| - FROM_HERE, |
59 |
| - base::Bind(&ExtensionService::TerminateExtension, |
60 |
| - service->AsWeakPtr(), |
61 |
| - extension_id())); |
| 73 | + FROM_HERE, |
| 74 | + base::Bind(&NwAppQuitFunction::DoJob, service, extension()->id())); |
62 | 75 | return RespondNow(NoArguments());
|
63 | 76 | }
|
64 | 77 |
|
65 | 78 | void NwAppCloseAllWindowsFunction::DoJob(AppWindowRegistry* registry, std::string id) {
|
| 79 | + if (base::FeatureList::IsEnabled(::features::kNWNewWin)) { |
| 80 | + chrome::CloseAllBrowsers(); |
| 81 | + } |
66 | 82 | AppWindowRegistry::AppWindowList windows =
|
67 | 83 | registry->GetAppWindowsForApp(id);
|
68 | 84 |
|
|
0 commit comments