| 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 3248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3259 if (mime_type == "application/x-nacl-srpc") { | 3259 if (mime_type == "application/x-nacl-srpc") { |
| 3260 in_process_plugin = true; | 3260 in_process_plugin = true; |
| 3261 use_pepper_host = true; | 3261 use_pepper_host = true; |
| 3262 } | 3262 } |
| 3263 } | 3263 } |
| 3264 | 3264 |
| 3265 if (in_process_plugin) { | 3265 if (in_process_plugin) { |
| 3266 if (use_pepper_host) { | 3266 if (use_pepper_host) { |
| 3267 WebPluginDelegatePepper* pepper_plugin = | 3267 WebPluginDelegatePepper* pepper_plugin = |
| 3268 WebPluginDelegatePepper::Create(file_path, mime_type, AsWeakPtr()); | 3268 WebPluginDelegatePepper::Create(file_path, mime_type, AsWeakPtr()); |
| 3269 current_pepper_plugins_.insert(pepper_plugin); | 3269 current_oldstyle_pepper_plugins_.insert(pepper_plugin); |
| 3270 return pepper_plugin; | 3270 return pepper_plugin; |
| 3271 } else { | 3271 } else { |
| 3272 #if defined(OS_WIN) // In-proc plugins aren't supported on Linux or Mac. | 3272 #if defined(OS_WIN) // In-proc plugins aren't supported on Linux or Mac. |
| 3273 return WebPluginDelegateImpl::Create( | 3273 return WebPluginDelegateImpl::Create( |
| 3274 file_path, mime_type, gfx::NativeViewFromId(host_window_)); | 3274 file_path, mime_type, gfx::NativeViewFromId(host_window_)); |
| 3275 #else | 3275 #else |
| 3276 NOTIMPLEMENTED(); | 3276 NOTIMPLEMENTED(); |
| 3277 return NULL; | 3277 return NULL; |
| 3278 #endif | 3278 #endif |
| 3279 } | 3279 } |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3772 WebFrame* web_frame = GetChildFrame(frame_xpath); | 3772 WebFrame* web_frame = GetChildFrame(frame_xpath); |
| 3773 if (!web_frame) | 3773 if (!web_frame) |
| 3774 return; | 3774 return; |
| 3775 | 3775 |
| 3776 web_frame->insertStyleText(WebString::fromUTF8(css), WebString::fromUTF8(id)); | 3776 web_frame->insertStyleText(WebString::fromUTF8(css), WebString::fromUTF8(id)); |
| 3777 } | 3777 } |
| 3778 | 3778 |
| 3779 void RenderView::OnPepperPluginDestroy( | 3779 void RenderView::OnPepperPluginDestroy( |
| 3780 WebPluginDelegatePepper* pepper_plugin) { | 3780 WebPluginDelegatePepper* pepper_plugin) { |
| 3781 std::set<WebPluginDelegatePepper*>::iterator found_pepper = | 3781 std::set<WebPluginDelegatePepper*>::iterator found_pepper = |
| 3782 current_pepper_plugins_.find(pepper_plugin); | 3782 current_oldstyle_pepper_plugins_.find(pepper_plugin); |
| 3783 if (found_pepper == current_pepper_plugins_.end()) { | 3783 if (found_pepper == current_oldstyle_pepper_plugins_.end()) { |
| 3784 NOTREACHED(); | 3784 NOTREACHED(); |
| 3785 return; | 3785 return; |
| 3786 } | 3786 } |
| 3787 current_pepper_plugins_.erase(found_pepper); | 3787 current_oldstyle_pepper_plugins_.erase(found_pepper); |
| 3788 | 3788 |
| 3789 // The plugin could have been destroyed while it was waiting for a file | 3789 // The plugin could have been destroyed while it was waiting for a file |
| 3790 // choose callback, so check all pending completion callbacks and NULL them. | 3790 // choose callback, so check all pending completion callbacks and NULL them. |
| 3791 for (std::deque< linked_ptr<PendingFileChooser> >::iterator i = | 3791 for (std::deque< linked_ptr<PendingFileChooser> >::iterator i = |
| 3792 file_chooser_completions_.begin(); | 3792 file_chooser_completions_.begin(); |
| 3793 i != file_chooser_completions_.end(); /* nothing */) { | 3793 i != file_chooser_completions_.end(); /* nothing */) { |
| 3794 if ((*i)->completion == pepper_plugin) { | 3794 if ((*i)->completion == pepper_plugin) { |
| 3795 // We NULL the first one instead of deleting it because the plugin might | 3795 // We NULL the first one instead of deleting it because the plugin might |
| 3796 // be the one waiting for a file choose callback. If the callback later | 3796 // be the one waiting for a file choose callback. If the callback later |
| 3797 // comes, we don't want to send the result to the next callback in line. | 3797 // comes, we don't want to send the result to the next callback in line. |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4273 disable_scrollbars_size_limit_.width() <= new_size.width() || | 4273 disable_scrollbars_size_limit_.width() <= new_size.width() || |
| 4274 disable_scrollbars_size_limit_.height() <= new_size.height()); | 4274 disable_scrollbars_size_limit_.height() <= new_size.height()); |
| 4275 webview()->mainFrame()->setCanHaveScrollbars(allow_scrollbars); | 4275 webview()->mainFrame()->setCanHaveScrollbars(allow_scrollbars); |
| 4276 } | 4276 } |
| 4277 } | 4277 } |
| 4278 | 4278 |
| 4279 RenderWidget::OnResize(new_size, resizer_rect); | 4279 RenderWidget::OnResize(new_size, resizer_rect); |
| 4280 } | 4280 } |
| 4281 | 4281 |
| 4282 void RenderView::DidInitiatePaint() { | 4282 void RenderView::DidInitiatePaint() { |
| 4283 // Notify any pepper plugins that we started painting. The plugin "should" | 4283 // Notify the pepper plugins that we started painting. |
| 4284 // never notified that we started painting, this is used for internal | 4284 pepper_delegate_.ViewInitiatedPaint(); |
| 4285 // bookkeeping only, so we know that the set can not change under us. | 4285 |
| 4286 // Notify any "old-style" pepper plugins that we started painting. This is |
| 4287 // used for internal bookkeeping only, so we know that the set can not change |
| 4288 // under us. |
| 4286 for (std::set<WebPluginDelegatePepper*>::iterator i = | 4289 for (std::set<WebPluginDelegatePepper*>::iterator i = |
| 4287 current_pepper_plugins_.begin(); | 4290 current_oldstyle_pepper_plugins_.begin(); |
| 4288 i != current_pepper_plugins_.end(); ++i) | 4291 i != current_oldstyle_pepper_plugins_.end(); ++i) |
| 4289 (*i)->RenderViewInitiatedPaint(); | 4292 (*i)->RenderViewInitiatedPaint(); |
| 4290 } | 4293 } |
| 4291 | 4294 |
| 4292 void RenderView::DidFlushPaint() { | 4295 void RenderView::DidFlushPaint() { |
| 4293 // Notify any pepper plugins that we painted. This will call into the plugin, | 4296 // Notify any pepper plugins that we painted. This will call into the plugin, |
| 4294 // and we it may ask to close itself as a result. This will, in turn, modify | 4297 // and we it may ask to close itself as a result. This will, in turn, modify |
| 4295 // our set, possibly invalidating the iterator. So we iterate on a copy that | 4298 // our set, possibly invalidating the iterator. So we iterate on a copy that |
| 4296 // won't change out from under us. | 4299 // won't change out from under us. |
| 4297 std::set<WebPluginDelegatePepper*> plugins = current_pepper_plugins_; | 4300 pepper_delegate_.ViewFlushedPaint(); |
| 4301 |
| 4302 // Notify any old-style pepper plugins that we painted. This will call into |
| 4303 // the plugin, and we it may ask to close itself as a result. This will, in |
| 4304 // turn, modify our set, possibly invalidating the iterator. So we iterate on |
| 4305 // a copy that won't change out from under us. |
| 4306 // This should be deleted when we don't support old Pepper anymore. |
| 4307 std::set<WebPluginDelegatePepper*> plugins = current_oldstyle_pepper_plugins_; |
| 4298 for (std::set<WebPluginDelegatePepper*>::iterator i = plugins.begin(); | 4308 for (std::set<WebPluginDelegatePepper*>::iterator i = plugins.begin(); |
| 4299 i != plugins.end(); ++i) { | 4309 i != plugins.end(); ++i) { |
| 4300 // The copy above makes sure our iterator is never invalid if some plugins | 4310 // The copy above makes sure our iterator is never invalid if some plugins |
| 4301 // are destroyed. But some plugin may decide to close all of its views in | 4311 // are destroyed. But some plugin may decide to close all of its views in |
| 4302 // response to a paint in one of them, so we need to make sure each one is | 4312 // response to a paint in one of them, so we need to make sure each one is |
| 4303 // still "current" before using it. | 4313 // still "current" before using it. |
| 4304 if (current_pepper_plugins_.find(*i) != current_pepper_plugins_.end()) | 4314 if (current_oldstyle_pepper_plugins_.find(*i) != |
| 4315 current_oldstyle_pepper_plugins_.end()) |
| 4305 (*i)->RenderViewFlushedPaint(); | 4316 (*i)->RenderViewFlushedPaint(); |
| 4306 } | 4317 } |
| 4307 | 4318 |
| 4308 WebFrame* main_frame = webview()->mainFrame(); | 4319 WebFrame* main_frame = webview()->mainFrame(); |
| 4309 | 4320 |
| 4310 // If we have a provisional frame we are between the start and commit stages | 4321 // If we have a provisional frame we are between the start and commit stages |
| 4311 // of loading and we don't want to save stats. | 4322 // of loading and we don't want to save stats. |
| 4312 if (!main_frame->provisionalDataSource()) { | 4323 if (!main_frame->provisionalDataSource()) { |
| 4313 WebDataSource* ds = main_frame->dataSource(); | 4324 WebDataSource* ds = main_frame->dataSource(); |
| 4314 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 4325 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 4315 DCHECK(navigation_state); | 4326 DCHECK(navigation_state); |
| 4316 | 4327 |
| 4317 Time now = Time::Now(); | 4328 Time now = Time::Now(); |
| 4318 if (navigation_state->first_paint_time().is_null()) { | 4329 if (navigation_state->first_paint_time().is_null()) { |
| 4319 navigation_state->set_first_paint_time(now); | 4330 navigation_state->set_first_paint_time(now); |
| 4320 } | 4331 } |
| 4321 if (navigation_state->first_paint_after_load_time().is_null() && | 4332 if (navigation_state->first_paint_after_load_time().is_null() && |
| 4322 !navigation_state->finish_load_time().is_null()) { | 4333 !navigation_state->finish_load_time().is_null()) { |
| 4323 navigation_state->set_first_paint_after_load_time(now); | 4334 navigation_state->set_first_paint_after_load_time(now); |
| 4324 } | 4335 } |
| 4325 } | 4336 } |
| 4326 } | 4337 } |
| 4327 | 4338 |
| 4328 | |
| 4329 void RenderView::OnClearFocusedNode() { | 4339 void RenderView::OnClearFocusedNode() { |
| 4330 if (webview()) | 4340 if (webview()) |
| 4331 webview()->clearFocusedNode(); | 4341 webview()->clearFocusedNode(); |
| 4332 } | 4342 } |
| 4333 | 4343 |
| 4334 void RenderView::OnSetBackground(const SkBitmap& background) { | 4344 void RenderView::OnSetBackground(const SkBitmap& background) { |
| 4335 if (webview()) | 4345 if (webview()) |
| 4336 webview()->setIsTransparent(!background.empty()); | 4346 webview()->setIsTransparent(!background.empty()); |
| 4337 | 4347 |
| 4338 SetBackground(background); | 4348 SetBackground(background); |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5145 webkit_glue::FormData form; | 5155 webkit_glue::FormData form; |
| 5146 const WebInputElement element = node.toConst<WebInputElement>(); | 5156 const WebInputElement element = node.toConst<WebInputElement>(); |
| 5147 if (!form_manager_.FindFormWithFormControlElement( | 5157 if (!form_manager_.FindFormWithFormControlElement( |
| 5148 element, FormManager::REQUIRE_NONE, &form)) | 5158 element, FormManager::REQUIRE_NONE, &form)) |
| 5149 return; | 5159 return; |
| 5150 | 5160 |
| 5151 autofill_action_ = action; | 5161 autofill_action_ = action; |
| 5152 Send(new ViewHostMsg_FillAutoFillFormData( | 5162 Send(new ViewHostMsg_FillAutoFillFormData( |
| 5153 routing_id_, autofill_query_id_, form, value, label)); | 5163 routing_id_, autofill_query_id_, form, value, label)); |
| 5154 } | 5164 } |
| OLD | NEW |