diff options
author | Monroe Linden <monroe@lindenlab.com> | 2009-11-13 13:05:16 -0800 |
---|---|---|
committer | Monroe Linden <monroe@lindenlab.com> | 2009-11-13 13:05:16 -0800 |
commit | 5890c850f8db30e105717b7c5fbbec91c434ebff (patch) | |
tree | 381cfe9629f0af5253ba998fe4ea6d2a807291df /indra/media_plugins | |
parent | e728dcd1ab877d300ddf93beaab9d77e9b10c3cc (diff) |
Prevent the about:blank url from the initial navigate from leaking out of the webkit plugin. This should fix DEV-42766.
Diffstat (limited to 'indra/media_plugins')
-rw-r--r-- | indra/media_plugins/webkit/media_plugin_webkit.cpp | 128 |
1 files changed, 94 insertions, 34 deletions
diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp index 3ce8ff3deb..1e79720f43 100644 --- a/indra/media_plugins/webkit/media_plugin_webkit.cpp +++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp @@ -74,8 +74,17 @@ public: private: + enum + { + INIT_STATE_UNINITIALIZED, // Browser instance hasn't been set up yet + INIT_STATE_NAVIGATING, // Browser instance has been set up and initial navigate to about:blank has been issued + INIT_STATE_NAVIGATE_COMPLETE, // initial navigate to about:blank has completed + INIT_STATE_WAIT_REDRAW, // First real navigate begin has been received, waiting for page changed event to start handling redraws + INIT_STATE_RUNNING // All initialization gymnastics are complete. + }; int mBrowserWindowId; - bool mBrowserInitialized; + int mInitState; + std::string mInitialNavigateURL; bool mNeedsUpdate; bool mCanCut; @@ -93,7 +102,17 @@ private: checkEditState(); - if ( mNeedsUpdate ) + if(mInitState == INIT_STATE_NAVIGATE_COMPLETE) + { + if(!mInitialNavigateURL.empty()) + { + // We already have the initial navigate URL -- kick off the navigate. + LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, mInitialNavigateURL ); + mInitialNavigateURL.clear(); + } + } + + if ( (mInitState == INIT_STATE_RUNNING) && mNeedsUpdate ) { const unsigned char* browser_pixels = LLQtWebKit::getInstance()->grabBrowserWindow( mBrowserWindowId ); @@ -123,7 +142,7 @@ private: bool initBrowser() { // already initialized - if ( mBrowserInitialized ) + if ( mInitState > INIT_STATE_UNINITIALIZED ) return true; // not enough information to initialize the browser yet. @@ -210,20 +229,21 @@ private: // set background color to be black - mostly for initial login page LLQtWebKit::getInstance()->setBackgroundColor( mBrowserWindowId, 0x00, 0x00, 0x00 ); + // Set state _before_ starting the navigate, since onNavigateBegin might get called before this call returns. + mInitState = INIT_STATE_NAVIGATING; + // Don't do this here -- it causes the dreaded "white flash" when loading a browser instance. // FIXME: Re-added this because navigating to a "page" initializes things correctly - especially // for the HTTP AUTH dialog issues (DEV-41731). Will fix at a later date. LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, "about:blank" ); - // set flag so we don't do this again - mBrowserInitialized = true; - return true; }; return false; }; + //////////////////////////////////////////////////////////////////////////////// // virtual void onCursorChanged(const EventType& event) @@ -263,6 +283,11 @@ private: // virtual void onPageChanged( const EventType& event ) { + if(mInitState == INIT_STATE_WAIT_REDRAW) + { + mInitState = INIT_STATE_RUNNING; + } + // flag that an update is required mNeedsUpdate = true; }; @@ -271,62 +296,90 @@ private: // virtual void onNavigateBegin(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_begin"); - message.setValue("uri", event.getEventUri()); - sendMessage(message); - - setStatus(STATUS_LOADING); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_begin"); + message.setValue("uri", event.getEventUri()); + sendMessage(message); + + setStatus(STATUS_LOADING); + } + else if(mInitState == INIT_STATE_NAVIGATE_COMPLETE) + { + mInitState = INIT_STATE_WAIT_REDRAW; + } + } //////////////////////////////////////////////////////////////////////////////// // virtual void onNavigateComplete(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_complete"); - message.setValue("uri", event.getEventUri()); - message.setValueS32("result_code", event.getIntValue()); - message.setValue("result_string", event.getStringValue()); - message.setValueBoolean("history_back_available", LLQtWebKit::getInstance()->userActionIsEnabled( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_BACK)); - message.setValueBoolean("history_forward_available", LLQtWebKit::getInstance()->userActionIsEnabled( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_FORWARD)); - sendMessage(message); - - setStatus(STATUS_LOADED); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_complete"); + message.setValue("uri", event.getEventUri()); + message.setValueS32("result_code", event.getIntValue()); + message.setValue("result_string", event.getStringValue()); + message.setValueBoolean("history_back_available", LLQtWebKit::getInstance()->userActionIsEnabled( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_BACK)); + message.setValueBoolean("history_forward_available", LLQtWebKit::getInstance()->userActionIsEnabled( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_FORWARD)); + sendMessage(message); + + setStatus(STATUS_LOADED); + } + else if(mInitState == INIT_STATE_NAVIGATING) + { + mInitState = INIT_STATE_NAVIGATE_COMPLETE; + } + } //////////////////////////////////////////////////////////////////////////////// // virtual void onUpdateProgress(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "progress"); - message.setValueS32("percent", event.getIntValue()); - sendMessage(message); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "progress"); + message.setValueS32("percent", event.getIntValue()); + sendMessage(message); + } } //////////////////////////////////////////////////////////////////////////////// // virtual void onStatusTextChange(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "status_text"); - message.setValue("status", event.getStringValue()); - sendMessage(message); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "status_text"); + message.setValue("status", event.getStringValue()); + sendMessage(message); + } } //////////////////////////////////////////////////////////////////////////////// // virtual void onTitleChange(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "name_text"); - message.setValue("name", event.getStringValue()); - sendMessage(message); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "name_text"); + message.setValue("name", event.getStringValue()); + sendMessage(message); + } } //////////////////////////////////////////////////////////////////////////////// // virtual void onLocationChange(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "location_changed"); - message.setValue("uri", event.getEventUri()); - sendMessage(message); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "location_changed"); + message.setValue("uri", event.getEventUri()); + sendMessage(message); + } } //////////////////////////////////////////////////////////////////////////////// @@ -488,7 +541,7 @@ MediaPluginWebKit::MediaPluginWebKit(LLPluginInstance::sendMessageFunction host_ // std::cerr << "MediaPluginWebKit constructor" << std::endl; mBrowserWindowId = 0; - mBrowserInitialized = false; + mInitState = INIT_STATE_UNINITIALIZED; mNeedsUpdate = true; mCanCut = false; mCanCopy = false; @@ -674,7 +727,14 @@ void MediaPluginWebKit::receiveMessage(const char *message_string) if(!uri.empty()) { - LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, uri ); + if(mInitState >= INIT_STATE_NAVIGATE_COMPLETE) + { + LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, uri ); + } + else + { + mInitialNavigateURL = uri; + } } } else if(message_name == "mouse_event") |