PageRenderTime 37ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llurldispatcherlistener.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 75 lines | 34 code | 5 blank | 36 comment | 1 complexity | 35e5fe9fd74f70d5d8efbd7307e9f96d MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llurldispatcherlistener.cpp
  3. * @author Nat Goodspeed
  4. * @date 2009-12-10
  5. * @brief Implementation for llurldispatcherlistener.
  6. *
  7. * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. // Precompiled header
  29. #include "llviewerprecompiledheaders.h"
  30. // associated header
  31. #include "llurldispatcherlistener.h"
  32. // STL headers
  33. // std headers
  34. // external library headers
  35. // other Linden headers
  36. #include "llurldispatcher.h"
  37. LLURLDispatcherListener::LLURLDispatcherListener(/* LLURLDispatcher* instance */):
  38. LLEventAPI("LLURLDispatcher", "Internal URL handling") /* ,
  39. mDispatcher(instance) */
  40. {
  41. add("dispatch",
  42. "At startup time or on clicks in internal web browsers,\n"
  43. "teleport, open map, or run requested command.\n"
  44. "[\"url\"] string url to dispatch\n"
  45. "[\"trusted\"] boolean indicating trusted browser [default true]",
  46. &LLURLDispatcherListener::dispatch);
  47. add("dispatchRightClick", "Dispatch [\"url\"] as if from a right-click on a hot link.",
  48. &LLURLDispatcherListener::dispatchRightClick);
  49. add("dispatchFromTextEditor", "Dispatch [\"url\"] as if from an edit field.",
  50. &LLURLDispatcherListener::dispatchFromTextEditor);
  51. }
  52. void LLURLDispatcherListener::dispatch(const LLSD& params) const
  53. {
  54. // For most purposes, we expect callers to want to be trusted.
  55. bool trusted_browser = true;
  56. if (params.has("trusted"))
  57. {
  58. // But for testing, allow a caller to specify untrusted.
  59. trusted_browser = params["trusted"].asBoolean();
  60. }
  61. LLURLDispatcher::dispatch(params["url"], "clicked", NULL, trusted_browser);
  62. }
  63. void LLURLDispatcherListener::dispatchRightClick(const LLSD& params) const
  64. {
  65. LLURLDispatcher::dispatchRightClick(params["url"]);
  66. }
  67. void LLURLDispatcherListener::dispatchFromTextEditor(const LLSD& params) const
  68. {
  69. LLURLDispatcher::dispatchFromTextEditor(params["url"]);
  70. }