diff options
Diffstat (limited to 'linden/indra/media_plugins/webkit/media_plugin_webkit.cpp')
-rw-r--r-- | linden/indra/media_plugins/webkit/media_plugin_webkit.cpp | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/linden/indra/media_plugins/webkit/media_plugin_webkit.cpp b/linden/indra/media_plugins/webkit/media_plugin_webkit.cpp index f115c28..91efdae 100644 --- a/linden/indra/media_plugins/webkit/media_plugin_webkit.cpp +++ b/linden/indra/media_plugins/webkit/media_plugin_webkit.cpp | |||
@@ -75,6 +75,8 @@ public: | |||
75 | 75 | ||
76 | private: | 76 | private: |
77 | 77 | ||
78 | std::string mProfileDir; | ||
79 | |||
78 | enum | 80 | enum |
79 | { | 81 | { |
80 | INIT_STATE_UNINITIALIZED, // Browser instance hasn't been set up yet | 82 | INIT_STATE_UNINITIALIZED, // Browser instance hasn't been set up yet |
@@ -95,6 +97,12 @@ private: | |||
95 | int mLastMouseY; | 97 | int mLastMouseY; |
96 | bool mFirstFocus; | 98 | bool mFirstFocus; |
97 | 99 | ||
100 | void setInitState(int state) | ||
101 | { | ||
102 | // std::cerr << "changing init state to " << state << std::endl; | ||
103 | mInitState = state; | ||
104 | } | ||
105 | |||
98 | //////////////////////////////////////////////////////////////////////////////// | 106 | //////////////////////////////////////////////////////////////////////////////// |
99 | // | 107 | // |
100 | void update(int milliseconds) | 108 | void update(int milliseconds) |
@@ -186,7 +194,6 @@ private: | |||
186 | #else | 194 | #else |
187 | std::string component_dir = application_dir; | 195 | std::string component_dir = application_dir; |
188 | #endif | 196 | #endif |
189 | std::string profileDir = application_dir + "/" + "browser_profile"; // cross platform? | ||
190 | 197 | ||
191 | // window handle - needed on Windows and must be app window. | 198 | // window handle - needed on Windows and must be app window. |
192 | #if LL_WINDOWS | 199 | #if LL_WINDOWS |
@@ -198,7 +205,7 @@ private: | |||
198 | #endif | 205 | #endif |
199 | 206 | ||
200 | // main browser initialization | 207 | // main browser initialization |
201 | bool result = LLQtWebKit::getInstance()->init( application_dir, component_dir, profileDir, native_window_handle ); | 208 | bool result = LLQtWebKit::getInstance()->init( application_dir, component_dir, mProfileDir, native_window_handle ); |
202 | if ( result ) | 209 | if ( result ) |
203 | { | 210 | { |
204 | // create single browser window | 211 | // create single browser window |
@@ -208,13 +215,15 @@ private: | |||
208 | // Enable plugins | 215 | // Enable plugins |
209 | LLQtWebKit::getInstance()->enablePlugins(true); | 216 | LLQtWebKit::getInstance()->enablePlugins(true); |
210 | #elif LL_DARWIN | 217 | #elif LL_DARWIN |
211 | // Disable plugins | 218 | // Enable plugins |
212 | LLQtWebKit::getInstance()->enablePlugins(false); | 219 | LLQtWebKit::getInstance()->enablePlugins(true); |
213 | #elif LL_LINUX | 220 | #elif LL_LINUX |
214 | // Disable plugins | 221 | // Enable plugins |
215 | LLQtWebKit::getInstance()->enablePlugins(false); | 222 | LLQtWebKit::getInstance()->enablePlugins(true); |
216 | #endif | 223 | #endif |
217 | 224 | // Enable cookies | |
225 | LLQtWebKit::getInstance()->enableCookies( true ); | ||
226 | |||
218 | // tell LLQtWebKit about the size of the browser window | 227 | // tell LLQtWebKit about the size of the browser window |
219 | LLQtWebKit::getInstance()->setSize( mBrowserWindowId, mWidth, mHeight ); | 228 | LLQtWebKit::getInstance()->setSize( mBrowserWindowId, mWidth, mHeight ); |
220 | 229 | ||
@@ -227,11 +236,11 @@ private: | |||
227 | // don't flip bitmap | 236 | // don't flip bitmap |
228 | LLQtWebKit::getInstance()->flipWindow( mBrowserWindowId, true ); | 237 | LLQtWebKit::getInstance()->flipWindow( mBrowserWindowId, true ); |
229 | 238 | ||
230 | // Set the background color to black - mostly for initial login page | 239 | // set background color to be black - mostly for initial login page |
231 | LLQtWebKit::getInstance()->setBackgroundColor( mBrowserWindowId, 0x00, 0x00, 0x00 ); | 240 | LLQtWebKit::getInstance()->setBackgroundColor( mBrowserWindowId, 0x00, 0x00, 0x00 ); |
232 | 241 | ||
233 | // Set state _before_ starting the navigate, since onNavigateBegin might get called before this call returns. | 242 | // Set state _before_ starting the navigate, since onNavigateBegin might get called before this call returns. |
234 | mInitState = INIT_STATE_NAVIGATING; | 243 | setInitState(INIT_STATE_NAVIGATING); |
235 | 244 | ||
236 | // Don't do this here -- it causes the dreaded "white flash" when loading a browser instance. | 245 | // Don't do this here -- it causes the dreaded "white flash" when loading a browser instance. |
237 | // FIXME: Re-added this because navigating to a "page" initializes things correctly - especially | 246 | // FIXME: Re-added this because navigating to a "page" initializes things correctly - especially |
@@ -285,7 +294,7 @@ private: | |||
285 | { | 294 | { |
286 | if(mInitState == INIT_STATE_WAIT_REDRAW) | 295 | if(mInitState == INIT_STATE_WAIT_REDRAW) |
287 | { | 296 | { |
288 | mInitState = INIT_STATE_RUNNING; | 297 | setInitState(INIT_STATE_RUNNING); |
289 | } | 298 | } |
290 | 299 | ||
291 | // flag that an update is required | 300 | // flag that an update is required |
@@ -307,7 +316,7 @@ private: | |||
307 | 316 | ||
308 | if(mInitState == INIT_STATE_NAVIGATE_COMPLETE) | 317 | if(mInitState == INIT_STATE_NAVIGATE_COMPLETE) |
309 | { | 318 | { |
310 | mInitState = INIT_STATE_WAIT_REDRAW; | 319 | setInitState(INIT_STATE_WAIT_REDRAW); |
311 | } | 320 | } |
312 | 321 | ||
313 | } | 322 | } |
@@ -330,7 +339,7 @@ private: | |||
330 | } | 339 | } |
331 | else if(mInitState == INIT_STATE_NAVIGATING) | 340 | else if(mInitState == INIT_STATE_NAVIGATING) |
332 | { | 341 | { |
333 | mInitState = INIT_STATE_NAVIGATE_COMPLETE; | 342 | setInitState(INIT_STATE_NAVIGATE_COMPLETE); |
334 | } | 343 | } |
335 | 344 | ||
336 | } | 345 | } |
@@ -495,7 +504,16 @@ private: | |||
495 | { | 504 | { |
496 | // std::cerr << "unicode input, code = 0x" << std::hex << (unsigned long)(wstr[i]) << std::dec << std::endl; | 505 | // std::cerr << "unicode input, code = 0x" << std::hex << (unsigned long)(wstr[i]) << std::dec << std::endl; |
497 | 506 | ||
498 | LLQtWebKit::getInstance()->unicodeInput(mBrowserWindowId, wstr[i], modifiers); | 507 | if(wstr[i] == 32) |
508 | { | ||
509 | // For some reason, the webkit plugin really wants the space bar to come in through the key-event path, not the unicode path. | ||
510 | LLQtWebKit::getInstance()->keyEvent( mBrowserWindowId, LLQtWebKit::KE_KEY_DOWN, 32, modifiers); | ||
511 | LLQtWebKit::getInstance()->keyEvent( mBrowserWindowId, LLQtWebKit::KE_KEY_UP, 32, modifiers); | ||
512 | } | ||
513 | else | ||
514 | { | ||
515 | LLQtWebKit::getInstance()->unicodeInput(mBrowserWindowId, wstr[i], modifiers); | ||
516 | } | ||
499 | } | 517 | } |
500 | 518 | ||
501 | checkEditState(); | 519 | checkEditState(); |
@@ -576,6 +594,9 @@ void MediaPluginWebKit::receiveMessage(const char *message_string) | |||
576 | { | 594 | { |
577 | if(message_name == "init") | 595 | if(message_name == "init") |
578 | { | 596 | { |
597 | std::string user_data_path = message_in.getValue("user_data_path"); // n.b. always has trailing platform-specific dir-delimiter | ||
598 | mProfileDir = user_data_path + "browser_profile"; | ||
599 | |||
579 | LLPluginMessage message("base", "init_response"); | 600 | LLPluginMessage message("base", "init_response"); |
580 | LLSD versions = LLSD::emptyMap(); | 601 | LLSD versions = LLSD::emptyMap(); |
581 | versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION; | 602 | versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION; |
@@ -611,7 +632,11 @@ void MediaPluginWebKit::receiveMessage(const char *message_string) | |||
611 | } | 632 | } |
612 | else if(message_name == "cleanup") | 633 | else if(message_name == "cleanup") |
613 | { | 634 | { |
614 | // TODO: clean up here | 635 | // DTOR most likely won't be called but the recent change to the way this process |
636 | // is (not) killed means we see this message and can do what we need to here. | ||
637 | // Note: this cleanup is ultimately what writes cookies to the disk | ||
638 | LLQtWebKit::getInstance()->remObserver( mBrowserWindowId, this ); | ||
639 | LLQtWebKit::getInstance()->reset(); | ||
615 | } | 640 | } |
616 | else if(message_name == "shm_added") | 641 | else if(message_name == "shm_added") |
617 | { | 642 | { |