Changeset 2
- Timestamp:
- 11/21/07 18:45:01 (2 years ago)
- Files:
-
- trunk/llembeddedbrowserwindow.cpp (modified) (4 diffs)
- trunk/llembeddedbrowserwindow.h (modified) (3 diffs)
- trunk/llmozlib.cpp (modified) (1 diff)
- trunk/llmozlib.h (modified) (1 diff)
- trunk/tests/ubrowser.llmozlib/ubrowser.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/llembeddedbrowserwindow.cpp
r1 r2 58 58 #include "nsIDocument.h" 59 59 #include "nsIFrame.h" 60 #include "nsIHttpChannel.h" 60 61 #include "nsIInterfaceRequestorUtils.h" 61 62 #include "nsIScrollableView.h" … … 93 94 mBackgroundRed( 0xff ), 94 95 mBackgroundGreen( 0xff ), 95 mBackgroundBlue( 0xff ) 96 mBackgroundBlue( 0xff ), 97 m404RedirectUrl( "" ) 96 98 { 97 99 } … … 384 386 // TODO: ought to check that this change is on the top frame and 385 387 // indicate this to the consumer of this class 386 NS_IMETHODIMP LLEmbeddedBrowserWindow::OnLocationChange( nsIWebProgress* aWebProgress, 387 nsIRequest* aRequest, 388 nsIURI* aLocation ) 389 { 388 NS_IMETHODIMP LLEmbeddedBrowserWindow::OnLocationChange( nsIWebProgress* progress, 389 nsIRequest* request, 390 nsIURI* location ) 391 { 392 if ( request ) 393 { 394 nsCOMPtr< nsIHttpChannel > http_channel = do_QueryInterface( request ); 395 if ( http_channel ) 396 { 397 PRUint32 response_status = 0; 398 http_channel->GetResponseStatus( &response_status ); 399 400 if ( response_status == 404 ) 401 { 402 if ( ! m404RedirectUrl.empty() ) 403 { 404 if ( mWebNav ) 405 { 406 mWebNav->LoadURI( reinterpret_cast< const PRUnichar* > 407 ( NS_ConvertUTF8toUTF16( m404RedirectUrl.c_str() ).get() ), 408 nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY, 409 nsnull, nsnull, nsnull ); 410 }; 411 }; 412 }; 413 }; 414 }; 415 390 416 nsCAutoString newURI; 391 aLocation->GetSpec( newURI );417 location->GetSpec( newURI ); 392 418 393 419 mCurrentUri = newURI.get(); … … 1078 1104 } 1079 1105 1106 //////////////////////////////////////////////////////////////////////////////// 1107 // 1108 bool LLEmbeddedBrowserWindow::set404RedirectUrl( std::string redirect_url ) 1109 { 1110 m404RedirectUrl = redirect_url; 1111 1112 return true; 1113 } 1114 1115 //////////////////////////////////////////////////////////////////////////////// 1116 // 1117 bool LLEmbeddedBrowserWindow::clr404RedirectUrl() 1118 { 1119 m404RedirectUrl = std::string( "" ); 1120 1121 return true; 1122 } 1123 1080 1124 // #define required by this file for LibXUL/Mozilla code to avoid crashes in their debug code 1081 1125 #ifdef _DEBUG trunk/llembeddedbrowserwindow.h
r1 r2 165 165 void navigateForward(); 166 166 167 bool set404RedirectUrl( std::string redirect_url ); 168 bool clr404RedirectUrl(); 169 167 170 void mouseDown( PRInt16 xPosIn, PRInt16 yPosIn ); 168 171 void mouseUp( PRInt16 xPosIn, PRInt16 yPosIn ); … … 183 186 std::string mCurrentUri; 184 187 std::string mClickHref; 188 std::string m404RedirectUrl; 185 189 186 190 nsCOMPtr< nsIWebBrowser > mWebBrowser; … … 193 197 PRUint8 mBackgroundGreen; 194 198 PRUint8 mBackgroundBlue; 195 196 199 197 200 unsigned char* mPageBuffer; trunk/llmozlib.cpp
r1 r2 514 514 } 515 515 516 //////////////////////////////////////////////////////////////////////////////// 517 // 518 bool LLMozLib::set404RedirectUrl( int browser_window_in, std::string redirect_url ) 519 { 520 LLEmbeddedBrowserWindow* browser_window = getBrowserWindowFromWindowId( browser_window_in ); 521 if ( browser_window ) 522 { 523 browser_window->set404RedirectUrl( redirect_url ); 524 525 return true; 526 }; 527 528 return false; 529 } 530 531 //////////////////////////////////////////////////////////////////////////////// 532 // 533 bool LLMozLib::clr404RedirectUrl( int browser_window_in ) 534 { 535 LLEmbeddedBrowserWindow* browser_window = getBrowserWindowFromWindowId( browser_window_in ); 536 if ( browser_window ) 537 { 538 browser_window->clr404RedirectUrl(); 539 540 return true; 541 }; 542 543 return false; 544 } trunk/llmozlib.h
r1 r2 143 143 bool canNavigateForward( int browserWindowIdIn ); 144 144 bool navigateForward( int browserWindowIdIn ); 145 146 // set/clear URL to redirect to when a 404 page is reached 147 bool set404RedirectUrl( int browser_window_in, std::string redirect_url ); 148 bool clr404RedirectUrl( int browser_window_in ); 145 149 146 150 // access to rendered bitmap data trunk/tests/ubrowser.llmozlib/ubrowser.cpp
r1 r2 112 112 mBookmarks.push_back( std::pair< std::string, std::string >( "DHTML Lemmings!", "http://www.elizium.nu/scripts/lemmings/" ) ); 113 113 mBookmarks.push_back( std::pair< std::string, std::string >( "DHTML Demos", "http://www.dhteumeuleu.com/" ) ); 114 mBookmarks.push_back( std::pair< std::string, std::string >( "S3 404 test", "http://world.secondlife.com/parcel/jumk" ) ); 114 115 mBookmarks.push_back( std::pair< std::string, std::string >( "about:config", "about:config" ) ); 115 116 } … … 222 223 223 224 LLMozLib::getInstance()->setBrowserAgentId( "[uBrowser]" ); 225 226 LLMozLib::getInstance()->set404RedirectUrl( mWindowA, "http://secondlife.com/app/search/notfound.html" ); 224 227 225 228 std::cout << "LLMozLib version: " << LLMozLib::getInstance()->getVersion() << std::endl;
