OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2018 const std::string& name = UTF16ToUTF8(command_name); | 2018 const std::string& name = UTF16ToUTF8(command_name); |
2019 if (StartsWithASCII(name, "Move", true) || | 2019 if (StartsWithASCII(name, "Move", true) || |
2020 StartsWithASCII(name, "Insert", true) || | 2020 StartsWithASCII(name, "Insert", true) || |
2021 StartsWithASCII(name, "Delete", true)) | 2021 StartsWithASCII(name, "Delete", true)) |
2022 return; | 2022 return; |
2023 UserMetricsRecordAction(name); | 2023 UserMetricsRecordAction(name); |
2024 } | 2024 } |
2025 | 2025 |
2026 void RenderView::textFieldDidEndEditing( | 2026 void RenderView::textFieldDidEndEditing( |
2027 const WebKit::WebInputElement& element) { | 2027 const WebKit::WebInputElement& element) { |
2028 #if defined(WEBKIT_BUG_41283_IS_FIXED) | |
2029 password_autocomplete_manager_->TextFieldDidEndEditing(element); | 2028 password_autocomplete_manager_->TextFieldDidEndEditing(element); |
2030 #endif | |
2031 } | 2029 } |
2032 | 2030 |
2033 void RenderView::textFieldDidChange(const WebKit::WebInputElement& element) { | 2031 void RenderView::textFieldDidChange(const WebKit::WebInputElement& element) { |
2034 #if defined(WEBKIT_BUG_41283_IS_FIXED) | |
2035 // We post a task for doing the AutoFill as the caret position is not set | 2032 // We post a task for doing the AutoFill as the caret position is not set |
2036 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and | 2033 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and |
2037 // it is needed to trigger autofill. | 2034 // it is needed to trigger autofill. |
2038 autofill_method_factory_.RevokeAll(); | 2035 autofill_method_factory_.RevokeAll(); |
2039 MessageLoop::current()->PostTask( | 2036 MessageLoop::current()->PostTask( |
2040 FROM_HERE, | 2037 FROM_HERE, |
2041 autofill_method_factory_.NewRunnableMethod( | 2038 autofill_method_factory_.NewRunnableMethod( |
2042 &RenderView::TextFieldDidChangeImpl, element)); | 2039 &RenderView::TextFieldDidChangeImpl, element)); |
2043 #endif | |
2044 } | 2040 } |
2045 | 2041 |
2046 void RenderView::TextFieldDidChangeImpl( | 2042 void RenderView::TextFieldDidChangeImpl( |
2047 const WebKit::WebInputElement& element) { | 2043 const WebKit::WebInputElement& element) { |
2048 if (password_autocomplete_manager_->TextDidChangeInTextField(element)) | 2044 if (password_autocomplete_manager_->TextDidChangeInTextField(element)) |
2049 return; | 2045 return; |
2050 autofill_helper_->TextDidChangeInTextField(element); | 2046 autofill_helper_->TextDidChangeInTextField(element); |
2051 } | 2047 } |
2052 | 2048 |
2053 void RenderView::SendPendingAccessibilityNotifications() { | 2049 void RenderView::SendPendingAccessibilityNotifications() { |
(...skipping 18 matching lines...) Expand all Loading... |
2072 notifications.push_back(param); | 2068 notifications.push_back(param); |
2073 } | 2069 } |
2074 pending_accessibility_notifications_.clear(); | 2070 pending_accessibility_notifications_.clear(); |
2075 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications)); | 2071 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications)); |
2076 accessibility_ack_pending_ = true; | 2072 accessibility_ack_pending_ = true; |
2077 } | 2073 } |
2078 | 2074 |
2079 void RenderView::textFieldDidReceiveKeyDown( | 2075 void RenderView::textFieldDidReceiveKeyDown( |
2080 const WebKit::WebInputElement& element, | 2076 const WebKit::WebInputElement& element, |
2081 const WebKit::WebKeyboardEvent& event) { | 2077 const WebKit::WebKeyboardEvent& event) { |
2082 #if defined(WEBKIT_BUG_41283_IS_FIXED) | |
2083 password_autocomplete_manager_->TextFieldHandlingKeyDown(element, event); | 2078 password_autocomplete_manager_->TextFieldHandlingKeyDown(element, event); |
2084 #endif | |
2085 } | 2079 } |
2086 | 2080 |
2087 bool RenderView::handleCurrentKeyboardEvent() { | 2081 bool RenderView::handleCurrentKeyboardEvent() { |
2088 if (edit_commands_.empty()) | 2082 if (edit_commands_.empty()) |
2089 return false; | 2083 return false; |
2090 | 2084 |
2091 WebFrame* frame = webview()->focusedFrame(); | 2085 WebFrame* frame = webview()->focusedFrame(); |
2092 if (!frame) | 2086 if (!frame) |
2093 return false; | 2087 return false; |
2094 | 2088 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2368 return history_list_length_ - historyBackListCount() - 1; | 2362 return history_list_length_ - historyBackListCount() - 1; |
2369 } | 2363 } |
2370 | 2364 |
2371 void RenderView::didUpdateInspectorSetting(const WebString& key, | 2365 void RenderView::didUpdateInspectorSetting(const WebString& key, |
2372 const WebString& value) { | 2366 const WebString& value) { |
2373 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, | 2367 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, |
2374 key.utf8(), | 2368 key.utf8(), |
2375 value.utf8())); | 2369 value.utf8())); |
2376 } | 2370 } |
2377 | 2371 |
2378 void RenderView::queryAutofillSuggestions(const WebNode& node, | |
2379 const WebString& name, | |
2380 const WebString& value) { | |
2381 autofill_helper_->QueryAutoFillSuggestions(node); | |
2382 } | |
2383 | |
2384 void RenderView::removeAutofillSuggestions(const WebString& name, | 2372 void RenderView::removeAutofillSuggestions(const WebString& name, |
2385 const WebString& value) { | 2373 const WebString& value) { |
2386 autofill_helper_->RemoveAutocompleteSuggestion(name, value); | 2374 autofill_helper_->RemoveAutocompleteSuggestion(name, value); |
2387 } | 2375 } |
2388 | 2376 |
2389 void RenderView::didAcceptAutoFillSuggestion(const WebKit::WebNode& node, | 2377 void RenderView::didAcceptAutoFillSuggestion(const WebKit::WebNode& node, |
2390 const WebKit::WebString& value, | 2378 const WebKit::WebString& value, |
2391 const WebKit::WebString& label, | 2379 const WebKit::WebString& label, |
2392 int unique_id, | 2380 int unique_id, |
2393 unsigned index) { | 2381 unsigned index) { |
2394 autofill_helper_->DidAcceptAutoFillSuggestion(node, value, unique_id, index); | 2382 autofill_helper_->DidAcceptAutoFillSuggestion(node, value, unique_id, index); |
2395 } | 2383 } |
2396 | 2384 |
2397 void RenderView::didSelectAutoFillSuggestion(const WebKit::WebNode& node, | 2385 void RenderView::didSelectAutoFillSuggestion(const WebKit::WebNode& node, |
2398 const WebKit::WebString& value, | 2386 const WebKit::WebString& value, |
2399 const WebKit::WebString& label, | 2387 const WebKit::WebString& label, |
2400 int unique_id) { | 2388 int unique_id) { |
2401 autofill_helper_->DidSelectAutoFillSuggestion(node, unique_id); | 2389 autofill_helper_->DidSelectAutoFillSuggestion(node, unique_id); |
2402 } | 2390 } |
2403 | 2391 |
2404 void RenderView::didClearAutoFillSelection(const WebKit::WebNode& node) { | 2392 void RenderView::didClearAutoFillSelection(const WebKit::WebNode& node) { |
2405 autofill_helper_->DidClearAutoFillSelection(node); | 2393 autofill_helper_->DidClearAutoFillSelection(node); |
2406 } | 2394 } |
2407 | 2395 |
2408 void RenderView::didAcceptAutocompleteSuggestion( | 2396 void RenderView::didAcceptAutocompleteSuggestion( |
2409 const WebKit::WebInputElement& user_element) { | 2397 const WebKit::WebInputElement& user_element) { |
2410 #if defined(WEBKIT_BUG_41283_IS_FIXED) | |
2411 bool result = password_autocomplete_manager_->FillPassword(user_element); | 2398 bool result = password_autocomplete_manager_->FillPassword(user_element); |
2412 // Since this user name was selected from a suggestion list, we should always | 2399 // Since this user name was selected from a suggestion list, we should always |
2413 // have password for it. | 2400 // have password for it. |
2414 DCHECK(result); | 2401 DCHECK(result); |
2415 #endif | |
2416 } | 2402 } |
2417 | 2403 |
2418 // WebKit::WebWidgetClient ---------------------------------------------------- | 2404 // WebKit::WebWidgetClient ---------------------------------------------------- |
2419 | 2405 |
2420 void RenderView::didFocus() { | 2406 void RenderView::didFocus() { |
2421 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed | 2407 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
2422 // we won't have to test for user gesture anymore and we can | 2408 // we won't have to test for user gesture anymore and we can |
2423 // move that code back to render_widget.cc | 2409 // move that code back to render_widget.cc |
2424 if (webview() && webview()->mainFrame() && | 2410 if (webview() && webview()->mainFrame() && |
2425 webview()->mainFrame()->isProcessingUserGesture()) { | 2411 webview()->mainFrame()->isProcessingUserGesture()) { |
(...skipping 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4446 webview()->dragSourceMovedTo(client_point, screen_point, op); | 4432 webview()->dragSourceMovedTo(client_point, screen_point, op); |
4447 } | 4433 } |
4448 } | 4434 } |
4449 | 4435 |
4450 void RenderView::OnDragSourceSystemDragEnded() { | 4436 void RenderView::OnDragSourceSystemDragEnded() { |
4451 webview()->dragSourceSystemDragEnded(); | 4437 webview()->dragSourceSystemDragEnded(); |
4452 } | 4438 } |
4453 | 4439 |
4454 void RenderView::OnFillPasswordForm( | 4440 void RenderView::OnFillPasswordForm( |
4455 const webkit_glue::PasswordFormFillData& form_data) { | 4441 const webkit_glue::PasswordFormFillData& form_data) { |
4456 #if defined(WEBKIT_BUG_41283_IS_FIXED) | |
4457 password_autocomplete_manager_->ReceivedPasswordFormFillData(webview(), | 4442 password_autocomplete_manager_->ReceivedPasswordFormFillData(webview(), |
4458 form_data); | 4443 form_data); |
4459 #else | |
4460 webkit_glue::FillPasswordForm(this->webview(), form_data); | |
4461 #endif | |
4462 } | 4444 } |
4463 | 4445 |
4464 void RenderView::OnDragTargetDragEnter(const WebDropData& drop_data, | 4446 void RenderView::OnDragTargetDragEnter(const WebDropData& drop_data, |
4465 const gfx::Point& client_point, | 4447 const gfx::Point& client_point, |
4466 const gfx::Point& screen_point, | 4448 const gfx::Point& screen_point, |
4467 WebDragOperationsMask ops) { | 4449 WebDragOperationsMask ops) { |
4468 WebDragOperation operation = webview()->dragTargetDragEnter( | 4450 WebDragOperation operation = webview()->dragTargetDragEnter( |
4469 drop_data.ToDragData(), | 4451 drop_data.ToDragData(), |
4470 drop_data.identity, | 4452 drop_data.identity, |
4471 client_point, | 4453 client_point, |
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6129 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), | 6111 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), |
6130 message_id); | 6112 message_id); |
6131 } | 6113 } |
6132 | 6114 |
6133 #if defined(OS_MACOSX) | 6115 #if defined(OS_MACOSX) |
6134 void RenderView::OnSelectPopupMenuItem(int selected_index) { | 6116 void RenderView::OnSelectPopupMenuItem(int selected_index) { |
6135 external_popup_menu_->DidSelectItem(selected_index); | 6117 external_popup_menu_->DidSelectItem(selected_index); |
6136 external_popup_menu_.reset(); | 6118 external_popup_menu_.reset(); |
6137 } | 6119 } |
6138 #endif | 6120 #endif |
OLD | NEW |