[M120][Tizen][Onscreen] Fix build errors for TV profile
[platform/framework/web/chromium-efl.git] / chrome / browser / browser_process_platform_part_mac.mm
1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/browser_process_platform_part_mac.h"
6
7 #include "base/apple/foundation_util.h"
8 #include "base/metrics/histogram_macros.h"
9 #include "base/time/time.h"
10 #import "chrome/browser/app_controller_mac.h"
11 #include "chrome/browser/apps/app_shim/app_shim_manager_mac.h"
12 #include "chrome/browser/apps/app_shim/web_app_shim_manager_delegate_mac.h"
13 #include "chrome/browser/apps/platform_apps/extension_app_shim_manager_delegate_mac.h"
14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_browser_application_mac.h"
16 #include "services/device/public/cpp/geolocation/system_geolocation_source_mac.h"
17
18 BrowserProcessPlatformPart::BrowserProcessPlatformPart() = default;
19
20 BrowserProcessPlatformPart::~BrowserProcessPlatformPart() = default;
21
22 void BrowserProcessPlatformPart::StartTearDown() {
23   app_shim_listener_ = nullptr;
24 }
25
26 void BrowserProcessPlatformPart::AttemptExit(bool try_to_quit_application) {
27   // On the Mac, the application continues to run once all windows are closed.
28   // Terminate will result in a CloseAllBrowsers() call, and once (and if)
29   // that is done, will cause the application to exit cleanly.
30   //
31   // This function is called for two types of attempted exits: URL requests
32   // (chrome://quit or chrome://restart), and a keyboard menu invocations of
33   // command-Q. (Interestingly, selecting the Quit command with the mouse don't
34   // come down this code path at all.) URL requests to exit have
35   // |try_to_quit_application| set to true; keyboard menu invocations have it
36   // set to false.
37
38   if (!try_to_quit_application) {
39     // A keyboard menu invocation.
40     if (![AppController.sharedController runConfirmQuitPanel]) {
41       return;
42     }
43   }
44
45   chrome_browser_application_mac::Terminate();
46 }
47
48 void BrowserProcessPlatformPart::PreMainMessageLoopRun() {
49   // Create two AppShimManager::Delegates -- one for extensions-based apps
50   // (which will be deprecated in 2020), and one for web apps (PWAs and
51   // bookmark apps). The WebAppShimManagerDelegate will defer to the
52   // ExtensionAppShimManagerDelegate passed to it for extension-based apps.
53   // When extension-based apps are deprecated, the
54   // ExtensionAppShimManagerDelegate may be changed to nullptr here.
55   std::unique_ptr<apps::AppShimManager::Delegate> app_shim_manager_delegate =
56       std::make_unique<apps::ExtensionAppShimManagerDelegate>();
57   app_shim_manager_delegate =
58       std::make_unique<web_app::WebAppShimManagerDelegate>(
59           std::move(app_shim_manager_delegate));
60   app_shim_manager_ = std::make_unique<apps::AppShimManager>(
61       std::move(app_shim_manager_delegate));
62
63   // AppShimListener can not simply be reset, otherwise destroying the old
64   // domain socket will cause the just-created socket to be unlinked.
65   DCHECK(!app_shim_listener_.get());
66   app_shim_listener_ = new AppShimListener;
67
68   if (!device::GeolocationManager::GetInstance()) {
69     device::GeolocationManager::SetInstance(
70         device::SystemGeolocationSourceMac::CreateGeolocationManagerOnMac());
71   }
72 }
73
74 apps::AppShimManager* BrowserProcessPlatformPart::app_shim_manager() {
75   return app_shim_manager_.get();
76 }
77
78 AppShimListener* BrowserProcessPlatformPart::app_shim_listener() {
79   return app_shim_listener_.get();
80 }