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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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/malware_dom_details.h" | 90 #include "chrome/renderer/safe_browsing/malware_dom_details.h" |
91 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 91 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
92 #include "chrome/renderer/searchbox.h" | 92 #include "chrome/renderer/searchbox.h" |
93 #include "chrome/renderer/speech_input_dispatcher.h" | 93 #include "chrome/renderer/speech_input_dispatcher.h" |
94 #include "chrome/renderer/spellchecker/spellcheck_provider.h" | 94 #include "chrome/renderer/spellchecker/spellcheck_provider.h" |
95 #include "chrome/renderer/spellchecker/spellcheck.h" | 95 #include "chrome/renderer/spellchecker/spellcheck.h" |
96 #include "chrome/renderer/text_input_client_observer.h" | |
96 #include "chrome/renderer/translate_helper.h" | 97 #include "chrome/renderer/translate_helper.h" |
97 #include "chrome/renderer/user_script_idle_scheduler.h" | 98 #include "chrome/renderer/user_script_idle_scheduler.h" |
98 #include "chrome/renderer/user_script_slave.h" | 99 #include "chrome/renderer/user_script_slave.h" |
99 #include "chrome/renderer/visitedlink_slave.h" | 100 #include "chrome/renderer/visitedlink_slave.h" |
100 #include "chrome/renderer/web_ui_bindings.h" | 101 #include "chrome/renderer/web_ui_bindings.h" |
101 #include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h" | 102 #include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h" |
102 #include "chrome/renderer/webplugin_delegate_pepper.h" | 103 #include "chrome/renderer/webplugin_delegate_pepper.h" |
103 #include "chrome/renderer/webplugin_delegate_proxy.h" | 104 #include "chrome/renderer/webplugin_delegate_proxy.h" |
104 #include "chrome/renderer/websharedworker_proxy.h" | 105 #include "chrome/renderer/websharedworker_proxy.h" |
105 #include "chrome/renderer/webworker_proxy.h" | 106 #include "chrome/renderer/webworker_proxy.h" |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
614 } | 615 } |
615 | 616 |
616 notification_provider_ = new NotificationProvider(this); | 617 notification_provider_ = new NotificationProvider(this); |
617 | 618 |
618 devtools_agent_ = new DevToolsAgent(this); | 619 devtools_agent_ = new DevToolsAgent(this); |
619 PasswordAutoFillManager* password_autofill_manager = | 620 PasswordAutoFillManager* password_autofill_manager = |
620 new PasswordAutoFillManager(this); | 621 new PasswordAutoFillManager(this); |
621 AutoFillAgent* autofill_agent = new AutoFillAgent(this, | 622 AutoFillAgent* autofill_agent = new AutoFillAgent(this, |
622 password_autofill_manager); | 623 password_autofill_manager); |
623 | 624 |
625 #if defined(OS_MACOSX) | |
626 // Create the message filter for the TextInputClient. | |
627 TextInputClientObserver* input_client = new TextInputClientObserver(this); | |
628 input_client->render_view(); // Avoid unused variable warning. | |
629 #endif // defined(OS_MACOSX) | |
630 | |
624 webwidget_ = WebView::create(this, devtools_agent_, autofill_agent); | 631 webwidget_ = WebView::create(this, devtools_agent_, autofill_agent); |
625 g_view_map.Get().insert(std::make_pair(webview(), this)); | 632 g_view_map.Get().insert(std::make_pair(webview(), this)); |
626 webkit_preferences_.Apply(webview()); | 633 webkit_preferences_.Apply(webview()); |
627 webview()->initializeMainFrame(this); | 634 webview()->initializeMainFrame(this); |
628 if (!frame_name.empty()) | 635 if (!frame_name.empty()) |
629 webview()->mainFrame()->setName(frame_name); | 636 webview()->mainFrame()->setName(frame_name); |
630 webview()->settings()->setMinimumTimerInterval( | 637 webview()->settings()->setMinimumTimerInterval( |
631 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : | 638 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
632 webkit_glue::kForegroundTabTimerInterval); | 639 webkit_glue::kForegroundTabTimerInterval); |
633 | 640 |
(...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2226 void RenderView::didChangeSelection(bool is_empty_selection) { | 2233 void RenderView::didChangeSelection(bool is_empty_selection) { |
2227 #if defined(OS_POSIX) | 2234 #if defined(OS_POSIX) |
2228 if (!handling_input_event_) | 2235 if (!handling_input_event_) |
2229 return; | 2236 return; |
2230 // TODO(estade): investigate incremental updates to the selection so that we | 2237 // TODO(estade): investigate incremental updates to the selection so that we |
2231 // don't send the entire selection over IPC every time. | 2238 // don't send the entire selection over IPC every time. |
2232 if (!is_empty_selection) { | 2239 if (!is_empty_selection) { |
2233 // Sometimes we get repeated didChangeSelection calls from webkit when | 2240 // Sometimes we get repeated didChangeSelection calls from webkit when |
2234 // the selection hasn't actually changed. We don't want to report these | 2241 // the selection hasn't actually changed. We don't want to report these |
2235 // because it will cause us to continually claim the X clipboard. | 2242 // because it will cause us to continually claim the X clipboard. |
2236 const std::string& this_selection = | 2243 WebFrame* frame = webview()->focusedFrame(); |
2237 webview()->focusedFrame()->selectionAsText().utf8(); | 2244 const std::string& this_selection = frame->selectionAsText().utf8(); |
2238 if (this_selection == last_selection_) | 2245 if (this_selection == last_selection_) |
2239 return; | 2246 return; |
2240 | 2247 |
2248 WebRange range = frame->selectionRange(); | |
James Su
2011/03/03 04:10:31
IMHO we should use the same code path regardless o
Robert Sesek
2011/03/18 21:33:16
Done.
| |
2241 Send(new ViewHostMsg_SelectionChanged(routing_id_, | 2249 Send(new ViewHostMsg_SelectionChanged(routing_id_, |
2242 this_selection)); | 2250 this_selection, range.startOffset(), range.endOffset())); |
2243 last_selection_ = this_selection; | 2251 last_selection_ = this_selection; |
2244 } else { | 2252 } else { |
2245 last_selection_.clear(); | 2253 last_selection_.clear(); |
2246 Send(new ViewHostMsg_SelectionChanged(routing_id_, | 2254 WebRange range = webwidget_->caretOrSelectionRange(); |
2247 last_selection_)); | 2255 if (!range.isNull()) { |
2256 Send(new ViewHostMsg_SelectionChanged(routing_id_, | |
2257 last_selection_, range.startOffset(), range.endOffset())); | |
2258 } else { | |
2259 Send(new ViewHostMsg_SelectionChanged(routing_id_, | |
2260 last_selection_, 0, 0)); | |
2261 } | |
2248 } | 2262 } |
2249 #endif // defined(OS_POSIX) | 2263 #endif // defined(OS_POSIX) |
2250 } | 2264 } |
2251 | 2265 |
2252 void RenderView::didExecuteCommand(const WebString& command_name) { | 2266 void RenderView::didExecuteCommand(const WebString& command_name) { |
2253 const std::string& name = UTF16ToUTF8(command_name); | 2267 const std::string& name = UTF16ToUTF8(command_name); |
2254 if (StartsWithASCII(name, "Move", true) || | 2268 if (StartsWithASCII(name, "Move", true) || |
2255 StartsWithASCII(name, "Insert", true) || | 2269 StartsWithASCII(name, "Insert", true) || |
2256 StartsWithASCII(name, "Delete", true)) | 2270 StartsWithASCII(name, "Delete", true)) |
2257 return; | 2271 return; |
(...skipping 3439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5697 } | 5711 } |
5698 } | 5712 } |
5699 | 5713 |
5700 void RenderView::OnContextMenuClosed( | 5714 void RenderView::OnContextMenuClosed( |
5701 const webkit_glue::CustomContextMenuContext& custom_context) { | 5715 const webkit_glue::CustomContextMenuContext& custom_context) { |
5702 if (custom_context.is_pepper_menu) | 5716 if (custom_context.is_pepper_menu) |
5703 pepper_delegate_.OnContextMenuClosed(custom_context); | 5717 pepper_delegate_.OnContextMenuClosed(custom_context); |
5704 else | 5718 else |
5705 context_menu_node_.reset(); | 5719 context_menu_node_.reset(); |
5706 } | 5720 } |
OLD | NEW |