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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, | 646 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
647 OnDragSourceSystemDragEnded) | 647 OnDragSourceSystemDragEnded) |
648 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) | 648 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
649 IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) | 649 IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) |
650 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) | 650 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
651 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoView, | 651 IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoView, |
652 OnScrollFocusedEditableNodeIntoView) | 652 OnScrollFocusedEditableNodeIntoView) |
653 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) | 653 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
654 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) | 654 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
655 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) | 655 IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
656 IPC_MESSAGE_HANDLER(ViewMsg_InstallMissingPlugin, OnInstallMissingPlugin) | |
657 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, | 656 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
658 OnEnumerateDirectoryResponse) | 657 OnEnumerateDirectoryResponse) |
659 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) | 658 IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
660 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) | 659 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) |
661 IPC_MESSAGE_HANDLER(ViewMsg_SwapOut, OnSwapOut) | 660 IPC_MESSAGE_HANDLER(ViewMsg_SwapOut, OnSwapOut) |
662 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) | 661 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
663 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) | 662 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
664 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, | 663 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, |
665 OnDisassociateFromPopupCount) | 664 OnDisassociateFromPopupCount) |
666 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) | 665 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog | 1320 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog |
1322 // it is particularly important that we do not call willEnterModalLoop as | 1321 // it is particularly important that we do not call willEnterModalLoop as |
1323 // that would defer resource loads for the dialog itself. | 1322 // that would defer resource loads for the dialog itself. |
1324 if (RenderThread::current()) // Will be NULL during unit tests. | 1323 if (RenderThread::current()) // Will be NULL during unit tests. |
1325 RenderThread::current()->DoNotNotifyWebKitOfModalLoop(); | 1324 RenderThread::current()->DoNotNotifyWebKitOfModalLoop(); |
1326 | 1325 |
1327 message->EnableMessagePumping(); // Runs a nested message loop. | 1326 message->EnableMessagePumping(); // Runs a nested message loop. |
1328 return Send(message); | 1327 return Send(message); |
1329 } | 1328 } |
1330 | 1329 |
1331 void RenderView::OnMissingPluginStatus( | |
1332 WebPluginDelegateProxy* delegate, | |
1333 int status) { | |
1334 #if defined(OS_WIN) | |
1335 if (!first_default_plugin_) { | |
1336 // Show the InfoBar for the first available plugin. | |
1337 if (status == webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE) { | |
1338 first_default_plugin_ = delegate->AsWeakPtr(); | |
1339 Send(new ViewHostMsg_MissingPluginStatus(routing_id_, status)); | |
1340 } | |
1341 } else { | |
1342 // Closes the InfoBar if user clicks on the plugin (instead of the InfoBar) | |
1343 // to start the download/install. | |
1344 if (status == | |
1345 webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD) { | |
1346 Send(new ViewHostMsg_MissingPluginStatus(routing_id_, status)); | |
1347 } | |
1348 } | |
1349 #else | |
1350 // TODO(port): Implement the infobar that accompanies the default plugin. | |
1351 // Linux: http://crbug.com/10952 | |
1352 // Mac: http://crbug.com/17392 | |
1353 NOTIMPLEMENTED(); | |
1354 #endif | |
1355 } | |
1356 | |
1357 // WebKit::WebViewClient ------------------------------------------------------ | 1330 // WebKit::WebViewClient ------------------------------------------------------ |
1358 | 1331 |
1359 WebView* RenderView::createView( | 1332 WebView* RenderView::createView( |
1360 WebFrame* creator, | 1333 WebFrame* creator, |
1361 const WebURLRequest& request, | 1334 const WebURLRequest& request, |
1362 const WebWindowFeatures& features, | 1335 const WebWindowFeatures& features, |
1363 const WebString& frame_name) { | 1336 const WebString& frame_name) { |
1364 // Check to make sure we aren't overloading on popups. | 1337 // Check to make sure we aren't overloading on popups. |
1365 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) | 1338 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) |
1366 return NULL; | 1339 return NULL; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 webkit_glue::WebStringToFilePath(path))); | 1479 webkit_glue::WebStringToFilePath(path))); |
1507 } | 1480 } |
1508 | 1481 |
1509 void RenderView::didStartLoading() { | 1482 void RenderView::didStartLoading() { |
1510 if (is_loading_) { | 1483 if (is_loading_) { |
1511 DLOG(WARNING) << "didStartLoading called while loading"; | 1484 DLOG(WARNING) << "didStartLoading called while loading"; |
1512 return; | 1485 return; |
1513 } | 1486 } |
1514 | 1487 |
1515 is_loading_ = true; | 1488 is_loading_ = true; |
1516 // Clear the pointer so that we can assign it only when there is an unknown | |
1517 // plugin on a page. | |
1518 first_default_plugin_.reset(); | |
1519 | 1489 |
1520 Send(new ViewHostMsg_DidStartLoading(routing_id_)); | 1490 Send(new ViewHostMsg_DidStartLoading(routing_id_)); |
1521 | 1491 |
1522 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStartLoading()); | 1492 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStartLoading()); |
1523 } | 1493 } |
1524 | 1494 |
1525 void RenderView::didStopLoading() { | 1495 void RenderView::didStopLoading() { |
1526 if (!is_loading_) { | 1496 if (!is_loading_) { |
1527 DLOG(WARNING) << "DidStopLoading called while not loading"; | 1497 DLOG(WARNING) << "DidStopLoading called while not loading"; |
1528 return; | 1498 return; |
(...skipping 2091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3620 | 3590 |
3621 void RenderView::OnCustomContextMenuAction( | 3591 void RenderView::OnCustomContextMenuAction( |
3622 const webkit_glue::CustomContextMenuContext& custom_context, | 3592 const webkit_glue::CustomContextMenuContext& custom_context, |
3623 unsigned action) { | 3593 unsigned action) { |
3624 if (custom_context.is_pepper_menu) | 3594 if (custom_context.is_pepper_menu) |
3625 pepper_delegate_.OnCustomContextMenuAction(custom_context, action); | 3595 pepper_delegate_.OnCustomContextMenuAction(custom_context, action); |
3626 else | 3596 else |
3627 webview()->performCustomContextMenuAction(action); | 3597 webview()->performCustomContextMenuAction(action); |
3628 } | 3598 } |
3629 | 3599 |
3630 void RenderView::OnInstallMissingPlugin() { | |
3631 // This could happen when the first default plugin is deleted. | |
3632 if (first_default_plugin_) | |
3633 first_default_plugin_->InstallMissingPlugin(); | |
3634 } | |
3635 | |
3636 void RenderView::OnEnumerateDirectoryResponse( | 3600 void RenderView::OnEnumerateDirectoryResponse( |
3637 int id, | 3601 int id, |
3638 const std::vector<FilePath>& paths) { | 3602 const std::vector<FilePath>& paths) { |
3639 if (!enumeration_completions_[id]) | 3603 if (!enumeration_completions_[id]) |
3640 return; | 3604 return; |
3641 | 3605 |
3642 WebVector<WebString> ws_file_names(paths.size()); | 3606 WebVector<WebString> ws_file_names(paths.size()); |
3643 for (size_t i = 0; i < paths.size(); ++i) | 3607 for (size_t i = 0; i < paths.size(); ++i) |
3644 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); | 3608 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); |
3645 | 3609 |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4585 } | 4549 } |
4586 | 4550 |
4587 void RenderView::OnEnableViewSourceMode() { | 4551 void RenderView::OnEnableViewSourceMode() { |
4588 if (!webview()) | 4552 if (!webview()) |
4589 return; | 4553 return; |
4590 WebFrame* main_frame = webview()->mainFrame(); | 4554 WebFrame* main_frame = webview()->mainFrame(); |
4591 if (!main_frame) | 4555 if (!main_frame) |
4592 return; | 4556 return; |
4593 main_frame->enableViewSourceMode(true); | 4557 main_frame->enableViewSourceMode(true); |
4594 } | 4558 } |
OLD | NEW |