llmediactrl.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /**
  2. * @file llmediactrl.h
  3. * @brief Web browser UI control
  4. *
  5. * $LicenseInfo:firstyear=2006&license=viewergpl$
  6. *
  7. * Copyright (c) 2006-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLMediaCtrl_H
  33. #define LL_LLMediaCtrl_H
  34. #include "llframetimer.h"
  35. #include "lluictrl.h"
  36. #include "llviewermedia.h"
  37. class LLViewBorder;
  38. class LLUICtrlFactory;
  39. class LLMediaCtrl : public LLUICtrl, public LLViewerMediaObserver,
  40. public LLViewerMediaEventEmitter
  41. {
  42. protected:
  43. LOG_CLASS(LLMediaCtrl);
  44. public:
  45. LLMediaCtrl(const std::string& name, const LLRect& rect);
  46. ~LLMediaCtrl() override;
  47. void setBorderVisible(bool border_visible);
  48. const std::string& getTag() const override;
  49. LLXMLNodePtr getXML(bool save_children = true) const override;
  50. static LLView* fromXML(LLXMLNodePtr node, LLView* parent,
  51. LLUICtrlFactory* factory);
  52. void reshape(S32 width, S32 height, bool from_parent = true) override;
  53. void draw() override;
  54. // Focus overrides
  55. void onFocusLost() override;
  56. void onFocusReceived() override;
  57. // Input overrides
  58. bool handleKeyHere(KEY key, MASK mask) override;
  59. bool handleKeyUpHere(KEY key, MASK mask) override;
  60. bool handleUnicodeCharHere(llwchar uni_char) override;
  61. // The browser window wants keyup and keydown events. Overridden from
  62. // LLFocusableElement to return true.
  63. LL_INLINE bool wantsKeyUpKeyDown() const override { return true; }
  64. LL_INLINE bool wantsReturnKey() const override { return true; }
  65. LL_INLINE bool acceptsTextInput() const override { return true; }
  66. // Mouse handling related methods
  67. bool handleHover(S32 x, S32 y, MASK mask) override;
  68. bool handleMouseUp(S32 x, S32 y, MASK mask) override;
  69. bool handleMouseDown(S32 x, S32 y, MASK mask) override;
  70. bool handleRightMouseDown(S32 x, S32 y, MASK mask) override;
  71. bool handleRightMouseUp(S32 x, S32 y, MASK mask) override;
  72. bool handleDoubleClick(S32 x, S32 y, MASK mask) override;
  73. bool handleScrollWheel(S32 x, S32 y, S32 clicks) override;
  74. // Incoming media event dispatcher. Inherited from LLViewerMediaObserver.
  75. void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent evt) override;
  76. // Navigation
  77. void navigateTo(const std::string& url_in,
  78. const std::string& mime_type = LLStringUtil::null);
  79. void navigateBack();
  80. void navigateHome();
  81. void navigateForward();
  82. void navigateToLocalPage(const std::string& subdir,
  83. const std::string& filename_in);
  84. bool canNavigateBack();
  85. bool canNavigateForward();
  86. LL_INLINE std::string getCurrentNavUrl() { return mCurrentNavUrl; }
  87. // By default, we do not handle "secondlife:///app/" SLURLs, because those
  88. // can cause teleports, open windows, etc. We cannot be sure that each
  89. // "click" is actually due to a user action, versus Javascript or some
  90. // other mechanism. However, we need the search floater and login page to
  91. // handle these URLs. Those are safe because we control the page content.
  92. // See DEV-9530. JC.
  93. void setTrusted(bool trusted);
  94. LL_INLINE bool isTrusted() { return mTrusted; }
  95. void setHomePageUrl(const std::string urlIn,
  96. const std::string& mime_type = LLStringUtil::null);
  97. std::string getHomePageUrl() { return mHomePageUrl; }
  98. void setTarget(const std::string& target);
  99. // Set URL to visit when a 404 page is reached
  100. LL_INLINE void setErrorPageURL(std::string url) { mErrorPageURL = url; }
  101. LL_INLINE const std::string& getErrorPageURL() { return mErrorPageURL; }
  102. // Accessor/mutator for flag that indicates if frequent updates to texture
  103. // happen:
  104. LL_INLINE bool getFrequentUpdates() { return mFrequentUpdates; }
  105. LL_INLINE void setFrequentUpdates(bool b) { mFrequentUpdates = b; }
  106. LL_INLINE void setAlwaysRefresh(bool b) { mAlwaysRefresh = b; }
  107. LL_INLINE bool getAlwaysRefresh() { return mAlwaysRefresh; }
  108. LL_INLINE void setForceUpdate(bool b) { mForceUpdate = b; }
  109. LL_INLINE bool getForceUpdate() { return mForceUpdate; }
  110. LL_INLINE void setDecoupleTextureSize(bool b) { mDecoupleTextureSize = b; }
  111. LL_INLINE bool getDecoupleTextureSize() { return mDecoupleTextureSize; }
  112. void setTextureSize(S32 width, S32 height);
  113. LL_INLINE S32 getTextureWidth() { return mTextureWidth; }
  114. LL_INLINE S32 getTextureHeight() { return mTextureHeight; }
  115. bool ensureMediaSourceExists();
  116. LL_INLINE void unloadMediaSource() { mMediaSource = NULL; }
  117. LL_INLINE LLViewerMediaImpl* getMediaSource()
  118. {
  119. return mMediaSource.isNull() ? NULL : (LLViewerMediaImpl*)mMediaSource;
  120. }
  121. LLPluginClassMedia* getMediaPlugin();
  122. #if 0 // Not used
  123. virtual void handleVisibilityChange(bool new_visibility);
  124. #endif
  125. static void setOpenIdCookie(const std::string& url,
  126. const std::string& cookie_host,
  127. const std::string& cookie);
  128. protected:
  129. void convertInputCoords(S32& x, S32& y);
  130. private:
  131. void onVisibilityChange(bool new_visibility) override;
  132. static bool onClickLinkExternalTarget(const LLSD&, const LLSD&);
  133. static bool parseRawCookie(const std::string& raw_cookie,
  134. std::string& name, std::string& value,
  135. std::string& path);
  136. private:
  137. LLViewBorder* mBorder;
  138. std::string mHomePageUrl;
  139. std::string mHomePageMimeType;
  140. std::string mCurrentNavUrl;
  141. std::string mErrorPageURL;
  142. std::string mTarget;
  143. viewer_media_t mMediaSource;
  144. LLUUID mMediaTextureID;
  145. const S32 mTextureDepthBytes;
  146. S32 mTextureWidth;
  147. S32 mTextureHeight;
  148. bool mFrequentUpdates;
  149. bool mForceUpdate;
  150. bool mTrusted;
  151. bool mAlwaysRefresh;
  152. bool mStretchToFill;
  153. bool mMaintainAspectRatio;
  154. bool mHidingInitialLoad;
  155. bool mDecoupleTextureSize;
  156. typedef fast_hset<LLMediaCtrl*> instances_list_t;
  157. static instances_list_t sMediaCtrlInstances;
  158. };
  159. #endif // LL_LLMediaCtrl_H