OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #include "chrome/renderer/render_view_observer.h" | 84 #include "chrome/renderer/render_view_observer.h" |
85 #include "chrome/renderer/render_view_visitor.h" | 85 #include "chrome/renderer/render_view_visitor.h" |
86 #include "chrome/renderer/render_widget_fullscreen.h" | 86 #include "chrome/renderer/render_widget_fullscreen.h" |
87 #include "chrome/renderer/render_widget_fullscreen_pepper.h" | 87 #include "chrome/renderer/render_widget_fullscreen_pepper.h" |
88 #include "chrome/renderer/renderer_webapplicationcachehost_impl.h" | 88 #include "chrome/renderer/renderer_webapplicationcachehost_impl.h" |
89 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" | 89 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" |
90 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 90 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
91 #include "chrome/renderer/searchbox.h" | 91 #include "chrome/renderer/searchbox.h" |
92 #include "chrome/renderer/speech_input_dispatcher.h" | 92 #include "chrome/renderer/speech_input_dispatcher.h" |
93 #include "chrome/renderer/spellchecker/spellcheck.h" | 93 #include "chrome/renderer/spellchecker/spellcheck.h" |
| 94 #include "chrome/renderer/text_input_client_observer.h" |
94 #include "chrome/renderer/translate_helper.h" | 95 #include "chrome/renderer/translate_helper.h" |
95 #include "chrome/renderer/user_script_idle_scheduler.h" | 96 #include "chrome/renderer/user_script_idle_scheduler.h" |
96 #include "chrome/renderer/user_script_slave.h" | 97 #include "chrome/renderer/user_script_slave.h" |
97 #include "chrome/renderer/visitedlink_slave.h" | 98 #include "chrome/renderer/visitedlink_slave.h" |
98 #include "chrome/renderer/web_ui_bindings.h" | 99 #include "chrome/renderer/web_ui_bindings.h" |
99 #include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h" | 100 #include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h" |
100 #include "chrome/renderer/webplugin_delegate_pepper.h" | 101 #include "chrome/renderer/webplugin_delegate_pepper.h" |
101 #include "chrome/renderer/webplugin_delegate_proxy.h" | 102 #include "chrome/renderer/webplugin_delegate_proxy.h" |
102 #include "chrome/renderer/websharedworker_proxy.h" | 103 #include "chrome/renderer/websharedworker_proxy.h" |
103 #include "chrome/renderer/webworker_proxy.h" | 104 #include "chrome/renderer/webworker_proxy.h" |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 } | 607 } |
607 | 608 |
608 notification_provider_ = new NotificationProvider(this); | 609 notification_provider_ = new NotificationProvider(this); |
609 | 610 |
610 devtools_agent_ = new DevToolsAgent(this); | 611 devtools_agent_ = new DevToolsAgent(this); |
611 PasswordAutoFillManager* password_autofill_manager = | 612 PasswordAutoFillManager* password_autofill_manager = |
612 new PasswordAutoFillManager(this); | 613 new PasswordAutoFillManager(this); |
613 AutoFillAgent* autofill_agent = new AutoFillAgent(this, | 614 AutoFillAgent* autofill_agent = new AutoFillAgent(this, |
614 password_autofill_manager); | 615 password_autofill_manager); |
615 | 616 |
| 617 #if defined(OS_MACOSX) |
| 618 // Create the message filter for the TextInputClient. |
| 619 TextInputClientObserver* input_client = new TextInputClientObserver(this); |
| 620 input_client->render_view(); // Avoid unused variable warning. |
| 621 #endif // defined(OS_MACOSX) |
| 622 |
616 webwidget_ = WebView::create(this, devtools_agent_, autofill_agent); | 623 webwidget_ = WebView::create(this, devtools_agent_, autofill_agent); |
617 g_view_map.Get().insert(std::make_pair(webview(), this)); | 624 g_view_map.Get().insert(std::make_pair(webview(), this)); |
618 webkit_preferences_.Apply(webview()); | 625 webkit_preferences_.Apply(webview()); |
619 webview()->initializeMainFrame(this); | 626 webview()->initializeMainFrame(this); |
620 if (!frame_name.empty()) | 627 if (!frame_name.empty()) |
621 webview()->mainFrame()->setName(frame_name); | 628 webview()->mainFrame()->setName(frame_name); |
622 | 629 |
623 OnSetRendererPrefs(renderer_prefs); | 630 OnSetRendererPrefs(renderer_prefs); |
624 | 631 |
625 render_thread_->AddRoute(routing_id_, this); | 632 render_thread_->AddRoute(routing_id_, this); |
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 void RenderView::didChangeSelection(bool is_empty_selection) { | 2203 void RenderView::didChangeSelection(bool is_empty_selection) { |
2197 #if defined(OS_POSIX) | 2204 #if defined(OS_POSIX) |
2198 if (!handling_input_event_) | 2205 if (!handling_input_event_) |
2199 return; | 2206 return; |
2200 // TODO(estade): investigate incremental updates to the selection so that we | 2207 // TODO(estade): investigate incremental updates to the selection so that we |
2201 // don't send the entire selection over IPC every time. | 2208 // don't send the entire selection over IPC every time. |
2202 if (!is_empty_selection) { | 2209 if (!is_empty_selection) { |
2203 // Sometimes we get repeated didChangeSelection calls from webkit when | 2210 // Sometimes we get repeated didChangeSelection calls from webkit when |
2204 // the selection hasn't actually changed. We don't want to report these | 2211 // the selection hasn't actually changed. We don't want to report these |
2205 // because it will cause us to continually claim the X clipboard. | 2212 // because it will cause us to continually claim the X clipboard. |
2206 const std::string& this_selection = | 2213 WebFrame* frame = webview()->focusedFrame(); |
2207 webview()->focusedFrame()->selectionAsText().utf8(); | 2214 const std::string& this_selection = frame->selectionAsText().utf8(); |
2208 if (this_selection == last_selection_) | 2215 if (this_selection == last_selection_) |
2209 return; | 2216 return; |
2210 | 2217 |
| 2218 WebRange range = frame->selectionRange(); |
2211 Send(new ViewHostMsg_SelectionChanged(routing_id_, | 2219 Send(new ViewHostMsg_SelectionChanged(routing_id_, |
2212 this_selection)); | 2220 this_selection, range.startOffset(), range.endOffset())); |
2213 last_selection_ = this_selection; | 2221 last_selection_ = this_selection; |
2214 } else { | 2222 } else { |
2215 last_selection_.clear(); | 2223 last_selection_.clear(); |
2216 Send(new ViewHostMsg_SelectionChanged(routing_id_, | 2224 WebRange range = webwidget_->caretOrSelectionRange(); |
2217 last_selection_)); | 2225 if (!range.isNull()) { |
| 2226 Send(new ViewHostMsg_SelectionChanged(routing_id_, |
| 2227 last_selection_, range.startOffset(), range.endOffset())); |
| 2228 } else { |
| 2229 Send(new ViewHostMsg_SelectionChanged(routing_id_, |
| 2230 last_selection_, 0, 0)); |
| 2231 } |
2218 } | 2232 } |
2219 #endif // defined(OS_POSIX) | 2233 #endif // defined(OS_POSIX) |
2220 } | 2234 } |
2221 | 2235 |
2222 void RenderView::didExecuteCommand(const WebString& command_name) { | 2236 void RenderView::didExecuteCommand(const WebString& command_name) { |
2223 const std::string& name = UTF16ToUTF8(command_name); | 2237 const std::string& name = UTF16ToUTF8(command_name); |
2224 if (StartsWithASCII(name, "Move", true) || | 2238 if (StartsWithASCII(name, "Move", true) || |
2225 StartsWithASCII(name, "Insert", true) || | 2239 StartsWithASCII(name, "Insert", true) || |
2226 StartsWithASCII(name, "Delete", true)) | 2240 StartsWithASCII(name, "Delete", true)) |
2227 return; | 2241 return; |
(...skipping 3444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5672 } | 5686 } |
5673 } | 5687 } |
5674 | 5688 |
5675 void RenderView::OnContextMenuClosed( | 5689 void RenderView::OnContextMenuClosed( |
5676 const webkit_glue::CustomContextMenuContext& custom_context) { | 5690 const webkit_glue::CustomContextMenuContext& custom_context) { |
5677 if (custom_context.is_pepper_menu) | 5691 if (custom_context.is_pepper_menu) |
5678 pepper_delegate_.OnContextMenuClosed(custom_context); | 5692 pepper_delegate_.OnContextMenuClosed(custom_context); |
5679 else | 5693 else |
5680 context_menu_node_.reset(); | 5694 context_menu_node_.reset(); |
5681 } | 5695 } |
OLD | NEW |