From f44d24fafba7e8b9e8b5318602088a69d8da741c Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sun, 21 Jul 2013 13:02:55 -0700 Subject: ACME-734 : Fix : Factorize and clean up web browsing address, log and history code --- indra/newview/llfloaterwebcontent.cpp | 36 ++++++++++++++++------------------- indra/newview/llfloaterwebcontent.h | 4 ++-- 2 files changed, 18 insertions(+), 22 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp index 5e8bb7ad57..129e1f0e2a 100755 --- a/indra/newview/llfloaterwebcontent.cpp +++ b/indra/newview/llfloaterwebcontent.cpp @@ -68,6 +68,7 @@ LLFloaterWebContent::LLFloaterWebContent( const Params& params ) mUUID(params.id()), mShowPageTitle(params.show_page_title), mAllowNavigation(true), + mCurrentURL(""), mDisplayURL("") { mCommitCallbackRegistrar.add( "WebContent.Back", boost::bind( &LLFloaterWebContent::onClickBack, this )); @@ -356,17 +357,8 @@ void LLFloaterWebContent::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent if (test_prefix == prefix) { mSecureLockIcon->setVisible(true); - if (!mDisplayURL.empty()) - { - // Clear temporary entry if any - mAddressCombo->remove( mDisplayURL ); - mDisplayURL = ""; - } // Hack : we move the text a bit to make space for the lock icon. - // That entry in the list will be deleted on the next add. - mDisplayURL = " " + mCurrentURL; - mAddressCombo->add( mDisplayURL ); - mAddressCombo->selectByValue( mDisplayURL ); + set_current_url(" " + mCurrentURL); } else { @@ -414,22 +406,26 @@ void LLFloaterWebContent::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent void LLFloaterWebContent::set_current_url(const std::string& url) { + if (!mCurrentURL.empty()) + { + // Clean up the current browsing list to show true URL + mAddressCombo->remove(mDisplayURL); + mAddressCombo->add(mCurrentURL); + } + + // Update current URLs + mDisplayURL = url; mCurrentURL = url; LLStringUtil::trim(mCurrentURL); + // Serialize url history into the system URL History manager LLURLHistory::removeURL("browser", mCurrentURL); - // serialize url history into the system URL History manager LLURLHistory::addURL("browser", mCurrentURL); - if (!mDisplayURL.empty()) - { - // Clear temporary entry if any - mAddressCombo->remove( mDisplayURL ); - mDisplayURL = ""; - } - mAddressCombo->remove( mCurrentURL ); - mAddressCombo->add( mCurrentURL ); - mAddressCombo->selectByValue( mCurrentURL ); + // Clean up browsing list (prevent dupes) and add/select new URL to it + mAddressCombo->remove(mCurrentURL); + mAddressCombo->add(mDisplayURL); + mAddressCombo->selectByValue(mDisplayURL); } void LLFloaterWebContent::onClickForward() diff --git a/indra/newview/llfloaterwebcontent.h b/indra/newview/llfloaterwebcontent.h index 9d6d28bce0..5976474e0e 100755 --- a/indra/newview/llfloaterwebcontent.h +++ b/indra/newview/llfloaterwebcontent.h @@ -106,8 +106,8 @@ protected: LLView* mBtnReload; LLView* mBtnStop; - std::string mCurrentURL; - std::string mDisplayURL; + std::string mCurrentURL; // Current URL + std::string mDisplayURL; // URL being displayed in the address bar (can differ by trailing / leading space) std::string mUUID; bool mShowPageTitle; bool mAllowNavigation; -- cgit v1.2.3