| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "base/sys_string_conversions.h" | 24 #include "base/sys_string_conversions.h" |
| 25 #include "base/utf_string_conversions.h" | 25 #include "base/utf_string_conversions.h" |
| 26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 27 #include "chrome/common/appcache/appcache_dispatcher.h" | 27 #include "chrome/common/appcache/appcache_dispatcher.h" |
| 28 #include "chrome/common/bindings_policy.h" | 28 #include "chrome/common/bindings_policy.h" |
| 29 #include "chrome/common/child_process_logging.h" | 29 #include "chrome/common/child_process_logging.h" |
| 30 #include "chrome/common/chrome_constants.h" | 30 #include "chrome/common/chrome_constants.h" |
| 31 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
| 32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/extensions/extension.h" | 33 #include "chrome/common/extensions/extension.h" |
| 34 #include "chrome/common/file_system/file_system_dispatcher.h" |
| 35 #include "chrome/common/file_system/webfilesystem_callback_dispatcher.h" |
| 34 #include "chrome/common/jstemplate_builder.h" | 36 #include "chrome/common/jstemplate_builder.h" |
| 35 #include "chrome/common/notification_service.h" | 37 #include "chrome/common/notification_service.h" |
| 36 #include "chrome/common/page_zoom.h" | 38 #include "chrome/common/page_zoom.h" |
| 37 #include "chrome/common/pepper_plugin_registry.h" | 39 #include "chrome/common/pepper_plugin_registry.h" |
| 38 #include "chrome/common/plugin_group.h" | 40 #include "chrome/common/plugin_group.h" |
| 39 #include "chrome/common/render_messages.h" | 41 #include "chrome/common/render_messages.h" |
| 40 #include "chrome/common/render_messages_params.h" | 42 #include "chrome/common/render_messages_params.h" |
| 41 #include "chrome/common/renderer_preferences.h" | 43 #include "chrome/common/renderer_preferences.h" |
| 42 #include "chrome/common/thumbnail_score.h" | 44 #include "chrome/common/thumbnail_score.h" |
| 43 #include "chrome/common/url_constants.h" | 45 #include "chrome/common/url_constants.h" |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 // the languages CLD can detect. As a result, it'll return the invalid | 403 // the languages CLD can detect. As a result, it'll return the invalid |
| 402 // language code for tradtional Chinese among others. | 404 // language code for tradtional Chinese among others. |
| 403 // |LanguageCodeWithDialect| will go through ISO 639-1, ISO-639-2 and | 405 // |LanguageCodeWithDialect| will go through ISO 639-1, ISO-639-2 and |
| 404 // 'other' tables to do the 'right' thing. In addition, it'll return zh-CN | 406 // 'other' tables to do the 'right' thing. In addition, it'll return zh-CN |
| 405 // for Simplified Chinese. | 407 // for Simplified Chinese. |
| 406 language = LanguageCodeWithDialects(cld_language); | 408 language = LanguageCodeWithDialects(cld_language); |
| 407 } | 409 } |
| 408 return language; | 410 return language; |
| 409 } | 411 } |
| 410 | 412 |
| 411 // Holds pending openFileSystem callbacks. | |
| 412 struct RenderView::PendingOpenFileSystem { | |
| 413 explicit PendingOpenFileSystem(WebFileSystemCallbacks* c) : callbacks(c) { | |
| 414 } | |
| 415 ~PendingOpenFileSystem() { | |
| 416 if (callbacks) | |
| 417 callbacks->didFail(WebKit::WebFileErrorAbort); | |
| 418 } | |
| 419 WebFileSystemCallbacks* callbacks; | |
| 420 }; | |
| 421 | |
| 422 /////////////////////////////////////////////////////////////////////////////// | 413 /////////////////////////////////////////////////////////////////////////////// |
| 423 | 414 |
| 424 int32 RenderView::next_page_id_ = 1; | 415 int32 RenderView::next_page_id_ = 1; |
| 425 | 416 |
| 426 struct RenderView::PendingFileChooser { | 417 struct RenderView::PendingFileChooser { |
| 427 PendingFileChooser(const ViewHostMsg_RunFileChooser_Params& p, | 418 PendingFileChooser(const ViewHostMsg_RunFileChooser_Params& p, |
| 428 WebFileChooserCompletion* c) | 419 WebFileChooserCompletion* c) |
| 429 : params(p), | 420 : params(p), |
| 430 completion(c) { | 421 completion(c) { |
| 431 } | 422 } |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, | 794 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, |
| 804 OnCustomContextMenuAction) | 795 OnCustomContextMenuAction) |
| 805 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) | 796 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) |
| 806 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) | 797 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) |
| 807 IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityTree, OnGetAccessibilityTree) | 798 IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityTree, OnGetAccessibilityTree) |
| 808 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus) | 799 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus) |
| 809 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction, | 800 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction, |
| 810 OnAccessibilityDoDefaultAction) | 801 OnAccessibilityDoDefaultAction) |
| 811 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityNotifications_ACK, | 802 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityNotifications_ACK, |
| 812 OnAccessibilityNotificationsAck) | 803 OnAccessibilityNotificationsAck) |
| 813 IPC_MESSAGE_HANDLER(ViewMsg_OpenFileSystemRequest_Complete, | |
| 814 OnOpenFileSystemRequestComplete) | |
| 815 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) | 804 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) |
| 816 | 805 |
| 817 // Have the super handle all other messages. | 806 // Have the super handle all other messages. |
| 818 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) | 807 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) |
| 819 IPC_END_MESSAGE_MAP() | 808 IPC_END_MESSAGE_MAP() |
| 820 } | 809 } |
| 821 | 810 |
| 822 void RenderView::OnCaptureThumbnail() { | 811 void RenderView::OnCaptureThumbnail() { |
| 823 WebFrame* main_frame = webview()->mainFrame(); | 812 WebFrame* main_frame = webview()->mainFrame(); |
| 824 if (!main_frame) | 813 if (!main_frame) |
| (...skipping 2674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3499 selection_rect, | 3488 selection_rect, |
| 3500 active_match_ordinal, | 3489 active_match_ordinal, |
| 3501 false)); | 3490 false)); |
| 3502 } | 3491 } |
| 3503 | 3492 |
| 3504 void RenderView::openFileSystem( | 3493 void RenderView::openFileSystem( |
| 3505 WebFrame* frame, | 3494 WebFrame* frame, |
| 3506 WebFileSystem::Type type, | 3495 WebFileSystem::Type type, |
| 3507 long long size, | 3496 long long size, |
| 3508 WebFileSystemCallbacks* callbacks) { | 3497 WebFileSystemCallbacks* callbacks) { |
| 3509 scoped_ptr<PendingOpenFileSystem> request( | 3498 DCHECK(callbacks); |
| 3510 new PendingOpenFileSystem(callbacks)); | |
| 3511 | 3499 |
| 3512 WebSecurityOrigin origin = frame->securityOrigin(); | 3500 WebSecurityOrigin origin = frame->securityOrigin(); |
| 3513 if (origin.isEmpty()) | 3501 if (origin.isEmpty()) { |
| 3514 return; // Uninitialized document? | 3502 // Uninitialized document? |
| 3503 callbacks->didFail(WebKit::WebFileErrorAbort); |
| 3504 return; |
| 3505 } |
| 3515 | 3506 |
| 3516 ViewHostMsg_OpenFileSystemRequest_Params params; | 3507 ChildThread::current()->file_system_dispatcher()->OpenFileSystem( |
| 3517 params.routing_id = routing_id_; | 3508 GURL(origin.toString()), static_cast<fileapi::FileSystemType>(type), |
| 3518 params.request_id = pending_file_system_requests_.Add(request.release()); | 3509 size, new WebFileSystemCallbackDispatcher(callbacks)); |
| 3519 params.origin_url = GURL(origin.toString()); | |
| 3520 params.type = type; | |
| 3521 params.requested_size = size; | |
| 3522 | |
| 3523 Send(new ViewHostMsg_OpenFileSystemRequest(params)); | |
| 3524 } | 3510 } |
| 3525 | 3511 |
| 3526 // webkit_glue::WebPluginPageDelegate ----------------------------------------- | 3512 // webkit_glue::WebPluginPageDelegate ----------------------------------------- |
| 3527 | 3513 |
| 3528 webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( | 3514 webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( |
| 3529 const FilePath& file_path, | 3515 const FilePath& file_path, |
| 3530 const std::string& mime_type) { | 3516 const std::string& mime_type) { |
| 3531 if (!PluginChannelHost::IsListening()) | 3517 if (!PluginChannelHost::IsListening()) |
| 3532 return NULL; | 3518 return NULL; |
| 3533 | 3519 |
| (...skipping 2272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5806 return true; | 5792 return true; |
| 5807 } | 5793 } |
| 5808 } | 5794 } |
| 5809 | 5795 |
| 5810 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) | 5796 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) |
| 5811 return true; | 5797 return true; |
| 5812 } | 5798 } |
| 5813 return false; | 5799 return false; |
| 5814 } | 5800 } |
| 5815 | 5801 |
| 5816 void RenderView::OnOpenFileSystemRequestComplete( | |
| 5817 int request_id, bool accepted, const string16& name, | |
| 5818 const string16& root_path) { | |
| 5819 PendingOpenFileSystem* request = pending_file_system_requests_.Lookup( | |
| 5820 request_id); | |
| 5821 DCHECK(request); | |
| 5822 if (accepted) | |
| 5823 request->callbacks->didOpenFileSystem(name, root_path); | |
| 5824 else | |
| 5825 request->callbacks->didFail(WebKit::WebFileErrorSecurity); | |
| 5826 request->callbacks = NULL; | |
| 5827 pending_file_system_requests_.Remove(request_id); | |
| 5828 } | |
| 5829 | |
| 5830 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code, | 5802 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code, |
| 5831 IPC::PlatformFileForTransit file_for_transit, | 5803 IPC::PlatformFileForTransit file_for_transit, |
| 5832 int message_id) { | 5804 int message_id) { |
| 5833 pepper_delegate_.OnAsyncFileOpened( | 5805 pepper_delegate_.OnAsyncFileOpened( |
| 5834 error_code, | 5806 error_code, |
| 5835 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), | 5807 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), |
| 5836 message_id); | 5808 message_id); |
| 5837 } | 5809 } |
| OLD | NEW |