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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 #include "third_party/skia/include/core/SkBitmap.h" | 91 #include "third_party/skia/include/core/SkBitmap.h" |
92 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h" | 92 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h" |
93 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h" | 93 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h" |
94 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" | 94 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" |
95 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" | 95 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" |
96 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h" | 96 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h" |
97 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 97 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
98 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" | 98 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" |
99 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" | 99 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" |
100 #include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h" | 100 #include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h" |
| 101 #include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" |
| 102 #include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h" |
101 #include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h" | 103 #include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h" |
102 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" | 104 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" |
103 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 105 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
104 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" | 106 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" |
105 #include "third_party/WebKit/WebKit/chromium/public/WebImage.h" | 107 #include "third_party/WebKit/WebKit/chromium/public/WebImage.h" |
106 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" | 108 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" |
107 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" | 109 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" |
108 #include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h" | 110 #include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h" |
109 #include "third_party/WebKit/WebKit/chromium/public/WebPageSerializer.h" | 111 #include "third_party/WebKit/WebKit/chromium/public/WebPageSerializer.h" |
110 #include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h" | 112 #include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 using WebKit::WebCString; | 187 using WebKit::WebCString; |
186 using WebKit::WebData; | 188 using WebKit::WebData; |
187 using WebKit::WebDataSource; | 189 using WebKit::WebDataSource; |
188 using WebKit::WebDevToolsAgent; | 190 using WebKit::WebDevToolsAgent; |
189 using WebKit::WebDocument; | 191 using WebKit::WebDocument; |
190 using WebKit::WebDragData; | 192 using WebKit::WebDragData; |
191 using WebKit::WebDragOperation; | 193 using WebKit::WebDragOperation; |
192 using WebKit::WebDragOperationsMask; | 194 using WebKit::WebDragOperationsMask; |
193 using WebKit::WebEditingAction; | 195 using WebKit::WebEditingAction; |
194 using WebKit::WebFileChooserCompletion; | 196 using WebKit::WebFileChooserCompletion; |
| 197 using WebKit::WebFileSystem; |
| 198 using WebKit::WebFileSystemCallbacks; |
195 using WebKit::WebFindOptions; | 199 using WebKit::WebFindOptions; |
196 using WebKit::WebFormControlElement; | 200 using WebKit::WebFormControlElement; |
197 using WebKit::WebFormElement; | 201 using WebKit::WebFormElement; |
198 using WebKit::WebFrame; | 202 using WebKit::WebFrame; |
199 using WebKit::WebHistoryItem; | 203 using WebKit::WebHistoryItem; |
200 using WebKit::WebImage; | 204 using WebKit::WebImage; |
201 using WebKit::WebInputElement; | 205 using WebKit::WebInputElement; |
202 using WebKit::WebMediaPlayer; | 206 using WebKit::WebMediaPlayer; |
203 using WebKit::WebMediaPlayerAction; | 207 using WebKit::WebMediaPlayerAction; |
204 using WebKit::WebMediaPlayerClient; | 208 using WebKit::WebMediaPlayerClient; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 // 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 |
400 // language code for tradtional Chinese among others. | 404 // language code for tradtional Chinese among others. |
401 // |LanguageCodeWithDialect| will go through ISO 639-1, ISO-639-2 and | 405 // |LanguageCodeWithDialect| will go through ISO 639-1, ISO-639-2 and |
402 // '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 |
403 // for Simplified Chinese. | 407 // for Simplified Chinese. |
404 language = LanguageCodeWithDialects(cld_language); | 408 language = LanguageCodeWithDialects(cld_language); |
405 } | 409 } |
406 return language; | 410 return language; |
407 } | 411 } |
408 | 412 |
| 413 // Holds pending openFileSystem callbacks. |
| 414 struct RenderView::PendingOpenFileSystem { |
| 415 explicit PendingOpenFileSystem(WebFileSystemCallbacks* c) : callbacks(c) { |
| 416 } |
| 417 ~PendingOpenFileSystem() { |
| 418 if (callbacks) |
| 419 callbacks->didFail(WebKit::WebFileErrorAbort); |
| 420 } |
| 421 WebFileSystemCallbacks* callbacks; |
| 422 }; |
| 423 |
409 /////////////////////////////////////////////////////////////////////////////// | 424 /////////////////////////////////////////////////////////////////////////////// |
410 | 425 |
411 int32 RenderView::next_page_id_ = 1; | 426 int32 RenderView::next_page_id_ = 1; |
412 | 427 |
413 struct RenderView::PendingFileChooser { | 428 struct RenderView::PendingFileChooser { |
414 PendingFileChooser(const ViewHostMsg_RunFileChooser_Params& p, | 429 PendingFileChooser(const ViewHostMsg_RunFileChooser_Params& p, |
415 WebFileChooserCompletion* c) | 430 WebFileChooserCompletion* c) |
416 : params(p), | 431 : params(p), |
417 completion(c) { | 432 completion(c) { |
418 } | 433 } |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode, | 788 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode, |
774 OnExecuteCode) | 789 OnExecuteCode) |
775 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, | 790 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, |
776 OnCustomContextMenuAction) | 791 OnCustomContextMenuAction) |
777 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) | 792 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) |
778 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) | 793 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) |
779 IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityTree, OnGetAccessibilityTree) | 794 IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityTree, OnGetAccessibilityTree) |
780 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus) | 795 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus) |
781 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction, | 796 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction, |
782 OnAccessibilityDoDefaultAction) | 797 OnAccessibilityDoDefaultAction) |
| 798 IPC_MESSAGE_HANDLER(ViewMsg_OpenFileSystemRequest_Complete, |
| 799 OnOpenFileSystemRequestComplete) |
783 | 800 |
784 // Have the super handle all other messages. | 801 // Have the super handle all other messages. |
785 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) | 802 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) |
786 IPC_END_MESSAGE_MAP() | 803 IPC_END_MESSAGE_MAP() |
787 } | 804 } |
788 | 805 |
789 void RenderView::OnCaptureThumbnail() { | 806 void RenderView::OnCaptureThumbnail() { |
790 WebFrame* main_frame = webview()->mainFrame(); | 807 WebFrame* main_frame = webview()->mainFrame(); |
791 if (!main_frame) | 808 if (!main_frame) |
792 return; | 809 return; |
(...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3359 const WebRect& selection_rect) { | 3376 const WebRect& selection_rect) { |
3360 // Send the search result over to the browser process. | 3377 // Send the search result over to the browser process. |
3361 Send(new ViewHostMsg_Find_Reply(routing_id_, | 3378 Send(new ViewHostMsg_Find_Reply(routing_id_, |
3362 request_id, | 3379 request_id, |
3363 -1, | 3380 -1, |
3364 selection_rect, | 3381 selection_rect, |
3365 active_match_ordinal, | 3382 active_match_ordinal, |
3366 false)); | 3383 false)); |
3367 } | 3384 } |
3368 | 3385 |
| 3386 void RenderView::openFileSystem( |
| 3387 WebFrame* frame, |
| 3388 WebFileSystem::Type type, |
| 3389 long long size, |
| 3390 WebFileSystemCallbacks* callbacks) { |
| 3391 scoped_ptr<PendingOpenFileSystem> request( |
| 3392 new PendingOpenFileSystem(callbacks)); |
| 3393 |
| 3394 WebSecurityOrigin origin = frame->securityOrigin(); |
| 3395 if (origin.isEmpty()) |
| 3396 return; // Uninitialized document? |
| 3397 |
| 3398 ViewHostMsg_OpenFileSystemRequest_Params params; |
| 3399 params.routing_id = routing_id_; |
| 3400 params.request_id = pending_file_system_requests_.Add(request.release()); |
| 3401 params.origin_url = GURL(origin.toString()); |
| 3402 params.type = type; |
| 3403 params.requested_size = size; |
| 3404 |
| 3405 Send(new ViewHostMsg_OpenFileSystemRequest(params)); |
| 3406 } |
| 3407 |
3369 // webkit_glue::WebPluginPageDelegate ----------------------------------------- | 3408 // webkit_glue::WebPluginPageDelegate ----------------------------------------- |
3370 | 3409 |
3371 webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( | 3410 webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( |
3372 const FilePath& file_path, | 3411 const FilePath& file_path, |
3373 const std::string& mime_type) { | 3412 const std::string& mime_type) { |
3374 if (!PluginChannelHost::IsListening()) | 3413 if (!PluginChannelHost::IsListening()) |
3375 return NULL; | 3414 return NULL; |
3376 | 3415 |
3377 bool use_pepper_host = false; | 3416 bool use_pepper_host = false; |
3378 bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); | 3417 bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); |
(...skipping 2117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5496 // the origins of the two domains are different. This can be treated as a | 5535 // the origins of the two domains are different. This can be treated as a |
5497 // top level navigation and routed back to the host. | 5536 // top level navigation and routed back to the host. |
5498 WebKit::WebFrame* opener = frame->opener(); | 5537 WebKit::WebFrame* opener = frame->opener(); |
5499 if (opener) { | 5538 if (opener) { |
5500 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) | 5539 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) |
5501 return true; | 5540 return true; |
5502 } | 5541 } |
5503 } | 5542 } |
5504 return false; | 5543 return false; |
5505 } | 5544 } |
| 5545 |
| 5546 void RenderView::OnOpenFileSystemRequestComplete( |
| 5547 int request_id, bool accepted, const string16& name, |
| 5548 const string16& root_path) { |
| 5549 PendingOpenFileSystem* request = pending_file_system_requests_.Lookup( |
| 5550 request_id); |
| 5551 DCHECK(request); |
| 5552 if (accepted) |
| 5553 request->callbacks->didOpenFileSystem(name, root_path); |
| 5554 else |
| 5555 request->callbacks->didFail(WebKit::WebFileErrorSecurity); |
| 5556 request->callbacks = NULL; |
| 5557 pending_file_system_requests_.Remove(request_id); |
| 5558 } |
OLD | NEW |