| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if defined(ENABLE_PEPPER) | 5 #if defined(ENABLE_PEPPER) |
| 6 #define PEPPER_APIS_ENABLED | 6 #define PEPPER_APIS_ENABLED |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include "chrome/renderer/render_view.h" | 9 #include "chrome/renderer/render_view.h" |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "chrome/renderer/extensions/event_bindings.h" | 45 #include "chrome/renderer/extensions/event_bindings.h" |
| 46 #include "chrome/renderer/extensions/extension_process_bindings.h" | 46 #include "chrome/renderer/extensions/extension_process_bindings.h" |
| 47 #include "chrome/renderer/extensions/renderer_extension_bindings.h" | 47 #include "chrome/renderer/extensions/renderer_extension_bindings.h" |
| 48 #include "chrome/renderer/localized_error.h" | 48 #include "chrome/renderer/localized_error.h" |
| 49 #include "chrome/renderer/media/audio_renderer_impl.h" | 49 #include "chrome/renderer/media/audio_renderer_impl.h" |
| 50 #include "chrome/renderer/navigation_state.h" | 50 #include "chrome/renderer/navigation_state.h" |
| 51 #include "chrome/renderer/notification_provider.h" | 51 #include "chrome/renderer/notification_provider.h" |
| 52 #include "chrome/renderer/plugin_channel_host.h" | 52 #include "chrome/renderer/plugin_channel_host.h" |
| 53 #include "chrome/renderer/print_web_view_helper.h" | 53 #include "chrome/renderer/print_web_view_helper.h" |
| 54 #include "chrome/renderer/render_process.h" | 54 #include "chrome/renderer/render_process.h" |
| 55 #if defined(SPELLCHECKER_IN_RENDERER) | |
| 56 #include "chrome/renderer/spellchecker/spellcheck.h" | 55 #include "chrome/renderer/spellchecker/spellcheck.h" |
| 57 #endif | |
| 58 #include "chrome/renderer/user_script_slave.h" | 56 #include "chrome/renderer/user_script_slave.h" |
| 59 #include "chrome/renderer/visitedlink_slave.h" | 57 #include "chrome/renderer/visitedlink_slave.h" |
| 60 #include "chrome/renderer/webplugin_delegate_pepper.h" | 58 #include "chrome/renderer/webplugin_delegate_pepper.h" |
| 61 #include "chrome/renderer/webplugin_delegate_proxy.h" | 59 #include "chrome/renderer/webplugin_delegate_proxy.h" |
| 62 #include "chrome/renderer/websharedworker_proxy.h" | 60 #include "chrome/renderer/websharedworker_proxy.h" |
| 63 #include "chrome/renderer/webworker_proxy.h" | 61 #include "chrome/renderer/webworker_proxy.h" |
| 64 #include "grit/generated_resources.h" | 62 #include "grit/generated_resources.h" |
| 65 #include "grit/renderer_resources.h" | 63 #include "grit/renderer_resources.h" |
| 66 #include "net/base/data_url.h" | 64 #include "net/base/data_url.h" |
| 67 #include "net/base/escape.h" | 65 #include "net/base/escape.h" |
| (...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 } | 1494 } |
| 1497 | 1495 |
| 1498 return did_execute_command; | 1496 return did_execute_command; |
| 1499 } | 1497 } |
| 1500 | 1498 |
| 1501 void RenderView::spellCheck(const WebString& text, | 1499 void RenderView::spellCheck(const WebString& text, |
| 1502 int& misspelled_offset, | 1500 int& misspelled_offset, |
| 1503 int& misspelled_length) { | 1501 int& misspelled_length) { |
| 1504 EnsureDocumentTag(); | 1502 EnsureDocumentTag(); |
| 1505 | 1503 |
| 1506 #if defined(SPELLCHECKER_IN_RENDERER) | |
| 1507 string16 word(text); | 1504 string16 word(text); |
| 1508 RenderThread* thread = RenderThread::current(); | 1505 RenderThread* thread = RenderThread::current(); |
| 1509 // Will be NULL during unit tests. | 1506 // Will be NULL during unit tests. |
| 1510 if (thread) { | 1507 if (thread) { |
| 1511 RenderThread::current()->spellchecker()->SpellCheckWord( | 1508 thread->spellchecker()->SpellCheckWord( |
| 1512 word.c_str(), word.size(), document_tag_, | 1509 word.c_str(), word.size(), document_tag_, |
| 1513 &misspelled_offset, &misspelled_length, NULL); | 1510 &misspelled_offset, &misspelled_length, NULL); |
| 1514 } | 1511 } |
| 1515 #else | |
| 1516 Send(new ViewHostMsg_SpellCheck(routing_id_, text, document_tag_, | |
| 1517 &misspelled_offset, &misspelled_length)); | |
| 1518 #endif | |
| 1519 } | 1512 } |
| 1520 | 1513 |
| 1521 WebString RenderView::autoCorrectWord(const WebKit::WebString& word) { | 1514 WebString RenderView::autoCorrectWord(const WebKit::WebString& word) { |
| 1522 string16 autocorrect_word; | 1515 string16 autocorrect_word; |
| 1523 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1516 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 1524 if (command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures)) { | 1517 if (command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures)) { |
| 1525 EnsureDocumentTag(); | 1518 EnsureDocumentTag(); |
| 1526 #if defined(SPELLCHECKER_IN_RENDERER) | |
| 1527 RenderThread* thread = RenderThread::current(); | 1519 RenderThread* thread = RenderThread::current(); |
| 1528 // Will be NULL during unit tests. | 1520 // Will be NULL during unit tests. |
| 1529 if (thread) { | 1521 if (thread) { |
| 1530 autocorrect_word = | 1522 autocorrect_word = |
| 1531 RenderThread::current()->spellchecker()->GetAutoCorrectionWord( | 1523 thread->spellchecker()->GetAutoCorrectionWord( |
| 1532 word, document_tag_); | 1524 word, document_tag_); |
| 1533 } | 1525 } |
| 1534 #else | |
| 1535 Send(new ViewHostMsg_GetAutoCorrectWord( | |
| 1536 routing_id_, word, document_tag_, &autocorrect_word)); | |
| 1537 #endif | |
| 1538 } | 1526 } |
| 1539 return autocorrect_word; | 1527 return autocorrect_word; |
| 1540 } | 1528 } |
| 1541 | 1529 |
| 1542 void RenderView::showSpellingUI(bool show) { | 1530 void RenderView::showSpellingUI(bool show) { |
| 1543 Send(new ViewHostMsg_ShowSpellingPanel(routing_id_, show)); | 1531 Send(new ViewHostMsg_ShowSpellingPanel(routing_id_, show)); |
| 1544 } | 1532 } |
| 1545 | 1533 |
| 1546 bool RenderView::isShowingSpellingUI() { | 1534 bool RenderView::isShowingSpellingUI() { |
| 1547 return spelling_panel_visible_; | 1535 return spelling_panel_visible_; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 // response as RunJavaScriptMessage. | 1600 // response as RunJavaScriptMessage. |
| 1613 std::wstring ignored_result; | 1601 std::wstring ignored_result; |
| 1614 SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( | 1602 SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( |
| 1615 routing_id_, frame->url(), UTF16ToWideHack(message), &success, | 1603 routing_id_, frame->url(), UTF16ToWideHack(message), &success, |
| 1616 &ignored_result)); | 1604 &ignored_result)); |
| 1617 return success; | 1605 return success; |
| 1618 } | 1606 } |
| 1619 | 1607 |
| 1620 void RenderView::showContextMenu( | 1608 void RenderView::showContextMenu( |
| 1621 WebFrame* frame, const WebContextMenuData& data) { | 1609 WebFrame* frame, const WebContextMenuData& data) { |
| 1622 Send(new ViewHostMsg_ContextMenu(routing_id_, ContextMenuParams(data))); | 1610 ContextMenuParams params = ContextMenuParams(data); |
| 1611 if (!params.misspelled_word.empty() && RenderThread::current()) { |
| 1612 int misspelled_offset, misspelled_length; |
| 1613 bool misspelled = RenderThread::current()->spellchecker()->SpellCheckWord( |
| 1614 params.misspelled_word.c_str(), params.misspelled_word.size(), |
| 1615 document_tag_, |
| 1616 &misspelled_offset, &misspelled_length, |
| 1617 ¶ms.dictionary_suggestions); |
| 1618 if (!misspelled) |
| 1619 params.misspelled_word.clear(); |
| 1620 } |
| 1621 |
| 1622 Send(new ViewHostMsg_ContextMenu(routing_id_, params)); |
| 1623 } | 1623 } |
| 1624 | 1624 |
| 1625 void RenderView::setStatusText(const WebString& text) { | 1625 void RenderView::setStatusText(const WebString& text) { |
| 1626 } | 1626 } |
| 1627 | 1627 |
| 1628 void RenderView::UpdateTargetURL(const GURL& url, const GURL& fallback_url) { | 1628 void RenderView::UpdateTargetURL(const GURL& url, const GURL& fallback_url) { |
| 1629 GURL latest_url = url.spec().empty() ? fallback_url : url; | 1629 GURL latest_url = url.spec().empty() ? fallback_url : url; |
| 1630 if (latest_url == target_url_) | 1630 if (latest_url == target_url_) |
| 1631 return; | 1631 return; |
| 1632 | 1632 |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2540 void RenderView::didChangeContentsSize(WebFrame* frame, const WebSize& size) { | 2540 void RenderView::didChangeContentsSize(WebFrame* frame, const WebSize& size) { |
| 2541 // We don't always want to send the change messages over IPC, only if we've | 2541 // We don't always want to send the change messages over IPC, only if we've |
| 2542 // be put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | 2542 // be put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 2543 // message. | 2543 // message. |
| 2544 if (send_preferred_size_changes_) { | 2544 if (send_preferred_size_changes_) { |
| 2545 // WebCore likes to tell us things have changed even when they haven't, so | 2545 // WebCore likes to tell us things have changed even when they haven't, so |
| 2546 // cache the width and height and only send the IPC message when we're sure | 2546 // cache the width and height and only send the IPC message when we're sure |
| 2547 // they're different. | 2547 // they're different. |
| 2548 int width = webview()->mainFrame()->contentsPreferredWidth(); | 2548 int width = webview()->mainFrame()->contentsPreferredWidth(); |
| 2549 int height = webview()->mainFrame()->documentElementScrollHeight(); | 2549 int height = webview()->mainFrame()->documentElementScrollHeight(); |
| 2550 | 2550 |
| 2551 if (width != preferred_size_.width() || | 2551 if (width != preferred_size_.width() || |
| 2552 height != preferred_size_.height()) { | 2552 height != preferred_size_.height()) { |
| 2553 preferred_size_.set_width(width); | 2553 preferred_size_.set_width(width); |
| 2554 preferred_size_.set_height(height); | 2554 preferred_size_.set_height(height); |
| 2555 | 2555 |
| 2556 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, | 2556 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, |
| 2557 preferred_size_)); | 2557 preferred_size_)); |
| 2558 } | 2558 } |
| 2559 } | 2559 } |
| 2560 } | 2560 } |
| (...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3838 new PluginMsg_SignalModalDialogEvent(host_window_)); | 3838 new PluginMsg_SignalModalDialogEvent(host_window_)); |
| 3839 | 3839 |
| 3840 message->EnableMessagePumping(); // Runs a nested message loop. | 3840 message->EnableMessagePumping(); // Runs a nested message loop. |
| 3841 bool rv = Send(message); | 3841 bool rv = Send(message); |
| 3842 | 3842 |
| 3843 PluginChannelHost::Broadcast( | 3843 PluginChannelHost::Broadcast( |
| 3844 new PluginMsg_ResetModalDialogEvent(host_window_)); | 3844 new PluginMsg_ResetModalDialogEvent(host_window_)); |
| 3845 | 3845 |
| 3846 return rv; | 3846 return rv; |
| 3847 } | 3847 } |
| OLD | NEW |