1 // Copyright 2024 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 #ifndef BASE_NIX_SCOPED_XDG_ACTIVATION_TOKEN_INJECTOR_H_ 6 #define BASE_NIX_SCOPED_XDG_ACTIVATION_TOKEN_INJECTOR_H_ 7 8 #include "base/base_export.h" 9 #include "base/memory/raw_ref.h" 10 11 namespace base { 12 13 class CommandLine; 14 class Environment; 15 16 namespace nix { 17 18 // Sets the global xdg-activation token after reading from the launching app and 19 // injects it temporarily into the command line if it needs to be sent to 20 // another browser process. 21 // The token switch is removed from the command line on destruction. 22 class BASE_EXPORT ScopedXdgActivationTokenInjector { 23 public: 24 ScopedXdgActivationTokenInjector(base::CommandLine& command_line, 25 base::Environment& env); 26 27 ScopedXdgActivationTokenInjector(const ScopedXdgActivationTokenInjector&) = 28 delete; 29 ScopedXdgActivationTokenInjector& operator=( 30 const ScopedXdgActivationTokenInjector&) = delete; 31 32 ~ScopedXdgActivationTokenInjector(); 33 34 private: 35 const raw_ref<CommandLine> command_line_; 36 bool token_injected_ = false; 37 }; 38 39 } // namespace nix 40 41 } // namespace base 42 43 #endif // BASE_NIX_SCOPED_XDG_ACTIVATION_TOKEN_INJECTOR_H_ 44