GMPProcessChild.cpp (1709B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #include "GMPProcessChild.h" 7 8 #include "base/command_line.h" 9 #include "base/string_util.h" 10 #include "mozilla/GeckoArgs.h" 11 12 namespace mozilla::gmp { 13 14 /* static */ bool GMPProcessChild::sUseXpcom = false; 15 /* static */ bool GMPProcessChild::sUseNativeEventProcessing = true; 16 17 void GMPProcessChild::InitStatics(int aArgc, char* aArgv[]) { 18 Maybe<bool> nativeEvent = geckoargs::sPluginNativeEvent.Get(aArgc, aArgv); 19 sUseNativeEventProcessing = nativeEvent.isSome() && *nativeEvent; 20 21 auto prefsHandlePresent = geckoargs::sPrefsHandle.IsPresent(aArgc, aArgv); 22 auto prefMapHandlePresent = geckoargs::sPrefMapHandle.IsPresent(aArgc, aArgv); 23 sUseXpcom = prefsHandlePresent && prefMapHandlePresent; 24 } 25 26 GMPProcessChild::~GMPProcessChild() = default; 27 28 bool GMPProcessChild::Init(int aArgc, char* aArgv[]) { 29 Maybe<const char*> parentBuildID = 30 geckoargs::sParentBuildID.Get(aArgc, aArgv); 31 if (NS_WARN_IF(parentBuildID.isNothing())) { 32 return false; 33 } 34 35 Maybe<const char*> pluginPath = geckoargs::sPluginPath.Get(aArgc, aArgv); 36 if (NS_WARN_IF(pluginPath.isNothing())) { 37 return false; 38 } 39 40 NS_ConvertUTF8toUTF16 widePluginPath(*pluginPath); 41 42 if (sUseXpcom && NS_WARN_IF(!ProcessChild::InitPrefs(aArgc, aArgv))) { 43 return false; 44 } 45 46 return mPlugin->Init(widePluginPath, *parentBuildID, TakeInitialEndpoint()); 47 } 48 49 void GMPProcessChild::CleanUp() { mPlugin->Shutdown(); } 50 51 } // namespace mozilla::gmp