| 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 "content/renderer/render_view.h" | 5 #include "content/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 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/devtools_messages.h" | 30 #include "chrome/common/devtools_messages.h" |
| 31 #include "chrome/common/extensions/extension.h" | 31 #include "chrome/common/extensions/extension.h" |
| 32 #include "chrome/common/extensions/extension_constants.h" | 32 #include "chrome/common/extensions/extension_constants.h" |
| 33 #include "chrome/common/extensions/extension_messages.h" | 33 #include "chrome/common/extensions/extension_messages.h" |
| 34 #include "chrome/common/extensions/extension_set.h" | 34 #include "chrome/common/extensions/extension_set.h" |
| 35 #include "chrome/common/json_value_serializer.h" | 35 #include "chrome/common/json_value_serializer.h" |
| 36 #include "chrome/common/pepper_plugin_registry.h" | 36 #include "chrome/common/pepper_plugin_registry.h" |
| 37 #include "chrome/common/render_messages.h" | 37 #include "chrome/common/render_messages.h" |
| 38 #include "chrome/common/render_view_commands.h" | 38 #include "chrome/common/render_view_commands.h" |
| 39 #include "chrome/common/spellcheck_messages.h" | |
| 40 #include "chrome/common/thumbnail_score.h" | 39 #include "chrome/common/thumbnail_score.h" |
| 41 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
| 42 #include "chrome/common/web_apps.h" | 41 #include "chrome/common/web_apps.h" |
| 43 #include "chrome/renderer/about_handler.h" | 42 #include "chrome/renderer/about_handler.h" |
| 44 #include "chrome/renderer/autofill/autofill_agent.h" | 43 #include "chrome/renderer/autofill/autofill_agent.h" |
| 45 #include "chrome/renderer/autofill/form_manager.h" | 44 #include "chrome/renderer/autofill/form_manager.h" |
| 46 #include "chrome/renderer/autofill/password_autofill_manager.h" | 45 #include "chrome/renderer/autofill/password_autofill_manager.h" |
| 47 #include "chrome/renderer/automation/dom_automation_controller.h" | 46 #include "chrome/renderer/automation/dom_automation_controller.h" |
| 48 #include "chrome/renderer/devtools_agent.h" | 47 #include "chrome/renderer/devtools_agent.h" |
| 49 #include "chrome/renderer/devtools_client.h" | 48 #include "chrome/renderer/devtools_client.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" | 144 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" |
| 146 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" | 145 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" |
| 147 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" | 146 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
| 148 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | 147 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
| 149 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData
.h" | 148 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData
.h" |
| 150 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 149 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
| 151 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" | 150 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
| 152 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" | 151 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
| 153 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" | 152 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" |
| 154 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 153 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 155 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextCheckingComple
tion.h" | |
| 156 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 154 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
| 157 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" | 155 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" |
| 158 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 156 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
| 159 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" | 157 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" |
| 160 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" | 158 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" |
| 161 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 159 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 162 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" | 160 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" |
| 163 #include "third_party/skia/include/core/SkBitmap.h" | 161 #include "third_party/skia/include/core/SkBitmap.h" |
| 164 #include "ui/base/message_box_flags.h" | 162 #include "ui/base/message_box_flags.h" |
| 165 #include "ui/gfx/color_utils.h" | 163 #include "ui/gfx/color_utils.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 navigation_gesture_(NavigationGestureUnknown), | 531 navigation_gesture_(NavigationGestureUnknown), |
| 534 opened_by_user_gesture_(true), | 532 opened_by_user_gesture_(true), |
| 535 opener_suppressed_(false), | 533 opener_suppressed_(false), |
| 536 is_prerendering_(false), | 534 is_prerendering_(false), |
| 537 page_id_(-1), | 535 page_id_(-1), |
| 538 last_page_id_sent_to_browser_(-1), | 536 last_page_id_sent_to_browser_(-1), |
| 539 last_indexed_page_id_(-1), | 537 last_indexed_page_id_(-1), |
| 540 history_list_offset_(-1), | 538 history_list_offset_(-1), |
| 541 history_list_length_(0), | 539 history_list_length_(0), |
| 542 has_unload_listener_(false), | 540 has_unload_listener_(false), |
| 543 #if defined(OS_MACOSX) | |
| 544 has_document_tag_(false), | |
| 545 #endif | |
| 546 document_tag_(0), | |
| 547 target_url_status_(TARGET_NONE), | 541 target_url_status_(TARGET_NONE), |
| 548 spelling_panel_visible_(false), | |
| 549 view_type_(ViewType::INVALID), | 542 view_type_(ViewType::INVALID), |
| 550 browser_window_id_(-1), | 543 browser_window_id_(-1), |
| 551 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), | 544 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), |
| 552 ALLOW_THIS_IN_INITIALIZER_LIST(page_info_method_factory_(this)), | 545 ALLOW_THIS_IN_INITIALIZER_LIST(page_info_method_factory_(this)), |
| 553 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), | 546 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), |
| 554 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 547 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
| 555 devtools_client_(NULL), | 548 devtools_client_(NULL), |
| 556 geolocation_dispatcher_(NULL), | 549 geolocation_dispatcher_(NULL), |
| 557 speech_input_dispatcher_(NULL), | 550 speech_input_dispatcher_(NULL), |
| 558 device_orientation_dispatcher_(NULL), | 551 device_orientation_dispatcher_(NULL), |
| 559 print_helper_(NULL), | 552 print_helper_(NULL), |
| 560 searchbox_(NULL), | 553 searchbox_(NULL), |
| 561 spellcheck_provider_(NULL), | 554 spellcheck_provider_(NULL), |
| 562 accessibility_ack_pending_(false), | 555 accessibility_ack_pending_(false), |
| 563 p2p_socket_dispatcher_(NULL), | 556 p2p_socket_dispatcher_(NULL), |
| 564 pending_app_icon_requests_(0), | 557 pending_app_icon_requests_(0), |
| 565 session_storage_namespace_id_(session_storage_namespace_id) { | 558 session_storage_namespace_id_(session_storage_namespace_id) { |
| 566 | 559 |
| 567 ClearBlockedContentSettings(); | 560 ClearBlockedContentSettings(); |
| 568 | 561 |
| 569 routing_id_ = routing_id; | 562 routing_id_ = routing_id; |
| 570 if (opener_id != MSG_ROUTING_NONE) | 563 if (opener_id != MSG_ROUTING_NONE) |
| 571 opener_id_ = opener_id; | 564 opener_id_ = opener_id; |
| 572 | 565 |
| 566 webwidget_ = WebView::create(this); |
| 567 |
| 573 if (counter) { | 568 if (counter) { |
| 574 shared_popup_counter_ = counter; | 569 shared_popup_counter_ = counter; |
| 575 shared_popup_counter_->data++; | 570 shared_popup_counter_->data++; |
| 576 decrement_shared_popup_at_destruction_ = true; | 571 decrement_shared_popup_at_destruction_ = true; |
| 577 } else { | 572 } else { |
| 578 shared_popup_counter_ = new SharedRenderViewCounter(0); | 573 shared_popup_counter_ = new SharedRenderViewCounter(0); |
| 579 decrement_shared_popup_at_destruction_ = false; | 574 decrement_shared_popup_at_destruction_ = false; |
| 580 } | 575 } |
| 581 | 576 |
| 582 notification_provider_ = new NotificationProvider(this); | 577 notification_provider_ = new NotificationProvider(this); |
| 583 | 578 |
| 584 devtools_agent_ = new DevToolsAgent(this); | 579 devtools_agent_ = new DevToolsAgent(this); |
| 580 webview()->setDevToolsAgentClient(devtools_agent_); |
| 581 |
| 585 PasswordAutofillManager* password_autofill_manager = | 582 PasswordAutofillManager* password_autofill_manager = |
| 586 new PasswordAutofillManager(this); | 583 new PasswordAutofillManager(this); |
| 587 AutofillAgent* autofill_agent = new AutofillAgent(this, | 584 AutofillAgent* autofill_agent = new AutofillAgent(this, |
| 588 password_autofill_manager); | 585 password_autofill_manager); |
| 586 webview()->setAutoFillClient(autofill_agent); |
| 589 | 587 |
| 590 webwidget_ = WebView::create(this, devtools_agent_, autofill_agent); | |
| 591 g_view_map.Get().insert(std::make_pair(webview(), this)); | 588 g_view_map.Get().insert(std::make_pair(webview(), this)); |
| 592 webkit_preferences_.Apply(webview()); | 589 webkit_preferences_.Apply(webview()); |
| 593 webview()->initializeMainFrame(this); | 590 webview()->initializeMainFrame(this); |
| 594 if (!frame_name.empty()) | 591 if (!frame_name.empty()) |
| 595 webview()->mainFrame()->setName(frame_name); | 592 webview()->mainFrame()->setName(frame_name); |
| 596 webview()->settings()->setMinimumTimerInterval( | 593 webview()->settings()->setMinimumTimerInterval( |
| 597 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : | 594 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
| 598 webkit_glue::kForegroundTabTimerInterval); | 595 webkit_glue::kForegroundTabTimerInterval); |
| 599 | 596 |
| 600 OnSetRendererPrefs(renderer_prefs); | 597 OnSetRendererPrefs(renderer_prefs); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 628 // notification and can stop the propagation. | 625 // notification and can stop the propagation. |
| 629 page_click_tracker->AddListener(password_autofill_manager); | 626 page_click_tracker->AddListener(password_autofill_manager); |
| 630 page_click_tracker->AddListener(autofill_agent); | 627 page_click_tracker->AddListener(autofill_agent); |
| 631 new TranslateHelper(this); | 628 new TranslateHelper(this); |
| 632 print_helper_ = new PrintWebViewHelper(this); | 629 print_helper_ = new PrintWebViewHelper(this); |
| 633 searchbox_ = new SearchBox(this); | 630 searchbox_ = new SearchBox(this); |
| 634 | 631 |
| 635 RenderThread* current_thread = RenderThread::current(); | 632 RenderThread* current_thread = RenderThread::current(); |
| 636 SpellCheck* spellcheck = current_thread ? current_thread->spellchecker() : 0; | 633 SpellCheck* spellcheck = current_thread ? current_thread->spellchecker() : 0; |
| 637 spellcheck_provider_ = new SpellCheckProvider(this, spellcheck); | 634 spellcheck_provider_ = new SpellCheckProvider(this, spellcheck); |
| 635 webview()->setSpellCheckClient(spellcheck_provider_); |
| 638 | 636 |
| 639 if (CommandLine::ForCurrentProcess()->HasSwitch( | 637 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 640 switches::kEnableP2PApi)) { | 638 switches::kEnableP2PApi)) { |
| 641 p2p_socket_dispatcher_ = new P2PSocketDispatcher(this); | 639 p2p_socket_dispatcher_ = new P2PSocketDispatcher(this); |
| 642 } | 640 } |
| 643 | 641 |
| 644 if (CommandLine::ForCurrentProcess()->HasSwitch( | 642 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 645 switches::kEnableClientSidePhishingDetection)) { | 643 switches::kEnableClientSidePhishingDetection)) { |
| 646 new safe_browsing::PhishingClassifierDelegate(this, NULL); | 644 new safe_browsing::PhishingClassifierDelegate(this, NULL); |
| 647 } | 645 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 659 // If file chooser is still waiting for answer, dispatch empty answer. | 657 // If file chooser is still waiting for answer, dispatch empty answer. |
| 660 while (!file_chooser_completions_.empty()) { | 658 while (!file_chooser_completions_.empty()) { |
| 661 if (file_chooser_completions_.front()->completion) { | 659 if (file_chooser_completions_.front()->completion) { |
| 662 file_chooser_completions_.front()->completion->didChooseFile( | 660 file_chooser_completions_.front()->completion->didChooseFile( |
| 663 WebVector<WebString>()); | 661 WebVector<WebString>()); |
| 664 } | 662 } |
| 665 file_chooser_completions_.pop_front(); | 663 file_chooser_completions_.pop_front(); |
| 666 } | 664 } |
| 667 | 665 |
| 668 #if defined(OS_MACOSX) | 666 #if defined(OS_MACOSX) |
| 669 // Tell the spellchecker that the document is closed. | |
| 670 if (has_document_tag_) { | |
| 671 Send(new SpellCheckHostMsg_DocumentWithTagClosed( | |
| 672 routing_id_, document_tag_)); | |
| 673 } | |
| 674 | |
| 675 // Destroy all fake plugin window handles on the browser side. | 667 // Destroy all fake plugin window handles on the browser side. |
| 676 while (!fake_plugin_window_handles_.empty()) { | 668 while (!fake_plugin_window_handles_.empty()) { |
| 677 // Make sure no NULL plugin window handles were inserted into this list. | 669 // Make sure no NULL plugin window handles were inserted into this list. |
| 678 DCHECK(*fake_plugin_window_handles_.begin()); | 670 DCHECK(*fake_plugin_window_handles_.begin()); |
| 679 // DestroyFakePluginWindowHandle modifies fake_plugin_window_handles_. | 671 // DestroyFakePluginWindowHandle modifies fake_plugin_window_handles_. |
| 680 DestroyFakePluginWindowHandle(*fake_plugin_window_handles_.begin()); | 672 DestroyFakePluginWindowHandle(*fake_plugin_window_handles_.begin()); |
| 681 } | 673 } |
| 682 #endif | 674 #endif |
| 683 | 675 |
| 684 render_thread_->RemoveFilter(audio_message_filter_); | 676 render_thread_->RemoveFilter(audio_message_filter_); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) | 967 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) |
| 976 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) | 968 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) |
| 977 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) | 969 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) |
| 978 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) | 970 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) |
| 979 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) | 971 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) |
| 980 #if defined(OS_MACOSX) | 972 #if defined(OS_MACOSX) |
| 981 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) | 973 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) |
| 982 #endif | 974 #endif |
| 983 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) | 975 IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) |
| 984 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) | 976 IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) |
| 985 IPC_MESSAGE_HANDLER(SpellCheckMsg_ToggleSpellPanel, OnToggleSpellPanel) | |
| 986 IPC_MESSAGE_HANDLER(SpellCheckMsg_AdvanceToNextMisspelling, | |
| 987 OnAdvanceToNextMisspelling) | |
| 988 IPC_MESSAGE_HANDLER(SpellCheckMsg_ToggleSpellCheck, OnToggleSpellCheck) | |
| 989 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) | 977 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) |
| 990 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) | 978 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) |
| 991 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 979 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
| 992 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) | 980 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) |
| 993 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | 981 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
| 994 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | 982 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
| 995 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) | 983 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) |
| 996 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 984 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| 997 IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForLoadingURL, | 985 IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForLoadingURL, |
| 998 OnSetContentSettingsForLoadingURL) | 986 OnSetContentSettingsForLoadingURL) |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 void RenderView::OnReplace(const string16& text) { | 1514 void RenderView::OnReplace(const string16& text) { |
| 1527 if (!webview()) | 1515 if (!webview()) |
| 1528 return; | 1516 return; |
| 1529 | 1517 |
| 1530 WebFrame* frame = webview()->focusedFrame(); | 1518 WebFrame* frame = webview()->focusedFrame(); |
| 1531 if (!frame->hasSelection()) | 1519 if (!frame->hasSelection()) |
| 1532 frame->selectWordAroundCaret(); | 1520 frame->selectWordAroundCaret(); |
| 1533 frame->replaceSelection(text); | 1521 frame->replaceSelection(text); |
| 1534 } | 1522 } |
| 1535 | 1523 |
| 1536 void RenderView::OnAdvanceToNextMisspelling() { | |
| 1537 if (!webview()) | |
| 1538 return; | |
| 1539 webview()->focusedFrame()->executeCommand( | |
| 1540 WebString::fromUTF8("AdvanceToNextMisspelling")); | |
| 1541 } | |
| 1542 | |
| 1543 void RenderView::OnToggleSpellPanel(bool is_currently_visible) { | |
| 1544 if (!webview()) | |
| 1545 return; | |
| 1546 // We need to tell the webView whether the spelling panel is visible or not so | |
| 1547 // that it won't need to make ipc calls later. | |
| 1548 spelling_panel_visible_ = is_currently_visible; | |
| 1549 webview()->focusedFrame()->executeCommand( | |
| 1550 WebString::fromUTF8("ToggleSpellPanel")); | |
| 1551 } | |
| 1552 | |
| 1553 void RenderView::OnToggleSpellCheck() { | |
| 1554 if (!webview()) | |
| 1555 return; | |
| 1556 | |
| 1557 WebFrame* frame = webview()->focusedFrame(); | |
| 1558 frame->enableContinuousSpellChecking( | |
| 1559 !frame->isContinuousSpellCheckingEnabled()); | |
| 1560 } | |
| 1561 | |
| 1562 void RenderView::OnDelete() { | 1524 void RenderView::OnDelete() { |
| 1563 if (!webview()) | 1525 if (!webview()) |
| 1564 return; | 1526 return; |
| 1565 | 1527 |
| 1566 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete")); | 1528 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete")); |
| 1567 UserMetricsRecordAction("DeleteSelection"); | 1529 UserMetricsRecordAction("DeleteSelection"); |
| 1568 } | 1530 } |
| 1569 | 1531 |
| 1570 void RenderView::OnSelectAll() { | 1532 void RenderView::OnSelectAll() { |
| 1571 if (!webview()) | 1533 if (!webview()) |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2231 // seems safest to not execute the rest. | 2193 // seems safest to not execute the rest. |
| 2232 if (!frame->executeCommand(WebString::fromUTF8(it->name), | 2194 if (!frame->executeCommand(WebString::fromUTF8(it->name), |
| 2233 WebString::fromUTF8(it->value))) | 2195 WebString::fromUTF8(it->value))) |
| 2234 break; | 2196 break; |
| 2235 did_execute_command = true; | 2197 did_execute_command = true; |
| 2236 } | 2198 } |
| 2237 | 2199 |
| 2238 return did_execute_command; | 2200 return did_execute_command; |
| 2239 } | 2201 } |
| 2240 | 2202 |
| 2241 void RenderView::spellCheck(const WebString& text, | |
| 2242 int& misspelled_offset, | |
| 2243 int& misspelled_length) { | |
| 2244 EnsureDocumentTag(); | |
| 2245 | |
| 2246 string16 word(text); | |
| 2247 RenderThread* thread = RenderThread::current(); | |
| 2248 // Will be NULL during unit tests. | |
| 2249 if (thread) { | |
| 2250 thread->spellchecker()->SpellCheckWord( | |
| 2251 word.c_str(), word.size(), document_tag_, | |
| 2252 &misspelled_offset, &misspelled_length, NULL); | |
| 2253 } | |
| 2254 } | |
| 2255 | |
| 2256 void RenderView::requestCheckingOfText( | |
| 2257 const WebString& text, | |
| 2258 WebKit::WebTextCheckingCompletion* completion) { | |
| 2259 spellcheck_provider_->RequestTextChecking(text, document_tag_, completion); | |
| 2260 } | |
| 2261 | |
| 2262 WebString RenderView::autoCorrectWord(const WebKit::WebString& word) { | |
| 2263 string16 autocorrect_word; | |
| 2264 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 2265 if (command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures)) { | |
| 2266 EnsureDocumentTag(); | |
| 2267 RenderThread* thread = RenderThread::current(); | |
| 2268 // Will be NULL during unit tests. | |
| 2269 if (thread) { | |
| 2270 autocorrect_word = | |
| 2271 thread->spellchecker()->GetAutoCorrectionWord( | |
| 2272 word, document_tag_); | |
| 2273 } | |
| 2274 } | |
| 2275 return autocorrect_word; | |
| 2276 } | |
| 2277 | |
| 2278 void RenderView::showSpellingUI(bool show) { | |
| 2279 Send(new SpellCheckHostMsg_ShowSpellingPanel(routing_id_, show)); | |
| 2280 } | |
| 2281 | |
| 2282 bool RenderView::isShowingSpellingUI() { | |
| 2283 return spelling_panel_visible_; | |
| 2284 } | |
| 2285 | |
| 2286 void RenderView::updateSpellingUIWithMisspelledWord(const WebString& word) { | |
| 2287 Send(new SpellCheckHostMsg_UpdateSpellingPanelWithMisspelledWord(routing_id_, | |
| 2288 word)); | |
| 2289 } | |
| 2290 | |
| 2291 void RenderView::continuousSpellCheckingEnabledStateChanged() { | |
| 2292 UpdateToggleSpellCheckCommandState(); | |
| 2293 } | |
| 2294 | |
| 2295 bool RenderView::runFileChooser( | 2203 bool RenderView::runFileChooser( |
| 2296 const WebKit::WebFileChooserParams& params, | 2204 const WebKit::WebFileChooserParams& params, |
| 2297 WebFileChooserCompletion* chooser_completion) { | 2205 WebFileChooserCompletion* chooser_completion) { |
| 2298 // Do not open the file dialog in a hidden RenderView. | 2206 // Do not open the file dialog in a hidden RenderView. |
| 2299 if (is_hidden()) | 2207 if (is_hidden()) |
| 2300 return false; | 2208 return false; |
| 2301 ViewHostMsg_RunFileChooser_Params ipc_params; | 2209 ViewHostMsg_RunFileChooser_Params ipc_params; |
| 2302 if (params.directory) | 2210 if (params.directory) |
| 2303 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::OpenFolder; | 2211 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::OpenFolder; |
| 2304 else if (params.multiSelect) | 2212 else if (params.multiSelect) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2358 } | 2266 } |
| 2359 | 2267 |
| 2360 void RenderView::showContextMenu( | 2268 void RenderView::showContextMenu( |
| 2361 WebFrame* frame, const WebContextMenuData& data) { | 2269 WebFrame* frame, const WebContextMenuData& data) { |
| 2362 ContextMenuParams params = ContextMenuParams(data); | 2270 ContextMenuParams params = ContextMenuParams(data); |
| 2363 if (!params.misspelled_word.empty() && RenderThread::current()) { | 2271 if (!params.misspelled_word.empty() && RenderThread::current()) { |
| 2364 int misspelled_offset, misspelled_length; | 2272 int misspelled_offset, misspelled_length; |
| 2365 bool spelled_right = RenderThread::current()->spellchecker()-> | 2273 bool spelled_right = RenderThread::current()->spellchecker()-> |
| 2366 SpellCheckWord( | 2274 SpellCheckWord( |
| 2367 params.misspelled_word.c_str(), params.misspelled_word.size(), | 2275 params.misspelled_word.c_str(), params.misspelled_word.size(), |
| 2368 document_tag_, | 2276 spellcheck_provider_->document_tag(), |
| 2369 &misspelled_offset, &misspelled_length, | 2277 &misspelled_offset, &misspelled_length, |
| 2370 ¶ms.dictionary_suggestions); | 2278 ¶ms.dictionary_suggestions); |
| 2371 if (spelled_right) | 2279 if (spelled_right) |
| 2372 params.misspelled_word.clear(); | 2280 params.misspelled_word.clear(); |
| 2373 } | 2281 } |
| 2374 // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do | 2282 // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do |
| 2375 // it. We replace it with an empty GURL so the appropriate items are disabled | 2283 // it. We replace it with an empty GURL so the appropriate items are disabled |
| 2376 // in the context menu. | 2284 // in the context menu. |
| 2377 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large | 2285 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large |
| 2378 // data encoded images. We should have a way to save them. | 2286 // data encoded images. We should have a way to save them. |
| (...skipping 2701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5080 (*plugin_it)->SetWindowFocus(true); | 4988 (*plugin_it)->SetWindowFocus(true); |
| 5081 #endif | 4989 #endif |
| 5082 (*plugin_it)->SetContentAreaFocus(enable); | 4990 (*plugin_it)->SetContentAreaFocus(enable); |
| 5083 } | 4991 } |
| 5084 | 4992 |
| 5085 // Notify all Pepper plugins. | 4993 // Notify all Pepper plugins. |
| 5086 pepper_delegate_.OnSetFocus(enable); | 4994 pepper_delegate_.OnSetFocus(enable); |
| 5087 } | 4995 } |
| 5088 } | 4996 } |
| 5089 | 4997 |
| 5090 void RenderView::EnsureDocumentTag() { | |
| 5091 // TODO(darin): There's actually no reason for this to be here. We should | |
| 5092 // have the browser side manage the document tag. | |
| 5093 #if defined(OS_MACOSX) | |
| 5094 if (!has_document_tag_) { | |
| 5095 // Make the call to get the tag. | |
| 5096 Send(new SpellCheckHostMsg_GetDocumentTag(routing_id_, &document_tag_)); | |
| 5097 has_document_tag_ = true; | |
| 5098 } | |
| 5099 #endif | |
| 5100 } | |
| 5101 | |
| 5102 #if defined(OS_MACOSX) | 4998 #if defined(OS_MACOSX) |
| 5103 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { | 4999 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { |
| 5104 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), | 5000 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), |
| 5105 focused, plugin_id); | 5001 focused, plugin_id); |
| 5106 Send(msg); | 5002 Send(msg); |
| 5107 } | 5003 } |
| 5108 | 5004 |
| 5109 void RenderView::StartPluginIme() { | 5005 void RenderView::StartPluginIme() { |
| 5110 IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id()); | 5006 IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id()); |
| 5111 // This message can be sent during event-handling, and needs to be delivered | 5007 // This message can be sent during event-handling, and needs to be delivered |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5368 const webkit_glue::CustomContextMenuContext& custom_context) { | 5264 const webkit_glue::CustomContextMenuContext& custom_context) { |
| 5369 if (custom_context.is_pepper_menu) | 5265 if (custom_context.is_pepper_menu) |
| 5370 pepper_delegate_.OnContextMenuClosed(custom_context); | 5266 pepper_delegate_.OnContextMenuClosed(custom_context); |
| 5371 else | 5267 else |
| 5372 context_menu_node_.reset(); | 5268 context_menu_node_.reset(); |
| 5373 } | 5269 } |
| 5374 | 5270 |
| 5375 void RenderView::OnNetworkStateChanged(bool online) { | 5271 void RenderView::OnNetworkStateChanged(bool online) { |
| 5376 WebNetworkStateNotifier::setOnLine(online); | 5272 WebNetworkStateNotifier::setOnLine(online); |
| 5377 } | 5273 } |
| OLD | NEW |