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_impl.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> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/json/json_value_serializer.h" | 15 #include "base/json/json_value_serializer.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 using content::RenderViewVisitor; | 244 using content::RenderViewVisitor; |
245 using content::V8ValueConverter; | 245 using content::V8ValueConverter; |
246 using webkit_glue::AltErrorPageResourceFetcher; | 246 using webkit_glue::AltErrorPageResourceFetcher; |
247 using webkit_glue::FormField; | 247 using webkit_glue::FormField; |
248 using webkit_glue::PasswordForm; | 248 using webkit_glue::PasswordForm; |
249 using webkit_glue::PasswordFormDomManager; | 249 using webkit_glue::PasswordFormDomManager; |
250 using webkit_glue::ResourceFetcher; | 250 using webkit_glue::ResourceFetcher; |
251 | 251 |
252 //----------------------------------------------------------------------------- | 252 //----------------------------------------------------------------------------- |
253 | 253 |
254 typedef std::map<WebKit::WebView*, RenderView*> ViewMap; | 254 typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; |
255 static base::LazyInstance<ViewMap> g_view_map(base::LINKER_INITIALIZED); | 255 static base::LazyInstance<ViewMap> g_view_map(base::LINKER_INITIALIZED); |
256 | 256 |
257 // Time, in seconds, we delay before sending content state changes (such as form | 257 // Time, in seconds, we delay before sending content state changes (such as form |
258 // state and scroll position) to the browser. We delay sending changes to avoid | 258 // state and scroll position) to the browser. We delay sending changes to avoid |
259 // spamming the browser. | 259 // spamming the browser. |
260 // To avoid having tab/session restore require sending a message to get the | 260 // To avoid having tab/session restore require sending a message to get the |
261 // current content state during tab closing we use a shorter timeout for the | 261 // current content state during tab closing we use a shorter timeout for the |
262 // foreground renderer. This means there is a small window of time from which | 262 // foreground renderer. This means there is a small window of time from which |
263 // content state is modified and not sent to session restore, but this is | 263 // content state is modified and not sent to session restore, but this is |
264 // better than having to wake up all renderers during shutdown. | 264 // better than having to wake up all renderers during shutdown. |
(...skipping 18 matching lines...) Expand all Loading... |
283 static void StopAltErrorPageFetcher(WebDataSource* data_source) { | 283 static void StopAltErrorPageFetcher(WebDataSource* data_source) { |
284 if (data_source) { | 284 if (data_source) { |
285 NavigationState* state = NavigationState::FromDataSource(data_source); | 285 NavigationState* state = NavigationState::FromDataSource(data_source); |
286 if (state) | 286 if (state) |
287 state->set_alt_error_page_fetcher(NULL); | 287 state->set_alt_error_page_fetcher(NULL); |
288 } | 288 } |
289 } | 289 } |
290 | 290 |
291 /////////////////////////////////////////////////////////////////////////////// | 291 /////////////////////////////////////////////////////////////////////////////// |
292 | 292 |
293 int32 RenderView::next_page_id_ = 1; | 293 int32 RenderViewImpl::next_page_id_ = 1; |
294 | 294 |
295 struct RenderView::PendingFileChooser { | 295 struct RenderViewImpl::PendingFileChooser { |
296 PendingFileChooser(const ViewHostMsg_RunFileChooser_Params& p, | 296 PendingFileChooser(const ViewHostMsg_RunFileChooser_Params& p, |
297 WebFileChooserCompletion* c) | 297 WebFileChooserCompletion* c) |
298 : params(p), | 298 : params(p), |
299 completion(c) { | 299 completion(c) { |
300 } | 300 } |
301 ViewHostMsg_RunFileChooser_Params params; | 301 ViewHostMsg_RunFileChooser_Params params; |
302 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. | 302 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. |
303 }; | 303 }; |
304 | 304 |
305 RenderView::RenderView(gfx::NativeViewId parent_hwnd, | 305 RenderViewImpl::RenderViewImpl(gfx::NativeViewId parent_hwnd, |
306 int32 opener_id, | 306 int32 opener_id, |
307 const RendererPreferences& renderer_prefs, | 307 const RendererPreferences& renderer_prefs, |
308 const WebPreferences& webkit_prefs, | 308 const WebPreferences& webkit_prefs, |
309 SharedRenderViewCounter* counter, | 309 SharedRenderViewCounter* counter, |
310 int32 routing_id, | 310 int32 routing_id, |
311 int64 session_storage_namespace_id, | 311 int64 session_storage_namespace_id, |
312 const string16& frame_name) | 312 const string16& frame_name) |
313 : RenderWidget(WebKit::WebPopupTypeNone), | 313 : RenderWidget(WebKit::WebPopupTypeNone), |
314 webkit_preferences_(webkit_prefs), | 314 webkit_preferences_(webkit_prefs), |
315 send_content_state_immediately_(false), | 315 send_content_state_immediately_(false), |
316 enabled_bindings_(0), | 316 enabled_bindings_(0), |
317 send_preferred_size_changes_(false), | 317 send_preferred_size_changes_(false), |
318 is_loading_(false), | 318 is_loading_(false), |
319 navigation_gesture_(NavigationGestureUnknown), | 319 navigation_gesture_(NavigationGestureUnknown), |
320 opened_by_user_gesture_(true), | 320 opened_by_user_gesture_(true), |
321 opener_suppressed_(false), | 321 opener_suppressed_(false), |
322 page_id_(-1), | 322 page_id_(-1), |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 399 |
400 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 400 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
401 if (command_line.HasSwitch(switches::kEnableMediaStream)) { | 401 if (command_line.HasSwitch(switches::kEnableMediaStream)) { |
402 media_stream_impl_ = new MediaStreamImpl( | 402 media_stream_impl_ = new MediaStreamImpl( |
403 RenderThreadImpl::current()->video_capture_impl_manager()); | 403 RenderThreadImpl::current()->video_capture_impl_manager()); |
404 } | 404 } |
405 | 405 |
406 content::GetContentClient()->renderer()->RenderViewCreated(this); | 406 content::GetContentClient()->renderer()->RenderViewCreated(this); |
407 } | 407 } |
408 | 408 |
409 RenderView::~RenderView() { | 409 RenderViewImpl::~RenderViewImpl() { |
410 history_page_ids_.clear(); | 410 history_page_ids_.clear(); |
411 | 411 |
412 if (decrement_shared_popup_at_destruction_) | 412 if (decrement_shared_popup_at_destruction_) |
413 shared_popup_counter_->data--; | 413 shared_popup_counter_->data--; |
414 | 414 |
415 // If file chooser is still waiting for answer, dispatch empty answer. | 415 // If file chooser is still waiting for answer, dispatch empty answer. |
416 while (!file_chooser_completions_.empty()) { | 416 while (!file_chooser_completions_.empty()) { |
417 if (file_chooser_completions_.front()->completion) { | 417 if (file_chooser_completions_.front()->completion) { |
418 file_chooser_completions_.front()->completion->didChooseFile( | 418 file_chooser_completions_.front()->completion->didChooseFile( |
419 WebVector<WebString>()); | 419 WebVector<WebString>()); |
(...skipping 11 matching lines...) Expand all Loading... |
431 } | 431 } |
432 #endif | 432 #endif |
433 | 433 |
434 #ifndef NDEBUG | 434 #ifndef NDEBUG |
435 // Make sure we are no longer referenced by the ViewMap. | 435 // Make sure we are no longer referenced by the ViewMap. |
436 ViewMap* views = g_view_map.Pointer(); | 436 ViewMap* views = g_view_map.Pointer(); |
437 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) | 437 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
438 DCHECK_NE(this, it->second) << "Failed to call Close?"; | 438 DCHECK_NE(this, it->second) << "Failed to call Close?"; |
439 #endif | 439 #endif |
440 | 440 |
441 FOR_EACH_OBSERVER(RenderViewObserver, observers_, set_render_view(NULL)); | 441 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); |
442 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); | 442 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); |
443 } | 443 } |
444 | 444 |
445 /*static*/ | 445 /*static*/ |
446 RenderView* RenderView::FromWebView(WebView* webview) { | 446 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
447 ViewMap* views = g_view_map.Pointer(); | 447 ViewMap* views = g_view_map.Pointer(); |
448 ViewMap::iterator it = views->find(webview); | 448 ViewMap::iterator it = views->find(webview); |
449 return it == views->end() ? NULL : it->second; | 449 return it == views->end() ? NULL : it->second; |
450 } | 450 } |
451 | 451 |
452 /*static*/ | 452 /*static*/ |
453 content::RenderView* | 453 content::RenderView* |
454 content::RenderView::FromWebView(WebKit::WebView* webview) { | 454 content::RenderView::FromWebView(WebKit::WebView* webview) { |
455 return ::RenderView::FromWebView(webview); | 455 return RenderViewImpl::FromWebView(webview); |
456 } | 456 } |
457 | 457 |
458 /*static*/ | 458 /*static*/ |
459 void content::RenderView::ForEach(content::RenderViewVisitor* visitor) { | 459 void content::RenderView::ForEach(content::RenderViewVisitor* visitor) { |
460 ViewMap* views = g_view_map.Pointer(); | 460 ViewMap* views = g_view_map.Pointer(); |
461 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { | 461 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { |
462 if (!visitor->Visit(it->second)) | 462 if (!visitor->Visit(it->second)) |
463 return; | 463 return; |
464 } | 464 } |
465 } | 465 } |
466 | 466 |
467 /*static*/ | 467 /*static*/ |
468 RenderView* RenderView::Create( | 468 RenderViewImpl* RenderViewImpl::Create( |
469 gfx::NativeViewId parent_hwnd, | 469 gfx::NativeViewId parent_hwnd, |
470 int32 opener_id, | 470 int32 opener_id, |
471 const RendererPreferences& renderer_prefs, | 471 const RendererPreferences& renderer_prefs, |
472 const WebPreferences& webkit_prefs, | 472 const WebPreferences& webkit_prefs, |
473 SharedRenderViewCounter* counter, | 473 SharedRenderViewCounter* counter, |
474 int32 routing_id, | 474 int32 routing_id, |
475 int64 session_storage_namespace_id, | 475 int64 session_storage_namespace_id, |
476 const string16& frame_name) { | 476 const string16& frame_name) { |
477 DCHECK(routing_id != MSG_ROUTING_NONE); | 477 DCHECK(routing_id != MSG_ROUTING_NONE); |
478 return new RenderView( | 478 return new RenderViewImpl( |
479 parent_hwnd, | 479 parent_hwnd, |
480 opener_id, | 480 opener_id, |
481 renderer_prefs, | 481 renderer_prefs, |
482 webkit_prefs, | 482 webkit_prefs, |
483 counter, | 483 counter, |
484 routing_id, | 484 routing_id, |
485 session_storage_namespace_id, | 485 session_storage_namespace_id, |
486 frame_name); // adds reference | 486 frame_name); // adds reference |
487 } | 487 } |
488 | 488 |
489 // static | 489 // static |
490 void RenderView::SetNextPageID(int32 next_page_id) { | 490 void RenderViewImpl::SetNextPageID(int32 next_page_id) { |
491 // This method should only be called during process startup, and the given | 491 // This method should only be called during process startup, and the given |
492 // page id had better not exceed our current next page id! | 492 // page id had better not exceed our current next page id! |
493 DCHECK_EQ(next_page_id_, 1); | 493 DCHECK_EQ(next_page_id_, 1); |
494 DCHECK(next_page_id >= next_page_id_); | 494 DCHECK(next_page_id >= next_page_id_); |
495 next_page_id_ = next_page_id; | 495 next_page_id_ = next_page_id; |
496 } | 496 } |
497 | 497 |
498 void RenderView::AddObserver(RenderViewObserver* observer) { | 498 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
499 observers_.AddObserver(observer); | 499 observers_.AddObserver(observer); |
500 } | 500 } |
501 | 501 |
502 void RenderView::RemoveObserver(RenderViewObserver* observer) { | 502 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
503 observer->set_render_view(NULL); | 503 observer->RenderViewGone(); |
504 observers_.RemoveObserver(observer); | 504 observers_.RemoveObserver(observer); |
505 } | 505 } |
506 | 506 |
507 WebKit::WebView* RenderView::webview() const { | 507 WebKit::WebView* RenderViewImpl::webview() const { |
508 return static_cast<WebKit::WebView*>(webwidget()); | 508 return static_cast<WebKit::WebView*>(webwidget()); |
509 } | 509 } |
510 | 510 |
511 void RenderView::SetReportLoadProgressEnabled(bool enabled) { | 511 void RenderViewImpl::SetReportLoadProgressEnabled(bool enabled) { |
512 if (!enabled) { | 512 if (!enabled) { |
513 load_progress_tracker_.reset(NULL); | 513 load_progress_tracker_.reset(NULL); |
514 return; | 514 return; |
515 } | 515 } |
516 if (load_progress_tracker_ == NULL) | 516 if (load_progress_tracker_ == NULL) |
517 load_progress_tracker_.reset(new LoadProgressTracker(this)); | 517 load_progress_tracker_.reset(new LoadProgressTracker(this)); |
518 } | 518 } |
519 | 519 |
520 void RenderView::PluginCrashed(const FilePath& plugin_path) { | 520 void RenderViewImpl::PluginCrashed(const FilePath& plugin_path) { |
521 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); | 521 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); |
522 } | 522 } |
523 | 523 |
524 void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { | 524 void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { |
525 plugin_delegates_.insert(delegate); | 525 plugin_delegates_.insert(delegate); |
526 // If the renderer is visible, set initial visibility and focus state. | 526 // If the renderer is visible, set initial visibility and focus state. |
527 if (!is_hidden()) { | 527 if (!is_hidden()) { |
528 #if defined(OS_MACOSX) | 528 #if defined(OS_MACOSX) |
529 delegate->SetContainerVisibility(true); | 529 delegate->SetContainerVisibility(true); |
530 if (webview() && webview()->isActive()) | 530 if (webview() && webview()->isActive()) |
531 delegate->SetWindowFocus(true); | 531 delegate->SetWindowFocus(true); |
532 #endif | 532 #endif |
533 } | 533 } |
534 // Plugins start assuming the content has focus (so that they work in | 534 // Plugins start assuming the content has focus (so that they work in |
535 // environments where RenderView isn't hosting them), so we always have to | 535 // environments where RenderView isn't hosting them), so we always have to |
536 // set the initial state. See webplugin_delegate_impl.h for details. | 536 // set the initial state. See webplugin_delegate_impl.h for details. |
537 delegate->SetContentAreaFocus(has_focus()); | 537 delegate->SetContentAreaFocus(has_focus()); |
538 } | 538 } |
539 | 539 |
540 void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) { | 540 void RenderViewImpl::UnregisterPluginDelegate( |
| 541 WebPluginDelegateProxy* delegate) { |
541 plugin_delegates_.erase(delegate); | 542 plugin_delegates_.erase(delegate); |
542 } | 543 } |
543 | 544 |
544 bool RenderView::GetPluginInfo(const GURL& url, | 545 bool RenderViewImpl::GetPluginInfo(const GURL& url, |
545 const GURL& page_url, | 546 const GURL& page_url, |
546 const std::string& mime_type, | 547 const std::string& mime_type, |
547 webkit::WebPluginInfo* plugin_info, | 548 webkit::WebPluginInfo* plugin_info, |
548 std::string* actual_mime_type) { | 549 std::string* actual_mime_type) { |
549 bool found = false; | 550 bool found = false; |
550 Send(new ViewHostMsg_GetPluginInfo( | 551 Send(new ViewHostMsg_GetPluginInfo( |
551 routing_id_, url, page_url, mime_type, &found, plugin_info, | 552 routing_id_, url, page_url, mime_type, &found, plugin_info, |
552 actual_mime_type)); | 553 actual_mime_type)); |
553 return found; | 554 return found; |
554 } | 555 } |
555 | 556 |
556 bool RenderView::OnMessageReceived(const IPC::Message& message) { | 557 bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
557 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 558 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
558 if (main_frame) | 559 if (main_frame) |
559 content::GetContentClient()->SetActiveURL(main_frame->document().url()); | 560 content::GetContentClient()->SetActiveURL(main_frame->document().url()); |
560 | 561 |
561 ObserverListBase<RenderViewObserver>::Iterator it(observers_); | 562 ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
562 RenderViewObserver* observer; | 563 RenderViewObserver* observer; |
563 while ((observer = it.GetNext()) != NULL) | 564 while ((observer = it.GetNext()) != NULL) |
564 if (observer->OnMessageReceived(message)) | 565 if (observer->OnMessageReceived(message)) |
565 return true; | 566 return true; |
566 | 567 |
567 bool handled = true; | 568 bool handled = true; |
568 bool msg_is_ok = true; | 569 bool msg_is_ok = true; |
569 IPC_BEGIN_MESSAGE_MAP_EX(RenderView, message, msg_is_ok) | 570 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok) |
570 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) | 571 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
571 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) | 572 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
572 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) | 573 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) |
573 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) | 574 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) |
574 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) | 575 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) |
575 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) | 576 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) |
576 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) | 577 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) |
577 #if defined(OS_MACOSX) | 578 #if defined(OS_MACOSX) |
578 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) | 579 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) |
579 #endif | 580 #endif |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) | 670 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) |
670 IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) | 671 IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) |
671 | 672 |
672 // Have the super handle all other messages. | 673 // Have the super handle all other messages. |
673 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 674 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
674 IPC_END_MESSAGE_MAP() | 675 IPC_END_MESSAGE_MAP() |
675 | 676 |
676 if (!msg_is_ok) { | 677 if (!msg_is_ok) { |
677 // The message had a handler, but its deserialization failed. | 678 // The message had a handler, but its deserialization failed. |
678 // Kill the renderer to avoid potential spoofing attacks. | 679 // Kill the renderer to avoid potential spoofing attacks. |
679 CHECK(false) << "Unable to deserialize message in RenderView."; | 680 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
680 } | 681 } |
681 | 682 |
682 return handled; | 683 return handled; |
683 } | 684 } |
684 | 685 |
685 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { | 686 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { |
686 if (!webview()) | 687 if (!webview()) |
687 return; | 688 return; |
688 | 689 |
689 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); | 690 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); |
690 | 691 |
691 bool is_reload = | 692 bool is_reload = |
692 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || | 693 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
693 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 694 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
694 | 695 |
695 // If this is a stale back/forward (due to a recent navigation the browser | 696 // If this is a stale back/forward (due to a recent navigation the browser |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 | 797 |
797 if (navigation_state) | 798 if (navigation_state) |
798 navigation_state->set_load_type(NavigationState::NORMAL_LOAD); | 799 navigation_state->set_load_type(NavigationState::NORMAL_LOAD); |
799 main_frame->loadRequest(request); | 800 main_frame->loadRequest(request); |
800 } | 801 } |
801 | 802 |
802 // In case LoadRequest failed before DidCreateDataSource was called. | 803 // In case LoadRequest failed before DidCreateDataSource was called. |
803 pending_navigation_state_.reset(); | 804 pending_navigation_state_.reset(); |
804 } | 805 } |
805 | 806 |
806 bool RenderView::IsBackForwardToStaleEntry( | 807 bool RenderViewImpl::IsBackForwardToStaleEntry( |
807 const ViewMsg_Navigate_Params& params, | 808 const ViewMsg_Navigate_Params& params, |
808 bool is_reload) { | 809 bool is_reload) { |
809 // Make sure this isn't a back/forward to an entry we have already cropped | 810 // Make sure this isn't a back/forward to an entry we have already cropped |
810 // or replaced from our history, before the browser knew about it. If so, | 811 // or replaced from our history, before the browser knew about it. If so, |
811 // a new navigation has committed in the mean time, and we can ignore this. | 812 // a new navigation has committed in the mean time, and we can ignore this. |
812 bool is_back_forward = !is_reload && !params.state.empty(); | 813 bool is_back_forward = !is_reload && !params.state.empty(); |
813 | 814 |
814 // Note: if the history_list_length_ is 0 for a back/forward, we must be | 815 // Note: if the history_list_length_ is 0 for a back/forward, we must be |
815 // restoring from a previous session. We'll update our state in OnNavigate. | 816 // restoring from a previous session. We'll update our state in OnNavigate. |
816 if (!is_back_forward || history_list_length_ <= 0) | 817 if (!is_back_forward || history_list_length_ <= 0) |
(...skipping 17 matching lines...) Expand all Loading... |
834 // entries left. For now, it's ok to lazily update the list. | 835 // entries left. For now, it's ok to lazily update the list. |
835 // TODO(creis): Notify all live renderers when we remove entries from | 836 // TODO(creis): Notify all live renderers when we remove entries from |
836 // the front of the list, so that we don't hit this case. | 837 // the front of the list, so that we don't hit this case. |
837 history_page_ids_[params.pending_history_list_offset] = params.page_id; | 838 history_page_ids_[params.pending_history_list_offset] = params.page_id; |
838 } | 839 } |
839 | 840 |
840 return false; | 841 return false; |
841 } | 842 } |
842 | 843 |
843 // Stop loading the current page | 844 // Stop loading the current page |
844 void RenderView::OnStop() { | 845 void RenderViewImpl::OnStop() { |
845 if (webview()) { | 846 if (webview()) { |
846 WebFrame* main_frame = webview()->mainFrame(); | 847 WebFrame* main_frame = webview()->mainFrame(); |
847 // Stop the alt error page fetcher. If we let it continue it may complete | 848 // Stop the alt error page fetcher. If we let it continue it may complete |
848 // and cause RenderViewHostManager to swap to this RenderView, even though | 849 // and cause RenderViewHostManager to swap to this RenderView, even though |
849 // it may no longer be active. | 850 // it may no longer be active. |
850 StopAltErrorPageFetcher(main_frame->provisionalDataSource()); | 851 StopAltErrorPageFetcher(main_frame->provisionalDataSource()); |
851 StopAltErrorPageFetcher(main_frame->dataSource()); | 852 StopAltErrorPageFetcher(main_frame->dataSource()); |
852 main_frame->stopLoading(); | 853 main_frame->stopLoading(); |
853 } | 854 } |
854 } | 855 } |
855 | 856 |
856 // Reload current focused frame. | 857 // Reload current focused frame. |
857 // E.g. called by right-clicking on the frame and picking "reload this frame". | 858 // E.g. called by right-clicking on the frame and picking "reload this frame". |
858 void RenderView::OnReloadFrame() { | 859 void RenderViewImpl::OnReloadFrame() { |
859 if (webview() && webview()->focusedFrame()) { | 860 if (webview() && webview()->focusedFrame()) { |
860 // We always obey the cache (ignore_cache=false) here. | 861 // We always obey the cache (ignore_cache=false) here. |
861 // TODO(evanm): perhaps we could allow shift-clicking the menu item to do | 862 // TODO(evanm): perhaps we could allow shift-clicking the menu item to do |
862 // a cache-ignoring reload of the frame. | 863 // a cache-ignoring reload of the frame. |
863 webview()->focusedFrame()->reload(false); | 864 webview()->focusedFrame()->reload(false); |
864 } | 865 } |
865 } | 866 } |
866 | 867 |
867 void RenderView::OnCopyImageAt(int x, int y) { | 868 void RenderViewImpl::OnCopyImageAt(int x, int y) { |
868 webview()->copyImageAt(WebPoint(x, y)); | 869 webview()->copyImageAt(WebPoint(x, y)); |
869 } | 870 } |
870 | 871 |
871 void RenderView::OnExecuteEditCommand(const std::string& name, | 872 void RenderViewImpl::OnExecuteEditCommand(const std::string& name, |
872 const std::string& value) { | 873 const std::string& value) { |
873 if (!webview() || !webview()->focusedFrame()) | 874 if (!webview() || !webview()->focusedFrame()) |
874 return; | 875 return; |
875 | 876 |
876 webview()->focusedFrame()->executeCommand( | 877 webview()->focusedFrame()->executeCommand( |
877 WebString::fromUTF8(name), WebString::fromUTF8(value)); | 878 WebString::fromUTF8(name), WebString::fromUTF8(value)); |
878 } | 879 } |
879 | 880 |
880 void RenderView::OnUpdateTargetURLAck() { | 881 void RenderViewImpl::OnUpdateTargetURLAck() { |
881 // Check if there is a targeturl waiting to be sent. | 882 // Check if there is a targeturl waiting to be sent. |
882 if (target_url_status_ == TARGET_PENDING) { | 883 if (target_url_status_ == TARGET_PENDING) { |
883 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, | 884 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, |
884 pending_target_url_)); | 885 pending_target_url_)); |
885 } | 886 } |
886 | 887 |
887 target_url_status_ = TARGET_NONE; | 888 target_url_status_ = TARGET_NONE; |
888 } | 889 } |
889 | 890 |
890 void RenderView::OnUndo() { | 891 void RenderViewImpl::OnUndo() { |
891 if (!webview()) | 892 if (!webview()) |
892 return; | 893 return; |
893 | 894 |
894 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Undo")); | 895 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Undo")); |
895 } | 896 } |
896 | 897 |
897 void RenderView::OnRedo() { | 898 void RenderViewImpl::OnRedo() { |
898 if (!webview()) | 899 if (!webview()) |
899 return; | 900 return; |
900 | 901 |
901 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Redo")); | 902 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Redo")); |
902 } | 903 } |
903 | 904 |
904 void RenderView::OnCut() { | 905 void RenderViewImpl::OnCut() { |
905 if (!webview()) | 906 if (!webview()) |
906 return; | 907 return; |
907 | 908 |
908 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Cut")); | 909 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Cut")); |
909 } | 910 } |
910 | 911 |
911 void RenderView::OnCopy() { | 912 void RenderViewImpl::OnCopy() { |
912 if (!webview()) | 913 if (!webview()) |
913 return; | 914 return; |
914 | 915 |
915 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Copy"), | 916 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Copy"), |
916 context_menu_node_); | 917 context_menu_node_); |
917 } | 918 } |
918 | 919 |
919 #if defined(OS_MACOSX) | 920 #if defined(OS_MACOSX) |
920 void RenderView::OnCopyToFindPboard() { | 921 void RenderViewImpl::OnCopyToFindPboard() { |
921 if (!webview()) | 922 if (!webview()) |
922 return; | 923 return; |
923 | 924 |
924 // Since the find pasteboard supports only plain text, this can be simpler | 925 // Since the find pasteboard supports only plain text, this can be simpler |
925 // than the |OnCopy()| case. | 926 // than the |OnCopy()| case. |
926 WebFrame* frame = webview()->focusedFrame(); | 927 WebFrame* frame = webview()->focusedFrame(); |
927 if (frame->hasSelection()) { | 928 if (frame->hasSelection()) { |
928 string16 selection = frame->selectionAsText(); | 929 string16 selection = frame->selectionAsText(); |
929 RenderThread::Get()->Send( | 930 RenderThread::Get()->Send( |
930 new ClipboardHostMsg_FindPboardWriteStringAsync(selection)); | 931 new ClipboardHostMsg_FindPboardWriteStringAsync(selection)); |
931 } | 932 } |
932 } | 933 } |
933 #endif | 934 #endif |
934 | 935 |
935 void RenderView::OnPaste() { | 936 void RenderViewImpl::OnPaste() { |
936 if (!webview()) | 937 if (!webview()) |
937 return; | 938 return; |
938 | 939 |
939 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Paste")); | 940 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Paste")); |
940 } | 941 } |
941 | 942 |
942 void RenderView::OnReplace(const string16& text) { | 943 void RenderViewImpl::OnReplace(const string16& text) { |
943 if (!webview()) | 944 if (!webview()) |
944 return; | 945 return; |
945 | 946 |
946 WebFrame* frame = webview()->focusedFrame(); | 947 WebFrame* frame = webview()->focusedFrame(); |
947 if (!frame->hasSelection()) | 948 if (!frame->hasSelection()) |
948 frame->selectWordAroundCaret(); | 949 frame->selectWordAroundCaret(); |
949 frame->replaceSelection(text); | 950 frame->replaceSelection(text); |
950 } | 951 } |
951 | 952 |
952 void RenderView::OnDelete() { | 953 void RenderViewImpl::OnDelete() { |
953 if (!webview()) | 954 if (!webview()) |
954 return; | 955 return; |
955 | 956 |
956 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete")); | 957 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete")); |
957 } | 958 } |
958 | 959 |
959 void RenderView::OnSelectAll() { | 960 void RenderViewImpl::OnSelectAll() { |
960 if (!webview()) | 961 if (!webview()) |
961 return; | 962 return; |
962 | 963 |
963 webview()->focusedFrame()->executeCommand( | 964 webview()->focusedFrame()->executeCommand( |
964 WebString::fromUTF8("SelectAll")); | 965 WebString::fromUTF8("SelectAll")); |
965 } | 966 } |
966 | 967 |
967 void RenderView::OnSelectRange(const gfx::Point& start, const gfx::Point& end) { | 968 void RenderViewImpl::OnSelectRange(const gfx::Point& start, |
| 969 const gfx::Point& end) { |
968 if (!webview()) | 970 if (!webview()) |
969 return; | 971 return; |
970 | 972 |
971 handling_select_range_ = true; | 973 handling_select_range_ = true; |
972 webview()->focusedFrame()->selectRange(start, end); | 974 webview()->focusedFrame()->selectRange(start, end); |
973 handling_select_range_ = false; | 975 handling_select_range_ = false; |
974 } | 976 } |
975 | 977 |
976 void RenderView::OnSetHistoryLengthAndPrune(int history_length, | 978 void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length, |
977 int32 minimum_page_id) { | 979 int32 minimum_page_id) { |
978 DCHECK(history_length >= 0); | 980 DCHECK(history_length >= 0); |
979 DCHECK(history_list_offset_ == history_list_length_ - 1); | 981 DCHECK(history_list_offset_ == history_list_length_ - 1); |
980 DCHECK(minimum_page_id >= -1); | 982 DCHECK(minimum_page_id >= -1); |
981 | 983 |
982 // Generate the new list. | 984 // Generate the new list. |
983 std::vector<int32> new_history_page_ids(history_length, -1); | 985 std::vector<int32> new_history_page_ids(history_length, -1); |
984 for (size_t i = 0; i < history_page_ids_.size(); ++i) { | 986 for (size_t i = 0; i < history_page_ids_.size(); ++i) { |
985 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id) | 987 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id) |
986 continue; | 988 continue; |
987 new_history_page_ids.push_back(history_page_ids_[i]); | 989 new_history_page_ids.push_back(history_page_ids_[i]); |
988 } | 990 } |
989 new_history_page_ids.swap(history_page_ids_); | 991 new_history_page_ids.swap(history_page_ids_); |
990 | 992 |
991 // Update indexes. | 993 // Update indexes. |
992 history_list_length_ = history_page_ids_.size(); | 994 history_list_length_ = history_page_ids_.size(); |
993 history_list_offset_ = history_list_length_ - 1; | 995 history_list_offset_ = history_list_length_ - 1; |
994 } | 996 } |
995 | 997 |
996 | 998 |
997 void RenderView::OnSetInitialFocus(bool reverse) { | 999 void RenderViewImpl::OnSetInitialFocus(bool reverse) { |
998 if (!webview()) | 1000 if (!webview()) |
999 return; | 1001 return; |
1000 webview()->setInitialFocus(reverse); | 1002 webview()->setInitialFocus(reverse); |
1001 } | 1003 } |
1002 | 1004 |
1003 #if defined(OS_MACOSX) | 1005 #if defined(OS_MACOSX) |
1004 void RenderView::OnSetInLiveResize(bool in_live_resize) { | 1006 void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) { |
1005 if (!webview()) | 1007 if (!webview()) |
1006 return; | 1008 return; |
1007 if (in_live_resize) | 1009 if (in_live_resize) |
1008 webview()->willStartLiveResize(); | 1010 webview()->willStartLiveResize(); |
1009 else | 1011 else |
1010 webview()->willEndLiveResize(); | 1012 webview()->willEndLiveResize(); |
1011 } | 1013 } |
1012 #endif | 1014 #endif |
1013 | 1015 |
1014 void RenderView::OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect) { | 1016 void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
| 1017 const gfx::Rect& rect) { |
1015 WebKit::WebNode node = GetFocusedNode(); | 1018 WebKit::WebNode node = GetFocusedNode(); |
1016 if (!node.isNull()) { | 1019 if (!node.isNull()) { |
1017 if (IsEditableNode(node)) | 1020 if (IsEditableNode(node)) |
1018 webview()->scrollFocusedNodeIntoRect(rect); | 1021 webview()->scrollFocusedNodeIntoRect(rect); |
1019 } | 1022 } |
1020 } | 1023 } |
1021 | 1024 |
1022 /////////////////////////////////////////////////////////////////////////////// | 1025 /////////////////////////////////////////////////////////////////////////////// |
1023 | 1026 |
1024 // Tell the embedding application that the URL of the active page has changed | 1027 // Tell the embedding application that the URL of the active page has changed |
1025 void RenderView::UpdateURL(WebFrame* frame) { | 1028 void RenderViewImpl::UpdateURL(WebFrame* frame) { |
1026 WebDataSource* ds = frame->dataSource(); | 1029 WebDataSource* ds = frame->dataSource(); |
1027 DCHECK(ds); | 1030 DCHECK(ds); |
1028 | 1031 |
1029 const WebURLRequest& request = ds->request(); | 1032 const WebURLRequest& request = ds->request(); |
1030 const WebURLRequest& original_request = ds->originalRequest(); | 1033 const WebURLRequest& original_request = ds->originalRequest(); |
1031 const WebURLResponse& response = ds->response(); | 1034 const WebURLResponse& response = ds->response(); |
1032 | 1035 |
1033 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 1036 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
1034 DCHECK(navigation_state); | 1037 DCHECK(navigation_state); |
1035 | 1038 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 | 1182 |
1180 last_page_id_sent_to_browser_ = | 1183 last_page_id_sent_to_browser_ = |
1181 std::max(last_page_id_sent_to_browser_, page_id_); | 1184 std::max(last_page_id_sent_to_browser_, page_id_); |
1182 | 1185 |
1183 // If we end up reusing this WebRequest (for example, due to a #ref click), | 1186 // If we end up reusing this WebRequest (for example, due to a #ref click), |
1184 // we don't want the transition type to persist. Just clear it. | 1187 // we don't want the transition type to persist. Just clear it. |
1185 navigation_state->set_transition_type(PageTransition::LINK); | 1188 navigation_state->set_transition_type(PageTransition::LINK); |
1186 } | 1189 } |
1187 | 1190 |
1188 // Tell the embedding application that the title of the active page has changed | 1191 // Tell the embedding application that the title of the active page has changed |
1189 void RenderView::UpdateTitle(WebFrame* frame, | 1192 void RenderViewImpl::UpdateTitle(WebFrame* frame, |
1190 const string16& title, | 1193 const string16& title, |
1191 WebTextDirection title_direction) { | 1194 WebTextDirection title_direction) { |
1192 // Ignore all but top level navigations. | 1195 // Ignore all but top level navigations. |
1193 if (frame->parent()) | 1196 if (frame->parent()) |
1194 return; | 1197 return; |
1195 | 1198 |
1196 string16 shortened_title = title.substr(0, content::kMaxTitleChars); | 1199 string16 shortened_title = title.substr(0, content::kMaxTitleChars); |
1197 Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title, | 1200 Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title, |
1198 title_direction)); | 1201 title_direction)); |
1199 } | 1202 } |
1200 | 1203 |
1201 void RenderView::UpdateEncoding(WebFrame* frame, | 1204 void RenderViewImpl::UpdateEncoding(WebFrame* frame, |
1202 const std::string& encoding_name) { | 1205 const std::string& encoding_name) { |
1203 // Only update main frame's encoding_name. | 1206 // Only update main frame's encoding_name. |
1204 if (webview()->mainFrame() == frame && | 1207 if (webview()->mainFrame() == frame && |
1205 last_encoding_name_ != encoding_name) { | 1208 last_encoding_name_ != encoding_name) { |
1206 // Save the encoding name for later comparing. | 1209 // Save the encoding name for later comparing. |
1207 last_encoding_name_ = encoding_name; | 1210 last_encoding_name_ = encoding_name; |
1208 | 1211 |
1209 Send(new ViewHostMsg_UpdateEncoding(routing_id_, last_encoding_name_)); | 1212 Send(new ViewHostMsg_UpdateEncoding(routing_id_, last_encoding_name_)); |
1210 } | 1213 } |
1211 } | 1214 } |
1212 | 1215 |
1213 // Sends the last committed session history state to the browser so it will be | 1216 // Sends the last committed session history state to the browser so it will be |
1214 // saved before we navigate to a new page. This must be called *before* the | 1217 // saved before we navigate to a new page. This must be called *before* the |
1215 // page ID has been updated so we know what it was. | 1218 // page ID has been updated so we know what it was. |
1216 void RenderView::UpdateSessionHistory(WebFrame* frame) { | 1219 void RenderViewImpl::UpdateSessionHistory(WebFrame* frame) { |
1217 // If we have a valid page ID at this point, then it corresponds to the page | 1220 // If we have a valid page ID at this point, then it corresponds to the page |
1218 // we are navigating away from. Otherwise, this is the first navigation, so | 1221 // we are navigating away from. Otherwise, this is the first navigation, so |
1219 // there is no past session history to record. | 1222 // there is no past session history to record. |
1220 if (page_id_ == -1) | 1223 if (page_id_ == -1) |
1221 return; | 1224 return; |
1222 | 1225 |
1223 const WebHistoryItem& item = | 1226 const WebHistoryItem& item = |
1224 webview()->mainFrame()->previousHistoryItem(); | 1227 webview()->mainFrame()->previousHistoryItem(); |
1225 if (item.isNull()) | 1228 if (item.isNull()) |
1226 return; | 1229 return; |
1227 | 1230 |
1228 Send(new ViewHostMsg_UpdateState( | 1231 Send(new ViewHostMsg_UpdateState( |
1229 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 1232 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
1230 } | 1233 } |
1231 | 1234 |
1232 void RenderView::OpenURL(WebFrame* frame, | 1235 void RenderViewImpl::OpenURL(WebFrame* frame, |
1233 const GURL& url, | 1236 const GURL& url, |
1234 const GURL& referrer, | 1237 const GURL& referrer, |
1235 WebNavigationPolicy policy) { | 1238 WebNavigationPolicy policy) { |
1236 Send(new ViewHostMsg_OpenURL( | 1239 Send(new ViewHostMsg_OpenURL( |
1237 routing_id_, | 1240 routing_id_, |
1238 url, | 1241 url, |
1239 referrer, | 1242 referrer, |
1240 NavigationPolicyToDisposition(policy), | 1243 NavigationPolicyToDisposition(policy), |
1241 frame->identifier())); | 1244 frame->identifier())); |
1242 } | 1245 } |
1243 | 1246 |
1244 // WebViewDelegate ------------------------------------------------------------ | 1247 // WebViewDelegate ------------------------------------------------------------ |
1245 | 1248 |
1246 void RenderView::LoadNavigationErrorPage(WebFrame* frame, | 1249 void RenderViewImpl::LoadNavigationErrorPage( |
1247 const WebURLRequest& failed_request, | 1250 WebFrame* frame, |
1248 const WebURLError& error, | 1251 const WebURLRequest& failed_request, |
1249 const std::string& html, | 1252 const WebURLError& error, |
1250 bool replace) { | 1253 const std::string& html, |
| 1254 bool replace) { |
1251 std::string alt_html = !html.empty() ? html : | 1255 std::string alt_html = !html.empty() ? html : |
1252 content::GetContentClient()->renderer()->GetNavigationErrorHtml( | 1256 content::GetContentClient()->renderer()->GetNavigationErrorHtml( |
1253 failed_request, error); | 1257 failed_request, error); |
1254 frame->loadHTMLString(alt_html, | 1258 frame->loadHTMLString(alt_html, |
1255 GURL(chrome::kUnreachableWebDataURL), | 1259 GURL(chrome::kUnreachableWebDataURL), |
1256 error.unreachableURL, | 1260 error.unreachableURL, |
1257 replace); | 1261 replace); |
1258 } | 1262 } |
1259 | 1263 |
1260 bool RenderView::RunJavaScriptMessage(int type, | 1264 bool RenderViewImpl::RunJavaScriptMessage(int type, |
1261 const string16& message, | 1265 const string16& message, |
1262 const string16& default_value, | 1266 const string16& default_value, |
1263 const GURL& frame_url, | 1267 const GURL& frame_url, |
1264 string16* result) { | 1268 string16* result) { |
1265 bool success = false; | 1269 bool success = false; |
1266 string16 result_temp; | 1270 string16 result_temp; |
1267 if (!result) | 1271 if (!result) |
1268 result = &result_temp; | 1272 result = &result_temp; |
1269 | 1273 |
1270 SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage( | 1274 SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage( |
1271 routing_id_, message, default_value, frame_url, type, &success, result)); | 1275 routing_id_, message, default_value, frame_url, type, &success, result)); |
1272 return success; | 1276 return success; |
1273 } | 1277 } |
1274 | 1278 |
1275 bool RenderView::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) { | 1279 bool RenderViewImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) { |
1276 // Before WebKit asks us to show an alert (etc.), it takes care of doing the | 1280 // Before WebKit asks us to show an alert (etc.), it takes care of doing the |
1277 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog | 1281 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog |
1278 // it is particularly important that we do not call willEnterModalLoop as | 1282 // it is particularly important that we do not call willEnterModalLoop as |
1279 // that would defer resource loads for the dialog itself. | 1283 // that would defer resource loads for the dialog itself. |
1280 if (RenderThreadImpl::current()) // Will be NULL during unit tests. | 1284 if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
1281 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); | 1285 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); |
1282 | 1286 |
1283 message->EnableMessagePumping(); // Runs a nested message loop. | 1287 message->EnableMessagePumping(); // Runs a nested message loop. |
1284 return Send(message); | 1288 return Send(message); |
1285 } | 1289 } |
1286 | 1290 |
1287 // WebKit::WebViewClient ------------------------------------------------------ | 1291 // WebKit::WebViewClient ------------------------------------------------------ |
1288 | 1292 |
1289 WebView* RenderView::createView( | 1293 WebView* RenderViewImpl::createView( |
1290 WebFrame* creator, | 1294 WebFrame* creator, |
1291 const WebURLRequest& request, | 1295 const WebURLRequest& request, |
1292 const WebWindowFeatures& features, | 1296 const WebWindowFeatures& features, |
1293 const WebString& frame_name) { | 1297 const WebString& frame_name) { |
1294 // Check to make sure we aren't overloading on popups. | 1298 // Check to make sure we aren't overloading on popups. |
1295 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) | 1299 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) |
1296 return NULL; | 1300 return NULL; |
1297 | 1301 |
1298 ViewHostMsg_CreateWindow_Params params; | 1302 ViewHostMsg_CreateWindow_Params params; |
1299 params.opener_id = routing_id_; | 1303 params.opener_id = routing_id_; |
(...skipping 12 matching lines...) Expand all Loading... |
1312 int64 cloned_session_storage_namespace_id; | 1316 int64 cloned_session_storage_namespace_id; |
1313 bool opener_suppressed = creator->willSuppressOpenerInNewFrame(); | 1317 bool opener_suppressed = creator->willSuppressOpenerInNewFrame(); |
1314 | 1318 |
1315 RenderThread::Get()->Send( | 1319 RenderThread::Get()->Send( |
1316 new ViewHostMsg_CreateWindow(params, | 1320 new ViewHostMsg_CreateWindow(params, |
1317 &routing_id, | 1321 &routing_id, |
1318 &cloned_session_storage_namespace_id)); | 1322 &cloned_session_storage_namespace_id)); |
1319 if (routing_id == MSG_ROUTING_NONE) | 1323 if (routing_id == MSG_ROUTING_NONE) |
1320 return NULL; | 1324 return NULL; |
1321 | 1325 |
1322 RenderView* view = RenderView::Create(0, | 1326 RenderViewImpl* view = RenderViewImpl::Create( |
1323 routing_id_, | 1327 0, |
1324 renderer_preferences_, | 1328 routing_id_, |
1325 webkit_preferences_, | 1329 renderer_preferences_, |
1326 shared_popup_counter_, | 1330 webkit_preferences_, |
1327 routing_id, | 1331 shared_popup_counter_, |
1328 cloned_session_storage_namespace_id, | 1332 routing_id, |
1329 frame_name); | 1333 cloned_session_storage_namespace_id, |
| 1334 frame_name); |
1330 view->opened_by_user_gesture_ = params.user_gesture; | 1335 view->opened_by_user_gesture_ = params.user_gesture; |
1331 | 1336 |
1332 // Record whether the creator frame is trying to suppress the opener field. | 1337 // Record whether the creator frame is trying to suppress the opener field. |
1333 view->opener_suppressed_ = opener_suppressed; | 1338 view->opener_suppressed_ = opener_suppressed; |
1334 | 1339 |
1335 // Record the security origin of the creator. | 1340 // Record the security origin of the creator. |
1336 GURL creator_url(creator->document().securityOrigin().toString().utf8()); | 1341 GURL creator_url(creator->document().securityOrigin().toString().utf8()); |
1337 if (!creator_url.is_valid() || !creator_url.IsStandard()) | 1342 if (!creator_url.is_valid() || !creator_url.IsStandard()) |
1338 creator_url = GURL(); | 1343 creator_url = GURL(); |
1339 view->creator_url_ = creator_url; | 1344 view->creator_url_ = creator_url; |
1340 | 1345 |
1341 // Copy over the alternate error page URL so we can have alt error pages in | 1346 // Copy over the alternate error page URL so we can have alt error pages in |
1342 // the new render view (we don't need the browser to send the URL back down). | 1347 // the new render view (we don't need the browser to send the URL back down). |
1343 view->alternate_error_page_url_ = alternate_error_page_url_; | 1348 view->alternate_error_page_url_ = alternate_error_page_url_; |
1344 | 1349 |
1345 return view->webview(); | 1350 return view->webview(); |
1346 } | 1351 } |
1347 | 1352 |
1348 WebWidget* RenderView::createPopupMenu(WebKit::WebPopupType popup_type) { | 1353 WebWidget* RenderViewImpl::createPopupMenu(WebKit::WebPopupType popup_type) { |
1349 RenderWidget* widget = RenderWidget::Create(routing_id_, popup_type); | 1354 RenderWidget* widget = RenderWidget::Create(routing_id_, popup_type); |
1350 return widget->webwidget(); | 1355 return widget->webwidget(); |
1351 } | 1356 } |
1352 | 1357 |
1353 WebWidget* RenderView::createPopupMenu(const WebPopupMenuInfo& info) { | 1358 WebWidget* RenderViewImpl::createPopupMenu(const WebPopupMenuInfo& info) { |
1354 // TODO(jcivelli): Remove this deprecated method when its been removed from | 1359 // TODO(jcivelli): Remove this deprecated method when its been removed from |
1355 // the WebViewClient interface. It's been replaced by | 1360 // the WebViewClient interface. It's been replaced by |
1356 // createExternalPopupMenu. | 1361 // createExternalPopupMenu. |
1357 NOTREACHED(); | 1362 NOTREACHED(); |
1358 return NULL; | 1363 return NULL; |
1359 } | 1364 } |
1360 | 1365 |
1361 WebExternalPopupMenu* RenderView::createExternalPopupMenu( | 1366 WebExternalPopupMenu* RenderViewImpl::createExternalPopupMenu( |
1362 const WebPopupMenuInfo& popup_menu_info, | 1367 const WebPopupMenuInfo& popup_menu_info, |
1363 WebExternalPopupMenuClient* popup_menu_client) { | 1368 WebExternalPopupMenuClient* popup_menu_client) { |
1364 DCHECK(!external_popup_menu_.get()); | 1369 DCHECK(!external_popup_menu_.get()); |
1365 external_popup_menu_.reset( | 1370 external_popup_menu_.reset( |
1366 new ExternalPopupMenu(this, popup_menu_info, popup_menu_client)); | 1371 new ExternalPopupMenu(this, popup_menu_info, popup_menu_client)); |
1367 return external_popup_menu_.get(); | 1372 return external_popup_menu_.get(); |
1368 } | 1373 } |
1369 | 1374 |
1370 RenderWidgetFullscreenPepper* RenderView::CreatePepperFullscreenContainer( | 1375 RenderWidgetFullscreenPepper* RenderViewImpl::CreatePepperFullscreenContainer( |
1371 webkit::ppapi::PluginInstance* plugin) { | 1376 webkit::ppapi::PluginInstance* plugin) { |
1372 GURL active_url; | 1377 GURL active_url; |
1373 if (webview() && webview()->mainFrame()) | 1378 if (webview() && webview()->mainFrame()) |
1374 active_url = GURL(webview()->mainFrame()->document().url()); | 1379 active_url = GURL(webview()->mainFrame()->document().url()); |
1375 RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create( | 1380 RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create( |
1376 routing_id_, plugin, active_url); | 1381 routing_id_, plugin, active_url); |
1377 widget->show(WebKit::WebNavigationPolicyIgnore); | 1382 widget->show(WebKit::WebNavigationPolicyIgnore); |
1378 return widget; | 1383 return widget; |
1379 } | 1384 } |
1380 | 1385 |
1381 WebStorageNamespace* RenderView::createSessionStorageNamespace(unsigned quota) { | 1386 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace( |
| 1387 unsigned quota) { |
1382 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | 1388 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
1383 return WebStorageNamespace::createSessionStorageNamespace(quota); | 1389 return WebStorageNamespace::createSessionStorageNamespace(quota); |
1384 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); | 1390 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); |
1385 return new RendererWebStorageNamespaceImpl(DOM_STORAGE_SESSION, | 1391 return new RendererWebStorageNamespaceImpl(DOM_STORAGE_SESSION, |
1386 session_storage_namespace_id_); | 1392 session_storage_namespace_id_); |
1387 } | 1393 } |
1388 | 1394 |
1389 void RenderView::didAddMessageToConsole( | 1395 void RenderViewImpl::didAddMessageToConsole( |
1390 const WebConsoleMessage& message, const WebString& source_name, | 1396 const WebConsoleMessage& message, const WebString& source_name, |
1391 unsigned source_line) { | 1397 unsigned source_line) { |
1392 logging::LogSeverity log_severity = logging::LOG_VERBOSE; | 1398 logging::LogSeverity log_severity = logging::LOG_VERBOSE; |
1393 switch (message.level) { | 1399 switch (message.level) { |
1394 case WebConsoleMessage::LevelTip: | 1400 case WebConsoleMessage::LevelTip: |
1395 log_severity = logging::LOG_VERBOSE; | 1401 log_severity = logging::LOG_VERBOSE; |
1396 break; | 1402 break; |
1397 case WebConsoleMessage::LevelLog: | 1403 case WebConsoleMessage::LevelLog: |
1398 log_severity = logging::LOG_INFO; | 1404 log_severity = logging::LOG_INFO; |
1399 break; | 1405 break; |
1400 case WebConsoleMessage::LevelWarning: | 1406 case WebConsoleMessage::LevelWarning: |
1401 log_severity = logging::LOG_WARNING; | 1407 log_severity = logging::LOG_WARNING; |
1402 break; | 1408 break; |
1403 case WebConsoleMessage::LevelError: | 1409 case WebConsoleMessage::LevelError: |
1404 log_severity = logging::LOG_ERROR; | 1410 log_severity = logging::LOG_ERROR; |
1405 break; | 1411 break; |
1406 default: | 1412 default: |
1407 NOTREACHED(); | 1413 NOTREACHED(); |
1408 } | 1414 } |
1409 | 1415 |
1410 Send(new ViewHostMsg_AddMessageToConsole(routing_id_, | 1416 Send(new ViewHostMsg_AddMessageToConsole(routing_id_, |
1411 static_cast<int32>(log_severity), | 1417 static_cast<int32>(log_severity), |
1412 message.text, | 1418 message.text, |
1413 static_cast<int32>(source_line), | 1419 static_cast<int32>(source_line), |
1414 source_name)); | 1420 source_name)); |
1415 } | 1421 } |
1416 | 1422 |
1417 void RenderView::printPage(WebFrame* frame) { | 1423 void RenderViewImpl::printPage(WebFrame* frame) { |
1418 FOR_EACH_OBSERVER(RenderViewObserver, observers_, PrintPage(frame)); | 1424 FOR_EACH_OBSERVER(RenderViewObserver, observers_, PrintPage(frame)); |
1419 } | 1425 } |
1420 | 1426 |
1421 WebKit::WebNotificationPresenter* RenderView::notificationPresenter() { | 1427 WebKit::WebNotificationPresenter* RenderViewImpl::notificationPresenter() { |
1422 return notification_provider_; | 1428 return notification_provider_; |
1423 } | 1429 } |
1424 | 1430 |
1425 bool RenderView::enumerateChosenDirectory( | 1431 bool RenderViewImpl::enumerateChosenDirectory( |
1426 const WebString& path, | 1432 const WebString& path, |
1427 WebFileChooserCompletion* chooser_completion) { | 1433 WebFileChooserCompletion* chooser_completion) { |
1428 int id = enumeration_completion_id_++; | 1434 int id = enumeration_completion_id_++; |
1429 enumeration_completions_[id] = chooser_completion; | 1435 enumeration_completions_[id] = chooser_completion; |
1430 return Send(new ViewHostMsg_EnumerateDirectory( | 1436 return Send(new ViewHostMsg_EnumerateDirectory( |
1431 routing_id_, | 1437 routing_id_, |
1432 id, | 1438 id, |
1433 webkit_glue::WebStringToFilePath(path))); | 1439 webkit_glue::WebStringToFilePath(path))); |
1434 } | 1440 } |
1435 | 1441 |
1436 void RenderView::didStartLoading() { | 1442 void RenderViewImpl::didStartLoading() { |
1437 if (is_loading_) { | 1443 if (is_loading_) { |
1438 DLOG(WARNING) << "didStartLoading called while loading"; | 1444 DLOG(WARNING) << "didStartLoading called while loading"; |
1439 return; | 1445 return; |
1440 } | 1446 } |
1441 | 1447 |
1442 is_loading_ = true; | 1448 is_loading_ = true; |
1443 | 1449 |
1444 Send(new ViewHostMsg_DidStartLoading(routing_id_)); | 1450 Send(new ViewHostMsg_DidStartLoading(routing_id_)); |
1445 | 1451 |
1446 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStartLoading()); | 1452 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStartLoading()); |
1447 } | 1453 } |
1448 | 1454 |
1449 void RenderView::didStopLoading() { | 1455 void RenderViewImpl::didStopLoading() { |
1450 if (!is_loading_) { | 1456 if (!is_loading_) { |
1451 DLOG(WARNING) << "DidStopLoading called while not loading"; | 1457 DLOG(WARNING) << "DidStopLoading called while not loading"; |
1452 return; | 1458 return; |
1453 } | 1459 } |
1454 | 1460 |
1455 is_loading_ = false; | 1461 is_loading_ = false; |
1456 | 1462 |
1457 // NOTE: For now we're doing the safest thing, and sending out notification | 1463 // NOTE: For now we're doing the safest thing, and sending out notification |
1458 // when done loading. This currently isn't an issue as the favicon is only | 1464 // when done loading. This currently isn't an issue as the favicon is only |
1459 // displayed when done loading. Ideally we would send notification when | 1465 // displayed when done loading. Ideally we would send notification when |
1460 // finished parsing the head, but webkit doesn't support that yet. | 1466 // finished parsing the head, but webkit doesn't support that yet. |
1461 // The feed discovery code would also benefit from access to the head. | 1467 // The feed discovery code would also benefit from access to the head. |
1462 Send(new ViewHostMsg_DidStopLoading(routing_id_)); | 1468 Send(new ViewHostMsg_DidStopLoading(routing_id_)); |
1463 | 1469 |
1464 if (load_progress_tracker_ != NULL) | 1470 if (load_progress_tracker_ != NULL) |
1465 load_progress_tracker_->DidStopLoading(); | 1471 load_progress_tracker_->DidStopLoading(); |
1466 | 1472 |
1467 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); | 1473 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); |
1468 } | 1474 } |
1469 | 1475 |
1470 void RenderView::didChangeLoadProgress(WebFrame* frame, double load_progress) { | 1476 void RenderViewImpl::didChangeLoadProgress(WebFrame* frame, |
| 1477 double load_progress) { |
1471 if (load_progress_tracker_ != NULL) | 1478 if (load_progress_tracker_ != NULL) |
1472 load_progress_tracker_->DidChangeLoadProgress(frame, load_progress); | 1479 load_progress_tracker_->DidChangeLoadProgress(frame, load_progress); |
1473 } | 1480 } |
1474 | 1481 |
1475 bool RenderView::isSmartInsertDeleteEnabled() { | 1482 bool RenderViewImpl::isSmartInsertDeleteEnabled() { |
1476 #if defined(OS_MACOSX) | 1483 #if defined(OS_MACOSX) |
1477 return true; | 1484 return true; |
1478 #else | 1485 #else |
1479 return false; | 1486 return false; |
1480 #endif | 1487 #endif |
1481 } | 1488 } |
1482 | 1489 |
1483 bool RenderView::isSelectTrailingWhitespaceEnabled() { | 1490 bool RenderViewImpl::isSelectTrailingWhitespaceEnabled() { |
1484 #if defined(OS_WIN) | 1491 #if defined(OS_WIN) |
1485 return true; | 1492 return true; |
1486 #else | 1493 #else |
1487 return false; | 1494 return false; |
1488 #endif | 1495 #endif |
1489 } | 1496 } |
1490 | 1497 |
1491 void RenderView::didChangeSelection(bool is_empty_selection) { | 1498 void RenderViewImpl::didChangeSelection(bool is_empty_selection) { |
1492 #if defined(OS_POSIX) | 1499 #if defined(OS_POSIX) |
1493 if (!handling_input_event_ && !handling_select_range_) | 1500 if (!handling_input_event_ && !handling_select_range_) |
1494 return; | 1501 return; |
1495 handling_select_range_ = false; | 1502 handling_select_range_ = false; |
1496 | 1503 |
1497 SyncSelectionIfRequired(); | 1504 SyncSelectionIfRequired(); |
1498 #endif // defined(OS_POSIX) | 1505 #endif // defined(OS_POSIX) |
1499 } | 1506 } |
1500 | 1507 |
1501 void RenderView::didExecuteCommand(const WebString& command_name) { | 1508 void RenderViewImpl::didExecuteCommand(const WebString& command_name) { |
1502 const std::string& name = UTF16ToUTF8(command_name); | 1509 const std::string& name = UTF16ToUTF8(command_name); |
1503 if (StartsWithASCII(name, "Move", true) || | 1510 if (StartsWithASCII(name, "Move", true) || |
1504 StartsWithASCII(name, "Insert", true) || | 1511 StartsWithASCII(name, "Insert", true) || |
1505 StartsWithASCII(name, "Delete", true)) | 1512 StartsWithASCII(name, "Delete", true)) |
1506 return; | 1513 return; |
1507 RenderThreadImpl::current()->RecordUserMetrics(name); | 1514 RenderThreadImpl::current()->RecordUserMetrics(name); |
1508 } | 1515 } |
1509 | 1516 |
1510 bool RenderView::handleCurrentKeyboardEvent() { | 1517 bool RenderViewImpl::handleCurrentKeyboardEvent() { |
1511 if (edit_commands_.empty()) | 1518 if (edit_commands_.empty()) |
1512 return false; | 1519 return false; |
1513 | 1520 |
1514 WebFrame* frame = webview()->focusedFrame(); | 1521 WebFrame* frame = webview()->focusedFrame(); |
1515 if (!frame) | 1522 if (!frame) |
1516 return false; | 1523 return false; |
1517 | 1524 |
1518 EditCommands::iterator it = edit_commands_.begin(); | 1525 EditCommands::iterator it = edit_commands_.begin(); |
1519 EditCommands::iterator end = edit_commands_.end(); | 1526 EditCommands::iterator end = edit_commands_.end(); |
1520 | 1527 |
1521 bool did_execute_command = false; | 1528 bool did_execute_command = false; |
1522 for (; it != end; ++it) { | 1529 for (; it != end; ++it) { |
1523 // In gtk and cocoa, it's possible to bind multiple edit commands to one | 1530 // In gtk and cocoa, it's possible to bind multiple edit commands to one |
1524 // key (but it's the exception). Once one edit command is not executed, it | 1531 // key (but it's the exception). Once one edit command is not executed, it |
1525 // seems safest to not execute the rest. | 1532 // seems safest to not execute the rest. |
1526 if (!frame->executeCommand(WebString::fromUTF8(it->name), | 1533 if (!frame->executeCommand(WebString::fromUTF8(it->name), |
1527 WebString::fromUTF8(it->value))) | 1534 WebString::fromUTF8(it->value))) |
1528 break; | 1535 break; |
1529 did_execute_command = true; | 1536 did_execute_command = true; |
1530 } | 1537 } |
1531 | 1538 |
1532 return did_execute_command; | 1539 return did_execute_command; |
1533 } | 1540 } |
1534 | 1541 |
1535 bool RenderView::runFileChooser( | 1542 bool RenderViewImpl::runFileChooser( |
1536 const WebKit::WebFileChooserParams& params, | 1543 const WebKit::WebFileChooserParams& params, |
1537 WebFileChooserCompletion* chooser_completion) { | 1544 WebFileChooserCompletion* chooser_completion) { |
1538 // Do not open the file dialog in a hidden RenderView. | 1545 // Do not open the file dialog in a hidden RenderView. |
1539 if (is_hidden()) | 1546 if (is_hidden()) |
1540 return false; | 1547 return false; |
1541 ViewHostMsg_RunFileChooser_Params ipc_params; | 1548 ViewHostMsg_RunFileChooser_Params ipc_params; |
1542 if (params.directory) | 1549 if (params.directory) |
1543 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::OpenFolder; | 1550 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::OpenFolder; |
1544 else if (params.multiSelect) | 1551 else if (params.multiSelect) |
1545 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::OpenMultiple; | 1552 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::OpenMultiple; |
1546 else | 1553 else |
1547 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::Open; | 1554 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::Open; |
1548 ipc_params.title = params.title; | 1555 ipc_params.title = params.title; |
1549 ipc_params.default_file_name = | 1556 ipc_params.default_file_name = |
1550 webkit_glue::WebStringToFilePath(params.initialValue); | 1557 webkit_glue::WebStringToFilePath(params.initialValue); |
1551 ipc_params.accept_types = params.acceptTypes; | 1558 ipc_params.accept_types = params.acceptTypes; |
1552 | 1559 |
1553 return ScheduleFileChooser(ipc_params, chooser_completion); | 1560 return ScheduleFileChooser(ipc_params, chooser_completion); |
1554 } | 1561 } |
1555 | 1562 |
1556 void RenderView::runModalAlertDialog( | 1563 void RenderViewImpl::runModalAlertDialog( |
1557 WebFrame* frame, const WebString& message) { | 1564 WebFrame* frame, const WebString& message) { |
1558 RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptAlert, | 1565 RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptAlert, |
1559 message, | 1566 message, |
1560 string16(), | 1567 string16(), |
1561 frame->document().url(), | 1568 frame->document().url(), |
1562 NULL); | 1569 NULL); |
1563 } | 1570 } |
1564 | 1571 |
1565 bool RenderView::runModalConfirmDialog( | 1572 bool RenderViewImpl::runModalConfirmDialog( |
1566 WebFrame* frame, const WebString& message) { | 1573 WebFrame* frame, const WebString& message) { |
1567 return RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptConfirm, | 1574 return RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptConfirm, |
1568 message, | 1575 message, |
1569 string16(), | 1576 string16(), |
1570 frame->document().url(), | 1577 frame->document().url(), |
1571 NULL); | 1578 NULL); |
1572 } | 1579 } |
1573 | 1580 |
1574 bool RenderView::runModalPromptDialog( | 1581 bool RenderViewImpl::runModalPromptDialog( |
1575 WebFrame* frame, const WebString& message, const WebString& default_value, | 1582 WebFrame* frame, const WebString& message, const WebString& default_value, |
1576 WebString* actual_value) { | 1583 WebString* actual_value) { |
1577 string16 result; | 1584 string16 result; |
1578 bool ok = RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptPrompt, | 1585 bool ok = RunJavaScriptMessage(ui::MessageBoxFlags::kIsJavascriptPrompt, |
1579 message, | 1586 message, |
1580 default_value, | 1587 default_value, |
1581 frame->document().url(), | 1588 frame->document().url(), |
1582 &result); | 1589 &result); |
1583 if (ok) | 1590 if (ok) |
1584 actual_value->assign(result); | 1591 actual_value->assign(result); |
1585 return ok; | 1592 return ok; |
1586 } | 1593 } |
1587 | 1594 |
1588 bool RenderView::runModalBeforeUnloadDialog( | 1595 bool RenderViewImpl::runModalBeforeUnloadDialog( |
1589 WebFrame* frame, const WebString& message) { | 1596 WebFrame* frame, const WebString& message) { |
1590 // If we are swapping out, we have already run the beforeunload handler. | 1597 // If we are swapping out, we have already run the beforeunload handler. |
1591 // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload | 1598 // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload |
1592 // at all, to avoid running it twice. | 1599 // at all, to avoid running it twice. |
1593 if (is_swapped_out_) | 1600 if (is_swapped_out_) |
1594 return true; | 1601 return true; |
1595 | 1602 |
1596 bool success = false; | 1603 bool success = false; |
1597 // This is an ignored return value, but is included so we can accept the same | 1604 // This is an ignored return value, but is included so we can accept the same |
1598 // response as RunJavaScriptMessage. | 1605 // response as RunJavaScriptMessage. |
1599 string16 ignored_result; | 1606 string16 ignored_result; |
1600 SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( | 1607 SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( |
1601 routing_id_, frame->document().url(), message, | 1608 routing_id_, frame->document().url(), message, |
1602 &success, &ignored_result)); | 1609 &success, &ignored_result)); |
1603 return success; | 1610 return success; |
1604 } | 1611 } |
1605 | 1612 |
1606 void RenderView::showContextMenu( | 1613 void RenderViewImpl::showContextMenu( |
1607 WebFrame* frame, const WebContextMenuData& data) { | 1614 WebFrame* frame, const WebContextMenuData& data) { |
1608 ContextMenuParams params = ContextMenuParams(data); | 1615 ContextMenuParams params = ContextMenuParams(data); |
1609 | 1616 |
1610 // frame is NULL if invoked by BlockedPlugin. | 1617 // frame is NULL if invoked by BlockedPlugin. |
1611 if (frame) | 1618 if (frame) |
1612 params.frame_id = frame->identifier(); | 1619 params.frame_id = frame->identifier(); |
1613 | 1620 |
1614 // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do | 1621 // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do |
1615 // it. We replace it with an empty GURL so the appropriate items are disabled | 1622 // it. We replace it with an empty GURL so the appropriate items are disabled |
1616 // in the context menu. | 1623 // in the context menu. |
1617 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large | 1624 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large |
1618 // data encoded images. We should have a way to save them. | 1625 // data encoded images. We should have a way to save them. |
1619 if (params.src_url.spec().size() > content::kMaxURLChars) | 1626 if (params.src_url.spec().size() > content::kMaxURLChars) |
1620 params.src_url = GURL(); | 1627 params.src_url = GURL(); |
1621 context_menu_node_ = data.node; | 1628 context_menu_node_ = data.node; |
1622 Send(new ViewHostMsg_ContextMenu(routing_id_, params)); | 1629 Send(new ViewHostMsg_ContextMenu(routing_id_, params)); |
1623 } | 1630 } |
1624 | 1631 |
1625 bool RenderView::supportsFullscreen() { | 1632 bool RenderViewImpl::supportsFullscreen() { |
1626 return CommandLine::ForCurrentProcess()->HasSwitch( | 1633 return CommandLine::ForCurrentProcess()->HasSwitch( |
1627 switches::kEnableVideoFullscreen); | 1634 switches::kEnableVideoFullscreen); |
1628 } | 1635 } |
1629 | 1636 |
1630 void RenderView::enterFullscreenForNode(const WebKit::WebNode& node) { | 1637 void RenderViewImpl::enterFullscreenForNode(const WebKit::WebNode& node) { |
1631 NOTIMPLEMENTED(); | 1638 NOTIMPLEMENTED(); |
1632 } | 1639 } |
1633 | 1640 |
1634 void RenderView::exitFullscreenForNode(const WebKit::WebNode& node) { | 1641 void RenderViewImpl::exitFullscreenForNode(const WebKit::WebNode& node) { |
1635 NOTIMPLEMENTED(); | 1642 NOTIMPLEMENTED(); |
1636 } | 1643 } |
1637 | 1644 |
1638 void RenderView::enterFullscreen() { | 1645 void RenderViewImpl::enterFullscreen() { |
1639 Send(new ViewHostMsg_ToggleFullscreen(routing_id_, true)); | 1646 Send(new ViewHostMsg_ToggleFullscreen(routing_id_, true)); |
1640 } | 1647 } |
1641 | 1648 |
1642 void RenderView::exitFullscreen() { | 1649 void RenderViewImpl::exitFullscreen() { |
1643 Send(new ViewHostMsg_ToggleFullscreen(routing_id_, false)); | 1650 Send(new ViewHostMsg_ToggleFullscreen(routing_id_, false)); |
1644 } | 1651 } |
1645 | 1652 |
1646 void RenderView::setStatusText(const WebString& text) { | 1653 void RenderViewImpl::setStatusText(const WebString& text) { |
1647 } | 1654 } |
1648 | 1655 |
1649 void RenderView::UpdateTargetURL(const GURL& url, const GURL& fallback_url) { | 1656 void RenderViewImpl::UpdateTargetURL(const GURL& url, |
| 1657 const GURL& fallback_url) { |
1650 GURL latest_url = url.is_empty() ? fallback_url : url; | 1658 GURL latest_url = url.is_empty() ? fallback_url : url; |
1651 if (latest_url == target_url_) | 1659 if (latest_url == target_url_) |
1652 return; | 1660 return; |
1653 | 1661 |
1654 // Tell the browser to display a destination link. | 1662 // Tell the browser to display a destination link. |
1655 if (target_url_status_ == TARGET_INFLIGHT || | 1663 if (target_url_status_ == TARGET_INFLIGHT || |
1656 target_url_status_ == TARGET_PENDING) { | 1664 target_url_status_ == TARGET_PENDING) { |
1657 // If we have a request in-flight, save the URL to be sent when we | 1665 // If we have a request in-flight, save the URL to be sent when we |
1658 // receive an ACK to the in-flight request. We can happily overwrite | 1666 // receive an ACK to the in-flight request. We can happily overwrite |
1659 // any existing pending sends. | 1667 // any existing pending sends. |
1660 pending_target_url_ = latest_url; | 1668 pending_target_url_ = latest_url; |
1661 target_url_status_ = TARGET_PENDING; | 1669 target_url_status_ = TARGET_PENDING; |
1662 } else { | 1670 } else { |
1663 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, latest_url)); | 1671 Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, latest_url)); |
1664 target_url_ = latest_url; | 1672 target_url_ = latest_url; |
1665 target_url_status_ = TARGET_INFLIGHT; | 1673 target_url_status_ = TARGET_INFLIGHT; |
1666 } | 1674 } |
1667 } | 1675 } |
1668 | 1676 |
1669 void RenderView::StartNavStateSyncTimerIfNecessary() { | 1677 void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { |
1670 int delay; | 1678 int delay; |
1671 if (send_content_state_immediately_) | 1679 if (send_content_state_immediately_) |
1672 delay = 0; | 1680 delay = 0; |
1673 else if (is_hidden()) | 1681 else if (is_hidden()) |
1674 delay = kDelaySecondsForContentStateSyncHidden; | 1682 delay = kDelaySecondsForContentStateSyncHidden; |
1675 else | 1683 else |
1676 delay = kDelaySecondsForContentStateSync; | 1684 delay = kDelaySecondsForContentStateSync; |
1677 | 1685 |
1678 if (nav_state_sync_timer_.IsRunning()) { | 1686 if (nav_state_sync_timer_.IsRunning()) { |
1679 // The timer is already running. If the delay of the timer maches the amount | 1687 // The timer is already running. If the delay of the timer maches the amount |
1680 // we want to delay by, then return. Otherwise stop the timer so that it | 1688 // we want to delay by, then return. Otherwise stop the timer so that it |
1681 // gets started with the right delay. | 1689 // gets started with the right delay. |
1682 if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) | 1690 if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) |
1683 return; | 1691 return; |
1684 nav_state_sync_timer_.Stop(); | 1692 nav_state_sync_timer_.Stop(); |
1685 } | 1693 } |
1686 | 1694 |
1687 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, | 1695 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
1688 &RenderView::SyncNavigationState); | 1696 &RenderViewImpl::SyncNavigationState); |
1689 } | 1697 } |
1690 | 1698 |
1691 void RenderView::setMouseOverURL(const WebURL& url) { | 1699 void RenderViewImpl::setMouseOverURL(const WebURL& url) { |
1692 mouse_over_url_ = GURL(url); | 1700 mouse_over_url_ = GURL(url); |
1693 UpdateTargetURL(mouse_over_url_, focus_url_); | 1701 UpdateTargetURL(mouse_over_url_, focus_url_); |
1694 } | 1702 } |
1695 | 1703 |
1696 void RenderView::setKeyboardFocusURL(const WebURL& url) { | 1704 void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) { |
1697 focus_url_ = GURL(url); | 1705 focus_url_ = GURL(url); |
1698 UpdateTargetURL(focus_url_, mouse_over_url_); | 1706 UpdateTargetURL(focus_url_, mouse_over_url_); |
1699 } | 1707 } |
1700 | 1708 |
1701 void RenderView::startDragging(const WebDragData& data, | 1709 void RenderViewImpl::startDragging(const WebDragData& data, |
1702 WebDragOperationsMask mask, | 1710 WebDragOperationsMask mask, |
1703 const WebImage& image, | 1711 const WebImage& image, |
1704 const WebPoint& imageOffset) { | 1712 const WebPoint& imageOffset) { |
1705 #if WEBKIT_USING_SKIA | 1713 #if WEBKIT_USING_SKIA |
1706 SkBitmap bitmap(image.getSkBitmap()); | 1714 SkBitmap bitmap(image.getSkBitmap()); |
1707 #elif WEBKIT_USING_CG | 1715 #elif WEBKIT_USING_CG |
1708 SkBitmap bitmap = gfx::CGImageToSkBitmap(image.getCGImageRef()); | 1716 SkBitmap bitmap = gfx::CGImageToSkBitmap(image.getCGImageRef()); |
1709 #endif | 1717 #endif |
1710 | 1718 |
1711 Send(new DragHostMsg_StartDragging(routing_id_, | 1719 Send(new DragHostMsg_StartDragging(routing_id_, |
1712 WebDropData(data), | 1720 WebDropData(data), |
1713 mask, | 1721 mask, |
1714 bitmap, | 1722 bitmap, |
1715 imageOffset)); | 1723 imageOffset)); |
1716 } | 1724 } |
1717 | 1725 |
1718 bool RenderView::acceptsLoadDrops() { | 1726 bool RenderViewImpl::acceptsLoadDrops() { |
1719 return renderer_preferences_.can_accept_load_drops; | 1727 return renderer_preferences_.can_accept_load_drops; |
1720 } | 1728 } |
1721 | 1729 |
1722 void RenderView::focusNext() { | 1730 void RenderViewImpl::focusNext() { |
1723 Send(new ViewHostMsg_TakeFocus(routing_id_, false)); | 1731 Send(new ViewHostMsg_TakeFocus(routing_id_, false)); |
1724 } | 1732 } |
1725 | 1733 |
1726 void RenderView::focusPrevious() { | 1734 void RenderViewImpl::focusPrevious() { |
1727 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); | 1735 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); |
1728 } | 1736 } |
1729 | 1737 |
1730 void RenderView::focusedNodeChanged(const WebNode& node) { | 1738 void RenderViewImpl::focusedNodeChanged(const WebNode& node) { |
1731 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); | 1739 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); |
1732 | 1740 |
1733 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); | 1741 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
1734 } | 1742 } |
1735 | 1743 |
1736 void RenderView::navigateBackForwardSoon(int offset) { | 1744 void RenderViewImpl::navigateBackForwardSoon(int offset) { |
1737 Send(new ViewHostMsg_GoToEntryAtOffset(routing_id_, offset)); | 1745 Send(new ViewHostMsg_GoToEntryAtOffset(routing_id_, offset)); |
1738 } | 1746 } |
1739 | 1747 |
1740 int RenderView::historyBackListCount() { | 1748 int RenderViewImpl::historyBackListCount() { |
1741 return history_list_offset_ < 0 ? 0 : history_list_offset_; | 1749 return history_list_offset_ < 0 ? 0 : history_list_offset_; |
1742 } | 1750 } |
1743 | 1751 |
1744 int RenderView::historyForwardListCount() { | 1752 int RenderViewImpl::historyForwardListCount() { |
1745 return history_list_length_ - historyBackListCount() - 1; | 1753 return history_list_length_ - historyBackListCount() - 1; |
1746 } | 1754 } |
1747 | 1755 |
1748 void RenderView::postAccessibilityNotification( | 1756 void RenderViewImpl::postAccessibilityNotification( |
1749 const WebAccessibilityObject& obj, | 1757 const WebAccessibilityObject& obj, |
1750 WebAccessibilityNotification notification) { | 1758 WebAccessibilityNotification notification) { |
1751 renderer_accessibility_->PostAccessibilityNotification(obj, notification); | 1759 renderer_accessibility_->PostAccessibilityNotification(obj, notification); |
1752 } | 1760 } |
1753 | 1761 |
1754 void RenderView::didUpdateInspectorSetting(const WebString& key, | 1762 void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, |
1755 const WebString& value) { | 1763 const WebString& value) { |
1756 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, | 1764 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, |
1757 key.utf8(), | 1765 key.utf8(), |
1758 value.utf8())); | 1766 value.utf8())); |
1759 } | 1767 } |
1760 | 1768 |
1761 // WebKit::WebWidgetClient ---------------------------------------------------- | 1769 // WebKit::WebWidgetClient ---------------------------------------------------- |
1762 | 1770 |
1763 void RenderView::didFocus() { | 1771 void RenderViewImpl::didFocus() { |
1764 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed | 1772 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
1765 // we won't have to test for user gesture anymore and we can | 1773 // we won't have to test for user gesture anymore and we can |
1766 // move that code back to render_widget.cc | 1774 // move that code back to render_widget.cc |
1767 if (webview() && webview()->mainFrame() && | 1775 if (webview() && webview()->mainFrame() && |
1768 webview()->mainFrame()->isProcessingUserGesture()) { | 1776 webview()->mainFrame()->isProcessingUserGesture()) { |
1769 Send(new ViewHostMsg_Focus(routing_id_)); | 1777 Send(new ViewHostMsg_Focus(routing_id_)); |
1770 } | 1778 } |
1771 } | 1779 } |
1772 | 1780 |
1773 void RenderView::didBlur() { | 1781 void RenderViewImpl::didBlur() { |
1774 // TODO(jcivelli): see TODO above in didFocus(). | 1782 // TODO(jcivelli): see TODO above in didFocus(). |
1775 if (webview() && webview()->mainFrame() && | 1783 if (webview() && webview()->mainFrame() && |
1776 webview()->mainFrame()->isProcessingUserGesture()) { | 1784 webview()->mainFrame()->isProcessingUserGesture()) { |
1777 Send(new ViewHostMsg_Blur(routing_id_)); | 1785 Send(new ViewHostMsg_Blur(routing_id_)); |
1778 } | 1786 } |
1779 } | 1787 } |
1780 | 1788 |
1781 // We are supposed to get a single call to Show for a newly created RenderView | 1789 // We are supposed to get a single call to Show for a newly created RenderView |
1782 // that was created via RenderView::CreateWebView. So, we wait until this | 1790 // that was created via RenderViewImpl::CreateWebView. So, we wait until this |
1783 // point to dispatch the ShowView message. | 1791 // point to dispatch the ShowView message. |
1784 // | 1792 // |
1785 // This method provides us with the information about how to display the newly | 1793 // This method provides us with the information about how to display the newly |
1786 // created RenderView (i.e., as a blocked popup or as a new tab). | 1794 // created RenderView (i.e., as a blocked popup or as a new tab). |
1787 // | 1795 // |
1788 void RenderView::show(WebNavigationPolicy policy) { | 1796 void RenderViewImpl::show(WebNavigationPolicy policy) { |
1789 DCHECK(!did_show_) << "received extraneous Show call"; | 1797 DCHECK(!did_show_) << "received extraneous Show call"; |
1790 DCHECK(opener_id_ != MSG_ROUTING_NONE); | 1798 DCHECK(opener_id_ != MSG_ROUTING_NONE); |
1791 | 1799 |
1792 if (did_show_) | 1800 if (did_show_) |
1793 return; | 1801 return; |
1794 did_show_ = true; | 1802 did_show_ = true; |
1795 | 1803 |
1796 if (content::GetContentClient()->renderer()->AllowPopup(creator_url_)) | 1804 if (content::GetContentClient()->renderer()->AllowPopup(creator_url_)) |
1797 opened_by_user_gesture_ = true; | 1805 opened_by_user_gesture_ = true; |
1798 | 1806 |
1799 // Force new windows to a popup if they were not opened with a user gesture. | 1807 // Force new windows to a popup if they were not opened with a user gesture. |
1800 if (!opened_by_user_gesture_) { | 1808 if (!opened_by_user_gesture_) { |
1801 // We exempt background tabs for compat with older versions of Chrome. | 1809 // We exempt background tabs for compat with older versions of Chrome. |
1802 // TODO(darin): This seems bogus. These should have a user gesture, so | 1810 // TODO(darin): This seems bogus. These should have a user gesture, so |
1803 // we probably don't need this check. | 1811 // we probably don't need this check. |
1804 if (policy != WebKit::WebNavigationPolicyNewBackgroundTab) | 1812 if (policy != WebKit::WebNavigationPolicyNewBackgroundTab) |
1805 policy = WebKit::WebNavigationPolicyNewPopup; | 1813 policy = WebKit::WebNavigationPolicyNewPopup; |
1806 } | 1814 } |
1807 | 1815 |
1808 // NOTE: initial_pos_ may still have its default values at this point, but | 1816 // NOTE: initial_pos_ may still have its default values at this point, but |
1809 // that's okay. It'll be ignored if disposition is not NEW_POPUP, or the | 1817 // that's okay. It'll be ignored if disposition is not NEW_POPUP, or the |
1810 // browser process will impose a default position otherwise. | 1818 // browser process will impose a default position otherwise. |
1811 Send(new ViewHostMsg_ShowView(opener_id_, routing_id_, | 1819 Send(new ViewHostMsg_ShowView(opener_id_, routing_id_, |
1812 NavigationPolicyToDisposition(policy), initial_pos_, | 1820 NavigationPolicyToDisposition(policy), initial_pos_, |
1813 opened_by_user_gesture_)); | 1821 opened_by_user_gesture_)); |
1814 SetPendingWindowRect(initial_pos_); | 1822 SetPendingWindowRect(initial_pos_); |
1815 } | 1823 } |
1816 | 1824 |
1817 void RenderView::runModal() { | 1825 void RenderViewImpl::runModal() { |
1818 DCHECK(did_show_) << "should already have shown the view"; | 1826 DCHECK(did_show_) << "should already have shown the view"; |
1819 | 1827 |
1820 // We must keep WebKit's shared timer running in this case in order to allow | 1828 // We must keep WebKit's shared timer running in this case in order to allow |
1821 // showModalDialog to function properly. | 1829 // showModalDialog to function properly. |
1822 // | 1830 // |
1823 // TODO(darin): WebKit should really be smarter about suppressing events and | 1831 // TODO(darin): WebKit should really be smarter about suppressing events and |
1824 // timers so that we do not need to manage the shared timer in such a heavy | 1832 // timers so that we do not need to manage the shared timer in such a heavy |
1825 // handed manner. | 1833 // handed manner. |
1826 // | 1834 // |
1827 if (RenderThreadImpl::current()) // Will be NULL during unit tests. | 1835 if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
1828 RenderThreadImpl::current()->DoNotSuspendWebKitSharedTimer(); | 1836 RenderThreadImpl::current()->DoNotSuspendWebKitSharedTimer(); |
1829 | 1837 |
1830 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); | 1838 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); |
1831 } | 1839 } |
1832 | 1840 |
1833 // WebKit::WebFrameClient ----------------------------------------------------- | 1841 // WebKit::WebFrameClient ----------------------------------------------------- |
1834 | 1842 |
1835 WebPlugin* RenderView::createPlugin(WebFrame* frame, | 1843 WebPlugin* RenderViewImpl::createPlugin(WebFrame* frame, |
1836 const WebPluginParams& params) { | 1844 const WebPluginParams& params) { |
1837 WebPlugin* plugin = NULL; | 1845 WebPlugin* plugin = NULL; |
1838 if (content::GetContentClient()->renderer()->OverrideCreatePlugin( | 1846 if (content::GetContentClient()->renderer()->OverrideCreatePlugin( |
1839 this, frame, params, &plugin)) { | 1847 this, frame, params, &plugin)) { |
1840 return plugin; | 1848 return plugin; |
1841 } | 1849 } |
1842 | 1850 |
1843 webkit::WebPluginInfo info; | 1851 webkit::WebPluginInfo info; |
1844 std::string mime_type; | 1852 std::string mime_type; |
1845 bool found = GetPluginInfo(params.url, frame->top()->document().url(), | 1853 bool found = GetPluginInfo(params.url, frame->top()->document().url(), |
1846 params.mimeType.utf8(), &info, &mime_type); | 1854 params.mimeType.utf8(), &info, &mime_type); |
1847 if (!found) | 1855 if (!found) |
1848 return NULL; | 1856 return NULL; |
1849 | 1857 |
1850 WebPluginParams params_to_use = params; | 1858 WebPluginParams params_to_use = params; |
1851 params_to_use.mimeType = WebString::fromUTF8(mime_type); | 1859 params_to_use.mimeType = WebString::fromUTF8(mime_type); |
1852 return CreatePlugin(frame, info, params_to_use); | 1860 return CreatePlugin(frame, info, params_to_use); |
1853 } | 1861 } |
1854 | 1862 |
1855 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { | 1863 WebWorker* RenderViewImpl::createWorker(WebFrame* frame, |
| 1864 WebWorkerClient* client) { |
1856 WebApplicationCacheHostImpl* appcache_host = | 1865 WebApplicationCacheHostImpl* appcache_host = |
1857 WebApplicationCacheHostImpl::FromFrame(frame); | 1866 WebApplicationCacheHostImpl::FromFrame(frame); |
1858 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; | 1867 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; |
1859 return new WebWorkerProxy(client, RenderThreadImpl::current(), routing_id_, | 1868 return new WebWorkerProxy(client, RenderThreadImpl::current(), routing_id_, |
1860 appcache_host_id); | 1869 appcache_host_id); |
1861 } | 1870 } |
1862 | 1871 |
1863 WebSharedWorker* RenderView::createSharedWorker( | 1872 WebSharedWorker* RenderViewImpl::createSharedWorker( |
1864 WebFrame* frame, const WebURL& url, const WebString& name, | 1873 WebFrame* frame, const WebURL& url, const WebString& name, |
1865 unsigned long long document_id) { | 1874 unsigned long long document_id) { |
1866 | 1875 |
1867 int route_id = MSG_ROUTING_NONE; | 1876 int route_id = MSG_ROUTING_NONE; |
1868 bool exists = false; | 1877 bool exists = false; |
1869 bool url_mismatch = false; | 1878 bool url_mismatch = false; |
1870 ViewHostMsg_CreateWorker_Params params; | 1879 ViewHostMsg_CreateWorker_Params params; |
1871 params.url = url; | 1880 params.url = url; |
1872 params.is_shared = true; | 1881 params.is_shared = true; |
1873 params.name = name; | 1882 params.name = name; |
1874 params.document_id = document_id; | 1883 params.document_id = document_id; |
1875 params.render_view_route_id = routing_id_; | 1884 params.render_view_route_id = routing_id_; |
1876 params.route_id = MSG_ROUTING_NONE; | 1885 params.route_id = MSG_ROUTING_NONE; |
1877 params.parent_appcache_host_id = 0; | 1886 params.parent_appcache_host_id = 0; |
1878 params.script_resource_appcache_id = 0; | 1887 params.script_resource_appcache_id = 0; |
1879 Send(new ViewHostMsg_LookupSharedWorker( | 1888 Send(new ViewHostMsg_LookupSharedWorker( |
1880 params, &exists, &route_id, &url_mismatch)); | 1889 params, &exists, &route_id, &url_mismatch)); |
1881 if (url_mismatch) { | 1890 if (url_mismatch) { |
1882 return NULL; | 1891 return NULL; |
1883 } else { | 1892 } else { |
1884 return new WebSharedWorkerProxy(RenderThreadImpl::current(), | 1893 return new WebSharedWorkerProxy(RenderThreadImpl::current(), |
1885 document_id, | 1894 document_id, |
1886 exists, | 1895 exists, |
1887 route_id, | 1896 route_id, |
1888 routing_id_); | 1897 routing_id_); |
1889 } | 1898 } |
1890 } | 1899 } |
1891 | 1900 |
1892 WebMediaPlayer* RenderView::createMediaPlayer( | 1901 WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
1893 WebFrame* frame, WebMediaPlayerClient* client) { | 1902 WebFrame* frame, WebMediaPlayerClient* client) { |
1894 FOR_EACH_OBSERVER( | 1903 FOR_EACH_OBSERVER( |
1895 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); | 1904 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); |
1896 | 1905 |
1897 scoped_ptr<media::MessageLoopFactory> message_loop_factory( | 1906 scoped_ptr<media::MessageLoopFactory> message_loop_factory( |
1898 new media::MessageLoopFactoryImpl()); | 1907 new media::MessageLoopFactoryImpl()); |
1899 scoped_ptr<media::FilterCollection> collection( | 1908 scoped_ptr<media::FilterCollection> collection( |
1900 new media::FilterCollection()); | 1909 new media::FilterCollection()); |
1901 | 1910 |
1902 // Add in any custom filter factories first. | 1911 // Add in any custom filter factories first. |
(...skipping 17 matching lines...) Expand all Loading... |
1920 media_stream_impl_.get(), | 1929 media_stream_impl_.get(), |
1921 new RenderMediaLog())); | 1930 new RenderMediaLog())); |
1922 if (!result->Initialize(frame, | 1931 if (!result->Initialize(frame, |
1923 cmd_line->HasSwitch(switches::kSimpleDataSource), | 1932 cmd_line->HasSwitch(switches::kSimpleDataSource), |
1924 video_renderer)) { | 1933 video_renderer)) { |
1925 return NULL; | 1934 return NULL; |
1926 } | 1935 } |
1927 return result.release(); | 1936 return result.release(); |
1928 } | 1937 } |
1929 | 1938 |
1930 WebApplicationCacheHost* RenderView::createApplicationCacheHost( | 1939 WebApplicationCacheHost* RenderViewImpl::createApplicationCacheHost( |
1931 WebFrame* frame, WebApplicationCacheHostClient* client) { | 1940 WebFrame* frame, WebApplicationCacheHostClient* client) { |
1932 return new RendererWebApplicationCacheHostImpl( | 1941 return new RendererWebApplicationCacheHostImpl( |
1933 FromWebView(frame->view()), client, | 1942 FromWebView(frame->view()), client, |
1934 RenderThreadImpl::current()->appcache_dispatcher()->backend_proxy()); | 1943 RenderThreadImpl::current()->appcache_dispatcher()->backend_proxy()); |
1935 } | 1944 } |
1936 | 1945 |
1937 WebCookieJar* RenderView::cookieJar(WebFrame* frame) { | 1946 WebCookieJar* RenderViewImpl::cookieJar(WebFrame* frame) { |
1938 return &cookie_jar_; | 1947 return &cookie_jar_; |
1939 } | 1948 } |
1940 | 1949 |
1941 void RenderView::frameDetached(WebFrame* frame) { | 1950 void RenderViewImpl::frameDetached(WebFrame* frame) { |
1942 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameDetached(frame)); | 1951 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameDetached(frame)); |
1943 } | 1952 } |
1944 | 1953 |
1945 void RenderView::willClose(WebFrame* frame) { | 1954 void RenderViewImpl::willClose(WebFrame* frame) { |
1946 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameWillClose(frame)); | 1955 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameWillClose(frame)); |
1947 } | 1956 } |
1948 | 1957 |
1949 void RenderView::loadURLExternally( | 1958 void RenderViewImpl::loadURLExternally( |
1950 WebFrame* frame, const WebURLRequest& request, | 1959 WebFrame* frame, const WebURLRequest& request, |
1951 WebNavigationPolicy policy) { | 1960 WebNavigationPolicy policy) { |
1952 loadURLExternally(frame, request, policy, WebString()); | 1961 loadURLExternally(frame, request, policy, WebString()); |
1953 } | 1962 } |
1954 | 1963 |
1955 void RenderView::loadURLExternally( | 1964 void RenderViewImpl::loadURLExternally( |
1956 WebFrame* frame, const WebURLRequest& request, | 1965 WebFrame* frame, const WebURLRequest& request, |
1957 WebNavigationPolicy policy, | 1966 WebNavigationPolicy policy, |
1958 const WebString& suggested_name) { | 1967 const WebString& suggested_name) { |
1959 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 1968 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); |
1960 if (policy == WebKit::WebNavigationPolicyDownload) { | 1969 if (policy == WebKit::WebNavigationPolicyDownload) { |
1961 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, | 1970 Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, |
1962 suggested_name)); | 1971 suggested_name)); |
1963 } else { | 1972 } else { |
1964 OpenURL(frame, request.url(), referrer, policy); | 1973 OpenURL(frame, request.url(), referrer, policy); |
1965 } | 1974 } |
1966 } | 1975 } |
1967 | 1976 |
1968 WebNavigationPolicy RenderView::decidePolicyForNavigation( | 1977 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
1969 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, | 1978 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, |
1970 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { | 1979 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { |
1971 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. | 1980 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. |
1972 if (is_swapped_out_) { | 1981 if (is_swapped_out_) { |
1973 DCHECK(request.url() == GURL("about:swappedout")); | 1982 DCHECK(request.url() == GURL("about:swappedout")); |
1974 return default_policy; | 1983 return default_policy; |
1975 } | 1984 } |
1976 | 1985 |
1977 // Webkit is asking whether to navigate to a new URL. | 1986 // Webkit is asking whether to navigate to a new URL. |
1978 // This is fine normally, except if we're showing UI from one security | 1987 // This is fine normally, except if we're showing UI from one security |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2109 | 2118 |
2110 if (is_fork || is_noreferrer_and_blank_target) { | 2119 if (is_fork || is_noreferrer_and_blank_target) { |
2111 // Open the URL via the browser, not via WebKit. | 2120 // Open the URL via the browser, not via WebKit. |
2112 OpenURL(frame, url, GURL(), default_policy); | 2121 OpenURL(frame, url, GURL(), default_policy); |
2113 return WebKit::WebNavigationPolicyIgnore; | 2122 return WebKit::WebNavigationPolicyIgnore; |
2114 } | 2123 } |
2115 | 2124 |
2116 return default_policy; | 2125 return default_policy; |
2117 } | 2126 } |
2118 | 2127 |
2119 bool RenderView::canHandleRequest( | 2128 bool RenderViewImpl::canHandleRequest( |
2120 WebFrame* frame, const WebURLRequest& request) { | 2129 WebFrame* frame, const WebURLRequest& request) { |
2121 // We allow WebKit to think that everything can be handled even though | 2130 // We allow WebKit to think that everything can be handled even though |
2122 // browser-side we limit what we load. | 2131 // browser-side we limit what we load. |
2123 return true; | 2132 return true; |
2124 } | 2133 } |
2125 | 2134 |
2126 WebURLError RenderView::cannotHandleRequestError( | 2135 WebURLError RenderViewImpl::cannotHandleRequestError( |
2127 WebFrame* frame, const WebURLRequest& request) { | 2136 WebFrame* frame, const WebURLRequest& request) { |
2128 NOTREACHED(); // Since we said we can handle all requests. | 2137 NOTREACHED(); // Since we said we can handle all requests. |
2129 return WebURLError(); | 2138 return WebURLError(); |
2130 } | 2139 } |
2131 | 2140 |
2132 WebURLError RenderView::cancelledError( | 2141 WebURLError RenderViewImpl::cancelledError( |
2133 WebFrame* frame, const WebURLRequest& request) { | 2142 WebFrame* frame, const WebURLRequest& request) { |
2134 WebURLError error; | 2143 WebURLError error; |
2135 error.domain = WebString::fromUTF8(net::kErrorDomain); | 2144 error.domain = WebString::fromUTF8(net::kErrorDomain); |
2136 error.reason = net::ERR_ABORTED; | 2145 error.reason = net::ERR_ABORTED; |
2137 error.unreachableURL = request.url(); | 2146 error.unreachableURL = request.url(); |
2138 return error; | 2147 return error; |
2139 } | 2148 } |
2140 | 2149 |
2141 void RenderView::unableToImplementPolicyWithError( | 2150 void RenderViewImpl::unableToImplementPolicyWithError( |
2142 WebFrame*, const WebURLError&) { | 2151 WebFrame*, const WebURLError&) { |
2143 NOTREACHED(); // Since we said we can handle all requests. | 2152 NOTREACHED(); // Since we said we can handle all requests. |
2144 } | 2153 } |
2145 | 2154 |
2146 void RenderView::willSendSubmitEvent(WebKit::WebFrame* frame, | 2155 void RenderViewImpl::willSendSubmitEvent(WebKit::WebFrame* frame, |
2147 const WebKit::WebFormElement& form) { | 2156 const WebKit::WebFormElement& form) { |
2148 // Some login forms have onSubmit handlers that put a hash of the password | 2157 // Some login forms have onSubmit handlers that put a hash of the password |
2149 // into a hidden field and then clear the password. (Issue 28910.) | 2158 // into a hidden field and then clear the password. (Issue 28910.) |
2150 // This method gets called before any of those handlers run, so save away | 2159 // This method gets called before any of those handlers run, so save away |
2151 // a copy of the password in case it gets lost. | 2160 // a copy of the password in case it gets lost. |
2152 NavigationState* navigation_state = | 2161 NavigationState* navigation_state = |
2153 NavigationState::FromDataSource(frame->dataSource()); | 2162 NavigationState::FromDataSource(frame->dataSource()); |
2154 navigation_state->set_password_form_data( | 2163 navigation_state->set_password_form_data( |
2155 PasswordFormDomManager::CreatePasswordForm(form)); | 2164 PasswordFormDomManager::CreatePasswordForm(form)); |
2156 } | 2165 } |
2157 | 2166 |
2158 void RenderView::willSubmitForm(WebFrame* frame, const WebFormElement& form) { | 2167 void RenderViewImpl::willSubmitForm(WebFrame* frame, |
| 2168 const WebFormElement& form) { |
2159 NavigationState* navigation_state = | 2169 NavigationState* navigation_state = |
2160 NavigationState::FromDataSource(frame->provisionalDataSource()); | 2170 NavigationState::FromDataSource(frame->provisionalDataSource()); |
2161 | 2171 |
2162 if (navigation_state->transition_type() == PageTransition::LINK) | 2172 if (navigation_state->transition_type() == PageTransition::LINK) |
2163 navigation_state->set_transition_type(PageTransition::FORM_SUBMIT); | 2173 navigation_state->set_transition_type(PageTransition::FORM_SUBMIT); |
2164 | 2174 |
2165 // Save these to be processed when the ensuing navigation is committed. | 2175 // Save these to be processed when the ensuing navigation is committed. |
2166 WebSearchableFormData web_searchable_form_data(form); | 2176 WebSearchableFormData web_searchable_form_data(form); |
2167 navigation_state->set_searchable_form_url(web_searchable_form_data.url()); | 2177 navigation_state->set_searchable_form_url(web_searchable_form_data.url()); |
2168 navigation_state->set_searchable_form_encoding( | 2178 navigation_state->set_searchable_form_encoding( |
(...skipping 14 matching lines...) Expand all Loading... |
2183 PasswordForm* old_form_data = old_navigation_state->password_form_data(); | 2193 PasswordForm* old_form_data = old_navigation_state->password_form_data(); |
2184 if (old_form_data && old_form_data->action == password_form_data->action) | 2194 if (old_form_data && old_form_data->action == password_form_data->action) |
2185 password_form_data->password_value = old_form_data->password_value; | 2195 password_form_data->password_value = old_form_data->password_value; |
2186 } | 2196 } |
2187 } | 2197 } |
2188 | 2198 |
2189 FOR_EACH_OBSERVER( | 2199 FOR_EACH_OBSERVER( |
2190 RenderViewObserver, observers_, WillSubmitForm(frame, form)); | 2200 RenderViewObserver, observers_, WillSubmitForm(frame, form)); |
2191 } | 2201 } |
2192 | 2202 |
2193 void RenderView::willPerformClientRedirect( | 2203 void RenderViewImpl::willPerformClientRedirect( |
2194 WebFrame* frame, const WebURL& from, const WebURL& to, double interval, | 2204 WebFrame* frame, const WebURL& from, const WebURL& to, double interval, |
2195 double fire_time) { | 2205 double fire_time) { |
2196 FOR_EACH_OBSERVER( | 2206 FOR_EACH_OBSERVER( |
2197 RenderViewObserver, observers_, | 2207 RenderViewObserver, observers_, |
2198 WillPerformClientRedirect(frame, from, to, interval, fire_time)); | 2208 WillPerformClientRedirect(frame, from, to, interval, fire_time)); |
2199 } | 2209 } |
2200 | 2210 |
2201 void RenderView::didCancelClientRedirect(WebFrame* frame) { | 2211 void RenderViewImpl::didCancelClientRedirect(WebFrame* frame) { |
2202 FOR_EACH_OBSERVER( | 2212 FOR_EACH_OBSERVER( |
2203 RenderViewObserver, observers_, DidCancelClientRedirect(frame)); | 2213 RenderViewObserver, observers_, DidCancelClientRedirect(frame)); |
2204 } | 2214 } |
2205 | 2215 |
2206 void RenderView::didCompleteClientRedirect( | 2216 void RenderViewImpl::didCompleteClientRedirect( |
2207 WebFrame* frame, const WebURL& from) { | 2217 WebFrame* frame, const WebURL& from) { |
2208 if (!frame->parent()) | 2218 if (!frame->parent()) |
2209 completed_client_redirect_src_ = from; | 2219 completed_client_redirect_src_ = from; |
2210 FOR_EACH_OBSERVER( | 2220 FOR_EACH_OBSERVER( |
2211 RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); | 2221 RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); |
2212 } | 2222 } |
2213 | 2223 |
2214 void RenderView::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { | 2224 void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { |
2215 // The rest of RenderView assumes that a WebDataSource will always have a | 2225 // The rest of RenderView assumes that a WebDataSource will always have a |
2216 // non-null NavigationState. | 2226 // non-null NavigationState. |
2217 bool content_initiated = !pending_navigation_state_.get(); | 2227 bool content_initiated = !pending_navigation_state_.get(); |
2218 NavigationState* state = content_initiated ? | 2228 NavigationState* state = content_initiated ? |
2219 NavigationState::CreateContentInitiated() : | 2229 NavigationState::CreateContentInitiated() : |
2220 pending_navigation_state_.release(); | 2230 pending_navigation_state_.release(); |
2221 | 2231 |
2222 // NavigationState::referred_by_prefetcher_ is true if we are | 2232 // NavigationState::referred_by_prefetcher_ is true if we are |
2223 // navigating from a page that used prefetching using a link on that | 2233 // navigating from a page that used prefetching using a link on that |
2224 // page. We are early enough in the request process here that we | 2234 // page. We are early enough in the request process here that we |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2262 break; | 2272 break; |
2263 } | 2273 } |
2264 } | 2274 } |
2265 | 2275 |
2266 ds->setExtraData(state); | 2276 ds->setExtraData(state); |
2267 | 2277 |
2268 FOR_EACH_OBSERVER( | 2278 FOR_EACH_OBSERVER( |
2269 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); | 2279 RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); |
2270 } | 2280 } |
2271 | 2281 |
2272 void RenderView::didStartProvisionalLoad(WebFrame* frame) { | 2282 void RenderViewImpl::didStartProvisionalLoad(WebFrame* frame) { |
2273 WebDataSource* ds = frame->provisionalDataSource(); | 2283 WebDataSource* ds = frame->provisionalDataSource(); |
2274 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 2284 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
2275 | 2285 |
2276 // Update the request time if WebKit has better knowledge of it. | 2286 // Update the request time if WebKit has better knowledge of it. |
2277 if (navigation_state->request_time().is_null()) { | 2287 if (navigation_state->request_time().is_null()) { |
2278 double event_time = ds->triggeringEventTime(); | 2288 double event_time = ds->triggeringEventTime(); |
2279 if (event_time != 0.0) | 2289 if (event_time != 0.0) |
2280 navigation_state->set_request_time(Time::FromDoubleT(event_time)); | 2290 navigation_state->set_request_time(Time::FromDoubleT(event_time)); |
2281 } | 2291 } |
2282 | 2292 |
(...skipping 14 matching lines...) Expand all Loading... |
2297 } | 2307 } |
2298 | 2308 |
2299 FOR_EACH_OBSERVER( | 2309 FOR_EACH_OBSERVER( |
2300 RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); | 2310 RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); |
2301 | 2311 |
2302 Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( | 2312 Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( |
2303 routing_id_, frame->identifier(), is_top_most, GetOpenerUrl(), | 2313 routing_id_, frame->identifier(), is_top_most, GetOpenerUrl(), |
2304 ds->request().url())); | 2314 ds->request().url())); |
2305 } | 2315 } |
2306 | 2316 |
2307 void RenderView::didReceiveServerRedirectForProvisionalLoad(WebFrame* frame) { | 2317 void RenderViewImpl::didReceiveServerRedirectForProvisionalLoad( |
| 2318 WebFrame* frame) { |
2308 if (frame->parent()) | 2319 if (frame->parent()) |
2309 return; | 2320 return; |
2310 // Received a redirect on the main frame. | 2321 // Received a redirect on the main frame. |
2311 WebDataSource* data_source = frame->provisionalDataSource(); | 2322 WebDataSource* data_source = frame->provisionalDataSource(); |
2312 if (!data_source) { | 2323 if (!data_source) { |
2313 // Should only be invoked when we have a data source. | 2324 // Should only be invoked when we have a data source. |
2314 NOTREACHED(); | 2325 NOTREACHED(); |
2315 return; | 2326 return; |
2316 } | 2327 } |
2317 std::vector<GURL> redirects; | 2328 std::vector<GURL> redirects; |
2318 GetRedirectChain(data_source, &redirects); | 2329 GetRedirectChain(data_source, &redirects); |
2319 if (redirects.size() >= 2) { | 2330 if (redirects.size() >= 2) { |
2320 Send(new ViewHostMsg_DidRedirectProvisionalLoad(routing_id_, page_id_, | 2331 Send(new ViewHostMsg_DidRedirectProvisionalLoad(routing_id_, page_id_, |
2321 GetOpenerUrl(), redirects[redirects.size() - 2], redirects.back())); | 2332 GetOpenerUrl(), redirects[redirects.size() - 2], redirects.back())); |
2322 } | 2333 } |
2323 } | 2334 } |
2324 | 2335 |
2325 void RenderView::didFailProvisionalLoad(WebFrame* frame, | 2336 void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame, |
2326 const WebURLError& error) { | 2337 const WebURLError& error) { |
2327 // Notify the browser that we failed a provisional load with an error. | 2338 // Notify the browser that we failed a provisional load with an error. |
2328 // | 2339 // |
2329 // Note: It is important this notification occur before DidStopLoading so the | 2340 // Note: It is important this notification occur before DidStopLoading so the |
2330 // SSL manager can react to the provisional load failure before being | 2341 // SSL manager can react to the provisional load failure before being |
2331 // notified the load stopped. | 2342 // notified the load stopped. |
2332 // | 2343 // |
2333 WebDataSource* ds = frame->provisionalDataSource(); | 2344 WebDataSource* ds = frame->provisionalDataSource(); |
2334 DCHECK(ds); | 2345 DCHECK(ds); |
2335 | 2346 |
2336 const WebURLRequest& failed_request = ds->request(); | 2347 const WebURLRequest& failed_request = ds->request(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2378 } | 2389 } |
2379 | 2390 |
2380 // Provide the user with a more helpful error page? | 2391 // Provide the user with a more helpful error page? |
2381 if (MaybeLoadAlternateErrorPage(frame, error, replace)) | 2392 if (MaybeLoadAlternateErrorPage(frame, error, replace)) |
2382 return; | 2393 return; |
2383 | 2394 |
2384 // Fallback to a local error page. | 2395 // Fallback to a local error page. |
2385 LoadNavigationErrorPage(frame, failed_request, error, std::string(), replace); | 2396 LoadNavigationErrorPage(frame, failed_request, error, std::string(), replace); |
2386 } | 2397 } |
2387 | 2398 |
2388 void RenderView::didReceiveDocumentData( | 2399 void RenderViewImpl::didReceiveDocumentData( |
2389 WebFrame* frame, const char* data, size_t data_len, | 2400 WebFrame* frame, const char* data, size_t data_len, |
2390 bool& prevent_default) { | 2401 bool& prevent_default) { |
2391 NavigationState* navigation_state = | 2402 NavigationState* navigation_state = |
2392 NavigationState::FromDataSource(frame->dataSource()); | 2403 NavigationState::FromDataSource(frame->dataSource()); |
2393 navigation_state->set_use_error_page(false); | 2404 navigation_state->set_use_error_page(false); |
2394 } | 2405 } |
2395 | 2406 |
2396 void RenderView::didCommitProvisionalLoad(WebFrame* frame, | 2407 void RenderViewImpl::didCommitProvisionalLoad(WebFrame* frame, |
2397 bool is_new_navigation) { | 2408 bool is_new_navigation) { |
2398 NavigationState* navigation_state = | 2409 NavigationState* navigation_state = |
2399 NavigationState::FromDataSource(frame->dataSource()); | 2410 NavigationState::FromDataSource(frame->dataSource()); |
2400 | 2411 |
2401 navigation_state->set_commit_load_time(Time::Now()); | 2412 navigation_state->set_commit_load_time(Time::Now()); |
2402 if (is_new_navigation) { | 2413 if (is_new_navigation) { |
2403 // When we perform a new navigation, we need to update the last committed | 2414 // When we perform a new navigation, we need to update the last committed |
2404 // session history entry with state for the page we are leaving. | 2415 // session history entry with state for the page we are leaving. |
2405 UpdateSessionHistory(frame); | 2416 UpdateSessionHistory(frame); |
2406 | 2417 |
2407 // We bump our Page ID to correspond with the new session history entry. | 2418 // We bump our Page ID to correspond with the new session history entry. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2456 UpdateURL(frame); | 2467 UpdateURL(frame); |
2457 | 2468 |
2458 // If this committed load was initiated by a client redirect, we're | 2469 // If this committed load was initiated by a client redirect, we're |
2459 // at the last stop now, so clear it. | 2470 // at the last stop now, so clear it. |
2460 completed_client_redirect_src_ = GURL(); | 2471 completed_client_redirect_src_ = GURL(); |
2461 | 2472 |
2462 // Check whether we have new encoding name. | 2473 // Check whether we have new encoding name. |
2463 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2474 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
2464 } | 2475 } |
2465 | 2476 |
2466 void RenderView::didClearWindowObject(WebFrame* frame) { | 2477 void RenderViewImpl::didClearWindowObject(WebFrame* frame) { |
2467 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 2478 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
2468 DidClearWindowObject(frame)); | 2479 DidClearWindowObject(frame)); |
2469 | 2480 |
2470 GURL frame_url = frame->document().url(); | 2481 GURL frame_url = frame->document().url(); |
2471 if (BindingsPolicy::is_web_ui_enabled(enabled_bindings_) && | 2482 if (BindingsPolicy::is_web_ui_enabled(enabled_bindings_) && |
2472 (frame_url.SchemeIs(chrome::kChromeUIScheme) || | 2483 (frame_url.SchemeIs(chrome::kChromeUIScheme) || |
2473 frame_url.SchemeIs(chrome::kDataScheme))) { | 2484 frame_url.SchemeIs(chrome::kDataScheme))) { |
2474 GetWebUIBindings()->BindToJavascript(frame, "chrome"); | 2485 GetWebUIBindings()->BindToJavascript(frame, "chrome"); |
2475 } | 2486 } |
2476 } | 2487 } |
2477 | 2488 |
2478 void RenderView::didCreateDocumentElement(WebFrame* frame) { | 2489 void RenderViewImpl::didCreateDocumentElement(WebFrame* frame) { |
2479 // Notify the browser about non-blank documents loading in the top frame. | 2490 // Notify the browser about non-blank documents loading in the top frame. |
2480 GURL url = frame->document().url(); | 2491 GURL url = frame->document().url(); |
2481 if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) { | 2492 if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) { |
2482 if (frame == webview()->mainFrame()) | 2493 if (frame == webview()->mainFrame()) |
2483 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); | 2494 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); |
2484 } | 2495 } |
2485 | 2496 |
2486 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 2497 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
2487 DidCreateDocumentElement(frame)); | 2498 DidCreateDocumentElement(frame)); |
2488 } | 2499 } |
2489 | 2500 |
2490 void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title, | 2501 void RenderViewImpl::didReceiveTitle(WebFrame* frame, const WebString& title, |
2491 WebTextDirection direction) { | 2502 WebTextDirection direction) { |
2492 UpdateTitle(frame, title, direction); | 2503 UpdateTitle(frame, title, direction); |
2493 | 2504 |
2494 // Also check whether we have new encoding name. | 2505 // Also check whether we have new encoding name. |
2495 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2506 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
2496 } | 2507 } |
2497 | 2508 |
2498 void RenderView::didChangeIcon(WebFrame* frame, WebIconURL::Type type) { | 2509 void RenderViewImpl::didChangeIcon(WebFrame* frame, WebIconURL::Type type) { |
2499 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 2510 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
2500 DidChangeIcon(frame, type)); | 2511 DidChangeIcon(frame, type)); |
2501 } | 2512 } |
2502 | 2513 |
2503 void RenderView::didFinishDocumentLoad(WebFrame* frame) { | 2514 void RenderViewImpl::didFinishDocumentLoad(WebFrame* frame) { |
2504 WebDataSource* ds = frame->dataSource(); | 2515 WebDataSource* ds = frame->dataSource(); |
2505 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 2516 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
2506 DCHECK(navigation_state); | 2517 DCHECK(navigation_state); |
2507 navigation_state->set_finish_document_load_time(Time::Now()); | 2518 navigation_state->set_finish_document_load_time(Time::Now()); |
2508 | 2519 |
2509 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); | 2520 Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); |
2510 | 2521 |
2511 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 2522 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
2512 DidFinishDocumentLoad(frame)); | 2523 DidFinishDocumentLoad(frame)); |
2513 | 2524 |
2514 // Check whether we have new encoding name. | 2525 // Check whether we have new encoding name. |
2515 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2526 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
2516 } | 2527 } |
2517 | 2528 |
2518 void RenderView::didHandleOnloadEvents(WebFrame* frame) { | 2529 void RenderViewImpl::didHandleOnloadEvents(WebFrame* frame) { |
2519 if (webview()->mainFrame() == frame) { | 2530 if (webview()->mainFrame() == frame) { |
2520 Send(new ViewHostMsg_DocumentOnLoadCompletedInMainFrame(routing_id_, | 2531 Send(new ViewHostMsg_DocumentOnLoadCompletedInMainFrame(routing_id_, |
2521 page_id_)); | 2532 page_id_)); |
2522 } | 2533 } |
2523 } | 2534 } |
2524 | 2535 |
2525 void RenderView::didFailLoad(WebFrame* frame, const WebURLError& error) { | 2536 void RenderViewImpl::didFailLoad(WebFrame* frame, const WebURLError& error) { |
2526 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); | 2537 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); |
2527 } | 2538 } |
2528 | 2539 |
2529 void RenderView::didFinishLoad(WebFrame* frame) { | 2540 void RenderViewImpl::didFinishLoad(WebFrame* frame) { |
2530 WebDataSource* ds = frame->dataSource(); | 2541 WebDataSource* ds = frame->dataSource(); |
2531 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 2542 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
2532 DCHECK(navigation_state); | 2543 DCHECK(navigation_state); |
2533 navigation_state->set_finish_load_time(Time::Now()); | 2544 navigation_state->set_finish_load_time(Time::Now()); |
2534 | 2545 |
2535 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); | 2546 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); |
2536 | 2547 |
2537 Send(new ViewHostMsg_DidFinishLoad(routing_id_, frame->identifier())); | 2548 Send(new ViewHostMsg_DidFinishLoad(routing_id_, frame->identifier())); |
2538 } | 2549 } |
2539 | 2550 |
2540 void RenderView::didNavigateWithinPage( | 2551 void RenderViewImpl::didNavigateWithinPage( |
2541 WebFrame* frame, bool is_new_navigation) { | 2552 WebFrame* frame, bool is_new_navigation) { |
2542 // If this was a reference fragment navigation that we initiated, then we | 2553 // If this was a reference fragment navigation that we initiated, then we |
2543 // could end up having a non-null pending navigation state. We just need to | 2554 // could end up having a non-null pending navigation state. We just need to |
2544 // update the ExtraData on the datasource so that others who read the | 2555 // update the ExtraData on the datasource so that others who read the |
2545 // ExtraData will get the new NavigationState. Similarly, if we did not | 2556 // ExtraData will get the new NavigationState. Similarly, if we did not |
2546 // initiate this navigation, then we need to take care to reset any pre- | 2557 // initiate this navigation, then we need to take care to reset any pre- |
2547 // existing navigation state to a content-initiated navigation state. | 2558 // existing navigation state to a content-initiated navigation state. |
2548 // DidCreateDataSource conveniently takes care of this for us. | 2559 // DidCreateDataSource conveniently takes care of this for us. |
2549 didCreateDataSource(frame, frame->dataSource()); | 2560 didCreateDataSource(frame, frame->dataSource()); |
2550 | 2561 |
2551 NavigationState* new_state = | 2562 NavigationState* new_state = |
2552 NavigationState::FromDataSource(frame->dataSource()); | 2563 NavigationState::FromDataSource(frame->dataSource()); |
2553 new_state->set_was_within_same_page(true); | 2564 new_state->set_was_within_same_page(true); |
2554 | 2565 |
2555 didCommitProvisionalLoad(frame, is_new_navigation); | 2566 didCommitProvisionalLoad(frame, is_new_navigation); |
2556 | 2567 |
2557 WebDataSource* datasource = frame->view()->mainFrame()->dataSource(); | 2568 WebDataSource* datasource = frame->view()->mainFrame()->dataSource(); |
2558 UpdateTitle(frame, datasource->pageTitle(), datasource->pageTitleDirection()); | 2569 UpdateTitle(frame, datasource->pageTitle(), datasource->pageTitleDirection()); |
2559 } | 2570 } |
2560 | 2571 |
2561 void RenderView::didUpdateCurrentHistoryItem(WebFrame* frame) { | 2572 void RenderViewImpl::didUpdateCurrentHistoryItem(WebFrame* frame) { |
2562 StartNavStateSyncTimerIfNecessary(); | 2573 StartNavStateSyncTimerIfNecessary(); |
2563 } | 2574 } |
2564 | 2575 |
2565 void RenderView::assignIdentifierToRequest( | 2576 void RenderViewImpl::assignIdentifierToRequest( |
2566 WebFrame* frame, unsigned identifier, const WebURLRequest& request) { | 2577 WebFrame* frame, unsigned identifier, const WebURLRequest& request) { |
2567 // Ignore | 2578 // Ignore |
2568 } | 2579 } |
2569 | 2580 |
2570 void RenderView::willSendRequest(WebFrame* frame, | 2581 void RenderViewImpl::willSendRequest(WebFrame* frame, |
2571 unsigned identifier, | 2582 unsigned identifier, |
2572 WebURLRequest& request, | 2583 WebURLRequest& request, |
2573 const WebURLResponse& redirect_response) { | 2584 const WebURLResponse& redirect_response) { |
2574 WebFrame* top_frame = frame->top(); | 2585 WebFrame* top_frame = frame->top(); |
2575 if (!top_frame) | 2586 if (!top_frame) |
2576 top_frame = frame; | 2587 top_frame = frame; |
2577 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); | 2588 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); |
2578 WebDataSource* top_data_source = top_frame->dataSource(); | 2589 WebDataSource* top_data_source = top_frame->dataSource(); |
2579 WebDataSource* data_source = | 2590 WebDataSource* data_source = |
2580 provisional_data_source ? provisional_data_source : top_data_source; | 2591 provisional_data_source ? provisional_data_source : top_data_source; |
2581 | 2592 |
2582 GURL request_url(request.url()); | 2593 GURL request_url(request.url()); |
2583 GURL new_url; | 2594 GURL new_url; |
(...skipping 22 matching lines...) Expand all Loading... |
2606 request.targetType() == WebURLRequest::TargetIsPrerender)) | 2617 request.targetType() == WebURLRequest::TargetIsPrerender)) |
2607 top_data_state->set_was_prefetcher(true); | 2618 top_data_state->set_was_prefetcher(true); |
2608 | 2619 |
2609 request.setRequestorID(routing_id_); | 2620 request.setRequestorID(routing_id_); |
2610 request.setHasUserGesture(frame->isProcessingUserGesture()); | 2621 request.setHasUserGesture(frame->isProcessingUserGesture()); |
2611 | 2622 |
2612 if (!renderer_preferences_.enable_referrers) | 2623 if (!renderer_preferences_.enable_referrers) |
2613 request.clearHTTPHeaderField("Referer"); | 2624 request.clearHTTPHeaderField("Referer"); |
2614 } | 2625 } |
2615 | 2626 |
2616 void RenderView::didReceiveResponse( | 2627 void RenderViewImpl::didReceiveResponse( |
2617 WebFrame* frame, unsigned identifier, const WebURLResponse& response) { | 2628 WebFrame* frame, unsigned identifier, const WebURLResponse& response) { |
2618 | 2629 |
2619 // Only do this for responses that correspond to a provisional data source | 2630 // Only do this for responses that correspond to a provisional data source |
2620 // of the top-most frame. If we have a provisional data source, then we | 2631 // of the top-most frame. If we have a provisional data source, then we |
2621 // can't have any sub-resources yet, so we know that this response must | 2632 // can't have any sub-resources yet, so we know that this response must |
2622 // correspond to a frame load. | 2633 // correspond to a frame load. |
2623 if (!frame->provisionalDataSource() || frame->parent()) | 2634 if (!frame->provisionalDataSource() || frame->parent()) |
2624 return; | 2635 return; |
2625 | 2636 |
2626 // If we are in view source mode, then just let the user see the source of | 2637 // If we are in view source mode, then just let the user see the source of |
(...skipping 12 matching lines...) Expand all Loading... |
2639 navigation_state->set_was_alternate_protocol_available( | 2650 navigation_state->set_was_alternate_protocol_available( |
2640 response.wasAlternateProtocolAvailable()); | 2651 response.wasAlternateProtocolAvailable()); |
2641 navigation_state->set_was_fetched_via_proxy(response.wasFetchedViaProxy()); | 2652 navigation_state->set_was_fetched_via_proxy(response.wasFetchedViaProxy()); |
2642 navigation_state->set_http_status_code(http_status_code); | 2653 navigation_state->set_http_status_code(http_status_code); |
2643 // Whether or not the http status code actually corresponds to an error is | 2654 // Whether or not the http status code actually corresponds to an error is |
2644 // only checked when the page is done loading, if |use_error_page| is | 2655 // only checked when the page is done loading, if |use_error_page| is |
2645 // still true. | 2656 // still true. |
2646 navigation_state->set_use_error_page(true); | 2657 navigation_state->set_use_error_page(true); |
2647 } | 2658 } |
2648 | 2659 |
2649 void RenderView::didFinishResourceLoad( | 2660 void RenderViewImpl::didFinishResourceLoad( |
2650 WebFrame* frame, unsigned identifier) { | 2661 WebFrame* frame, unsigned identifier) { |
2651 NavigationState* navigation_state = | 2662 NavigationState* navigation_state = |
2652 NavigationState::FromDataSource(frame->dataSource()); | 2663 NavigationState::FromDataSource(frame->dataSource()); |
2653 if (!navigation_state->use_error_page()) | 2664 if (!navigation_state->use_error_page()) |
2654 return; | 2665 return; |
2655 | 2666 |
2656 // Do not show error page when DevTools is attached. | 2667 // Do not show error page when DevTools is attached. |
2657 if (devtools_agent_->IsAttached()) | 2668 if (devtools_agent_->IsAttached()) |
2658 return; | 2669 return; |
2659 | 2670 |
2660 // Display error page, if appropriate. | 2671 // Display error page, if appropriate. |
2661 int http_status_code = navigation_state->http_status_code(); | 2672 int http_status_code = navigation_state->http_status_code(); |
2662 if (http_status_code == 404) { | 2673 if (http_status_code == 404) { |
2663 // On 404s, try a remote search page as a fallback. | 2674 // On 404s, try a remote search page as a fallback. |
2664 const GURL& document_url = frame->document().url(); | 2675 const GURL& document_url = frame->document().url(); |
2665 | 2676 |
2666 const GURL& error_page_url = | 2677 const GURL& error_page_url = |
2667 GetAlternateErrorPageURL(document_url, HTTP_404); | 2678 GetAlternateErrorPageURL(document_url, HTTP_404); |
2668 if (error_page_url.is_valid()) { | 2679 if (error_page_url.is_valid()) { |
2669 WebURLError original_error; | 2680 WebURLError original_error; |
2670 original_error.domain = "http"; | 2681 original_error.domain = "http"; |
2671 original_error.reason = 404; | 2682 original_error.reason = 404; |
2672 original_error.unreachableURL = document_url; | 2683 original_error.unreachableURL = document_url; |
2673 | 2684 |
2674 navigation_state->set_alt_error_page_fetcher( | 2685 navigation_state->set_alt_error_page_fetcher( |
2675 new AltErrorPageResourceFetcher( | 2686 new AltErrorPageResourceFetcher( |
2676 error_page_url, frame, original_error, | 2687 error_page_url, frame, original_error, |
2677 NewCallback(this, &RenderView::AltErrorPageFinished))); | 2688 NewCallback(this, &RenderViewImpl::AltErrorPageFinished))); |
2678 return; | 2689 return; |
2679 } | 2690 } |
2680 } | 2691 } |
2681 | 2692 |
2682 std::string error_domain; | 2693 std::string error_domain; |
2683 if (content::GetContentClient()->renderer()->HasErrorPage( | 2694 if (content::GetContentClient()->renderer()->HasErrorPage( |
2684 http_status_code, &error_domain)) { | 2695 http_status_code, &error_domain)) { |
2685 WebURLError error; | 2696 WebURLError error; |
2686 error.unreachableURL = frame->document().url(); | 2697 error.unreachableURL = frame->document().url(); |
2687 error.domain = WebString::fromUTF8(error_domain); | 2698 error.domain = WebString::fromUTF8(error_domain); |
2688 error.reason = http_status_code; | 2699 error.reason = http_status_code; |
2689 | 2700 |
2690 LoadNavigationErrorPage( | 2701 LoadNavigationErrorPage( |
2691 frame, frame->dataSource()->request(), error, std::string(), true); | 2702 frame, frame->dataSource()->request(), error, std::string(), true); |
2692 } | 2703 } |
2693 } | 2704 } |
2694 | 2705 |
2695 void RenderView::didFailResourceLoad( | 2706 void RenderViewImpl::didFailResourceLoad( |
2696 WebFrame* frame, unsigned identifier, const WebURLError& error) { | 2707 WebFrame* frame, unsigned identifier, const WebURLError& error) { |
2697 // Ignore | 2708 // Ignore |
2698 } | 2709 } |
2699 | 2710 |
2700 void RenderView::didLoadResourceFromMemoryCache( | 2711 void RenderViewImpl::didLoadResourceFromMemoryCache( |
2701 WebFrame* frame, const WebURLRequest& request, | 2712 WebFrame* frame, const WebURLRequest& request, |
2702 const WebURLResponse& response) { | 2713 const WebURLResponse& response) { |
2703 // Let the browser know we loaded a resource from the memory cache. This | 2714 // Let the browser know we loaded a resource from the memory cache. This |
2704 // message is needed to display the correct SSL indicators. | 2715 // message is needed to display the correct SSL indicators. |
2705 Send(new ViewHostMsg_DidLoadResourceFromMemoryCache( | 2716 Send(new ViewHostMsg_DidLoadResourceFromMemoryCache( |
2706 routing_id_, | 2717 routing_id_, |
2707 request.url(), | 2718 request.url(), |
2708 response.securityInfo(), | 2719 response.securityInfo(), |
2709 request.httpMethod().utf8(), | 2720 request.httpMethod().utf8(), |
2710 ResourceType::FromTargetType(request.targetType()))); | 2721 ResourceType::FromTargetType(request.targetType()))); |
2711 } | 2722 } |
2712 | 2723 |
2713 void RenderView::didDisplayInsecureContent(WebFrame* frame) { | 2724 void RenderViewImpl::didDisplayInsecureContent(WebFrame* frame) { |
2714 Send(new ViewHostMsg_DidDisplayInsecureContent(routing_id_)); | 2725 Send(new ViewHostMsg_DidDisplayInsecureContent(routing_id_)); |
2715 } | 2726 } |
2716 | 2727 |
2717 void RenderView::didRunInsecureContent( | 2728 void RenderViewImpl::didRunInsecureContent( |
2718 WebFrame* frame, const WebSecurityOrigin& origin, const WebURL& target) { | 2729 WebFrame* frame, const WebSecurityOrigin& origin, const WebURL& target) { |
2719 Send(new ViewHostMsg_DidRunInsecureContent( | 2730 Send(new ViewHostMsg_DidRunInsecureContent( |
2720 routing_id_, | 2731 routing_id_, |
2721 origin.toString().utf8(), | 2732 origin.toString().utf8(), |
2722 target)); | 2733 target)); |
2723 } | 2734 } |
2724 | 2735 |
2725 void RenderView::didAdoptURLLoader(WebKit::WebURLLoader* loader) { | 2736 void RenderViewImpl::didAdoptURLLoader(WebKit::WebURLLoader* loader) { |
2726 webkit_glue::WebURLLoaderImpl* loader_impl = | 2737 webkit_glue::WebURLLoaderImpl* loader_impl = |
2727 static_cast<webkit_glue::WebURLLoaderImpl*>(loader); | 2738 static_cast<webkit_glue::WebURLLoaderImpl*>(loader); |
2728 loader_impl->UpdateRoutingId(routing_id_); | 2739 loader_impl->UpdateRoutingId(routing_id_); |
2729 } | 2740 } |
2730 | 2741 |
2731 void RenderView::didExhaustMemoryAvailableForScript(WebFrame* frame) { | 2742 void RenderViewImpl::didExhaustMemoryAvailableForScript(WebFrame* frame) { |
2732 Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); | 2743 Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); |
2733 } | 2744 } |
2734 | 2745 |
2735 void RenderView::didCreateScriptContext(WebFrame* frame, | 2746 void RenderViewImpl::didCreateScriptContext(WebFrame* frame, |
2736 v8::Handle<v8::Context> context, | 2747 v8::Handle<v8::Context> context, |
2737 int world_id) { | 2748 int world_id) { |
2738 content::GetContentClient()->renderer()->DidCreateScriptContext( | 2749 content::GetContentClient()->renderer()->DidCreateScriptContext( |
2739 frame, context, world_id); | 2750 frame, context, world_id); |
2740 } | 2751 } |
2741 | 2752 |
2742 void RenderView::willReleaseScriptContext(WebFrame* frame, | 2753 void RenderViewImpl::willReleaseScriptContext(WebFrame* frame, |
2743 v8::Handle<v8::Context> context, | 2754 v8::Handle<v8::Context> context, |
2744 int world_id) { | 2755 int world_id) { |
2745 content::GetContentClient()->renderer()->WillReleaseScriptContext( | 2756 content::GetContentClient()->renderer()->WillReleaseScriptContext( |
2746 frame, context, world_id); | 2757 frame, context, world_id); |
2747 } | 2758 } |
2748 | 2759 |
2749 void RenderView::didUpdateLayout(WebFrame* frame) { | 2760 void RenderViewImpl::didUpdateLayout(WebFrame* frame) { |
2750 // We don't always want to set up a timer, only if we've been put in that | 2761 // We don't always want to set up a timer, only if we've been put in that |
2751 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | 2762 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
2752 // message. | 2763 // message. |
2753 if (!send_preferred_size_changes_ || !webview()) | 2764 if (!send_preferred_size_changes_ || !webview()) |
2754 return; | 2765 return; |
2755 | 2766 |
2756 if (check_preferred_size_timer_.IsRunning()) | 2767 if (check_preferred_size_timer_.IsRunning()) |
2757 return; | 2768 return; |
2758 check_preferred_size_timer_.Start(FROM_HERE, | 2769 check_preferred_size_timer_.Start(FROM_HERE, |
2759 TimeDelta::FromMilliseconds(0), this, | 2770 TimeDelta::FromMilliseconds(0), this, |
2760 &RenderView::CheckPreferredSize); | 2771 &RenderViewImpl::CheckPreferredSize); |
2761 } | 2772 } |
2762 | 2773 |
2763 void RenderView::CheckPreferredSize() { | 2774 void RenderViewImpl::CheckPreferredSize() { |
2764 // We don't always want to send the change messages over IPC, only if we've | 2775 // We don't always want to send the change messages over IPC, only if we've |
2765 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| | 2776 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
2766 // message. | 2777 // message. |
2767 if (!send_preferred_size_changes_ || !webview()) | 2778 if (!send_preferred_size_changes_ || !webview()) |
2768 return; | 2779 return; |
2769 | 2780 |
2770 gfx::Size size(webview()->mainFrame()->contentsPreferredWidth(), | 2781 gfx::Size size(webview()->mainFrame()->contentsPreferredWidth(), |
2771 webview()->mainFrame()->documentElementScrollHeight()); | 2782 webview()->mainFrame()->documentElementScrollHeight()); |
2772 | 2783 |
2773 // In the presence of zoom, these sizes are still reported as if unzoomed, | 2784 // In the presence of zoom, these sizes are still reported as if unzoomed, |
2774 // so we need to adjust. | 2785 // so we need to adjust. |
2775 double zoom_factor = WebView::zoomLevelToZoomFactor(webview()->zoomLevel()); | 2786 double zoom_factor = WebView::zoomLevelToZoomFactor(webview()->zoomLevel()); |
2776 size.set_width(static_cast<int>(size.width() * zoom_factor)); | 2787 size.set_width(static_cast<int>(size.width() * zoom_factor)); |
2777 size.set_height(static_cast<int>(size.height() * zoom_factor)); | 2788 size.set_height(static_cast<int>(size.height() * zoom_factor)); |
2778 | 2789 |
2779 if (size == preferred_size_) | 2790 if (size == preferred_size_) |
2780 return; | 2791 return; |
2781 | 2792 |
2782 preferred_size_ = size; | 2793 preferred_size_ = size; |
2783 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, | 2794 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, |
2784 preferred_size_)); | 2795 preferred_size_)); |
2785 } | 2796 } |
2786 | 2797 |
2787 void RenderView::didChangeContentsSize(WebFrame* frame, const WebSize& size) { | 2798 void RenderViewImpl::didChangeContentsSize(WebFrame* frame, |
| 2799 const WebSize& size) { |
2788 if (webview()->mainFrame() != frame) | 2800 if (webview()->mainFrame() != frame) |
2789 return; | 2801 return; |
2790 WebView* frameView = frame->view(); | 2802 WebView* frameView = frame->view(); |
2791 if (!frameView) | 2803 if (!frameView) |
2792 return; | 2804 return; |
2793 | 2805 |
2794 bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); | 2806 bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); |
2795 bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); | 2807 bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); |
2796 | 2808 |
2797 if (has_horizontal_scrollbar != cached_has_main_frame_horizontal_scrollbar_ || | 2809 if (has_horizontal_scrollbar != cached_has_main_frame_horizontal_scrollbar_ || |
2798 has_vertical_scrollbar != cached_has_main_frame_vertical_scrollbar_) { | 2810 has_vertical_scrollbar != cached_has_main_frame_vertical_scrollbar_) { |
2799 Send(new ViewHostMsg_DidChangeScrollbarsForMainFrame( | 2811 Send(new ViewHostMsg_DidChangeScrollbarsForMainFrame( |
2800 routing_id_, has_horizontal_scrollbar, has_vertical_scrollbar)); | 2812 routing_id_, has_horizontal_scrollbar, has_vertical_scrollbar)); |
2801 | 2813 |
2802 cached_has_main_frame_horizontal_scrollbar_ = has_horizontal_scrollbar; | 2814 cached_has_main_frame_horizontal_scrollbar_ = has_horizontal_scrollbar; |
2803 cached_has_main_frame_vertical_scrollbar_ = has_vertical_scrollbar; | 2815 cached_has_main_frame_vertical_scrollbar_ = has_vertical_scrollbar; |
2804 } | 2816 } |
2805 } | 2817 } |
2806 | 2818 |
2807 void RenderView::UpdateScrollState(WebFrame* frame) { | 2819 void RenderViewImpl::UpdateScrollState(WebFrame* frame) { |
2808 WebSize offset = frame->scrollOffset(); | 2820 WebSize offset = frame->scrollOffset(); |
2809 WebSize minimum_offset = frame->minimumScrollOffset(); | 2821 WebSize minimum_offset = frame->minimumScrollOffset(); |
2810 WebSize maximum_offset = frame->maximumScrollOffset(); | 2822 WebSize maximum_offset = frame->maximumScrollOffset(); |
2811 | 2823 |
2812 bool is_pinned_to_left = offset.width <= minimum_offset.width; | 2824 bool is_pinned_to_left = offset.width <= minimum_offset.width; |
2813 bool is_pinned_to_right = offset.width >= maximum_offset.width; | 2825 bool is_pinned_to_right = offset.width >= maximum_offset.width; |
2814 | 2826 |
2815 if (is_pinned_to_left != cached_is_main_frame_pinned_to_left_ || | 2827 if (is_pinned_to_left != cached_is_main_frame_pinned_to_left_ || |
2816 is_pinned_to_right != cached_is_main_frame_pinned_to_right_) { | 2828 is_pinned_to_right != cached_is_main_frame_pinned_to_right_) { |
2817 Send(new ViewHostMsg_DidChangeScrollOffsetPinningForMainFrame( | 2829 Send(new ViewHostMsg_DidChangeScrollOffsetPinningForMainFrame( |
2818 routing_id_, is_pinned_to_left, is_pinned_to_right)); | 2830 routing_id_, is_pinned_to_left, is_pinned_to_right)); |
2819 | 2831 |
2820 cached_is_main_frame_pinned_to_left_ = is_pinned_to_left; | 2832 cached_is_main_frame_pinned_to_left_ = is_pinned_to_left; |
2821 cached_is_main_frame_pinned_to_right_ = is_pinned_to_right; | 2833 cached_is_main_frame_pinned_to_right_ = is_pinned_to_right; |
2822 } | 2834 } |
2823 } | 2835 } |
2824 | 2836 |
2825 void RenderView::didChangeScrollOffset(WebFrame* frame) { | 2837 void RenderViewImpl::didChangeScrollOffset(WebFrame* frame) { |
2826 StartNavStateSyncTimerIfNecessary(); | 2838 StartNavStateSyncTimerIfNecessary(); |
2827 | 2839 |
2828 if (webview()->mainFrame() == frame) | 2840 if (webview()->mainFrame() == frame) |
2829 UpdateScrollState(frame); | 2841 UpdateScrollState(frame); |
2830 } | 2842 } |
2831 | 2843 |
2832 void RenderView::numberOfWheelEventHandlersChanged(unsigned num_handlers) { | 2844 void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) { |
2833 Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers)); | 2845 Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers)); |
2834 } | 2846 } |
2835 | 2847 |
2836 void RenderView::reportFindInPageMatchCount(int request_id, int count, | 2848 void RenderViewImpl::reportFindInPageMatchCount(int request_id, int count, |
2837 bool final_update) { | 2849 bool final_update) { |
2838 int active_match_ordinal = -1; // -1 = don't update active match ordinal | 2850 int active_match_ordinal = -1; // -1 = don't update active match ordinal |
2839 if (!count) | 2851 if (!count) |
2840 active_match_ordinal = 0; | 2852 active_match_ordinal = 0; |
2841 | 2853 |
2842 IPC::Message* msg = new ViewHostMsg_Find_Reply( | 2854 IPC::Message* msg = new ViewHostMsg_Find_Reply( |
2843 routing_id_, | 2855 routing_id_, |
2844 request_id, | 2856 request_id, |
2845 count, | 2857 count, |
2846 gfx::Rect(), | 2858 gfx::Rect(), |
2847 active_match_ordinal, | 2859 active_match_ordinal, |
2848 final_update); | 2860 final_update); |
2849 | 2861 |
2850 // If we have a message that has been queued up, then we should just replace | 2862 // If we have a message that has been queued up, then we should just replace |
2851 // it. The ACK from the browser will make sure it gets sent when the browser | 2863 // it. The ACK from the browser will make sure it gets sent when the browser |
2852 // wants it. | 2864 // wants it. |
2853 if (queued_find_reply_message_.get()) { | 2865 if (queued_find_reply_message_.get()) { |
2854 queued_find_reply_message_.reset(msg); | 2866 queued_find_reply_message_.reset(msg); |
2855 } else { | 2867 } else { |
2856 // Send the search result over to the browser process. | 2868 // Send the search result over to the browser process. |
2857 Send(msg); | 2869 Send(msg); |
2858 } | 2870 } |
2859 } | 2871 } |
2860 | 2872 |
2861 void RenderView::reportFindInPageSelection(int request_id, | 2873 void RenderViewImpl::reportFindInPageSelection(int request_id, |
2862 int active_match_ordinal, | 2874 int active_match_ordinal, |
2863 const WebRect& selection_rect) { | 2875 const WebRect& selection_rect) { |
2864 // Send the search result over to the browser process. | 2876 // Send the search result over to the browser process. |
2865 Send(new ViewHostMsg_Find_Reply(routing_id_, | 2877 Send(new ViewHostMsg_Find_Reply(routing_id_, |
2866 request_id, | 2878 request_id, |
2867 -1, | 2879 -1, |
2868 selection_rect, | 2880 selection_rect, |
2869 active_match_ordinal, | 2881 active_match_ordinal, |
2870 false)); | 2882 false)); |
2871 } | 2883 } |
2872 | 2884 |
2873 void RenderView::openFileSystem( | 2885 void RenderViewImpl::openFileSystem( |
2874 WebFrame* frame, | 2886 WebFrame* frame, |
2875 WebFileSystem::Type type, | 2887 WebFileSystem::Type type, |
2876 long long size, | 2888 long long size, |
2877 bool create, | 2889 bool create, |
2878 WebFileSystemCallbacks* callbacks) { | 2890 WebFileSystemCallbacks* callbacks) { |
2879 DCHECK(callbacks); | 2891 DCHECK(callbacks); |
2880 | 2892 |
2881 WebSecurityOrigin origin = frame->document().securityOrigin(); | 2893 WebSecurityOrigin origin = frame->document().securityOrigin(); |
2882 if (origin.isEmpty()) { | 2894 if (origin.isEmpty()) { |
2883 // Uninitialized document? | 2895 // Uninitialized document? |
2884 callbacks->didFail(WebKit::WebFileErrorAbort); | 2896 callbacks->didFail(WebKit::WebFileErrorAbort); |
2885 return; | 2897 return; |
2886 } | 2898 } |
2887 | 2899 |
2888 ChildThread::current()->file_system_dispatcher()->OpenFileSystem( | 2900 ChildThread::current()->file_system_dispatcher()->OpenFileSystem( |
2889 GURL(origin.toString()), static_cast<fileapi::FileSystemType>(type), | 2901 GURL(origin.toString()), static_cast<fileapi::FileSystemType>(type), |
2890 size, create, new WebFileSystemCallbackDispatcher(callbacks)); | 2902 size, create, new WebFileSystemCallbackDispatcher(callbacks)); |
2891 } | 2903 } |
2892 | 2904 |
2893 void RenderView::queryStorageUsageAndQuota( | 2905 void RenderViewImpl::queryStorageUsageAndQuota( |
2894 WebFrame* frame, | 2906 WebFrame* frame, |
2895 WebStorageQuotaType type, | 2907 WebStorageQuotaType type, |
2896 WebStorageQuotaCallbacks* callbacks) { | 2908 WebStorageQuotaCallbacks* callbacks) { |
2897 DCHECK(frame); | 2909 DCHECK(frame); |
2898 WebSecurityOrigin origin = frame->document().securityOrigin(); | 2910 WebSecurityOrigin origin = frame->document().securityOrigin(); |
2899 if (origin.isEmpty()) { | 2911 if (origin.isEmpty()) { |
2900 // Uninitialized document? | 2912 // Uninitialized document? |
2901 callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); | 2913 callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); |
2902 return; | 2914 return; |
2903 } | 2915 } |
2904 ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota( | 2916 ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota( |
2905 GURL(origin.toString()), | 2917 GURL(origin.toString()), |
2906 static_cast<quota::StorageType>(type), | 2918 static_cast<quota::StorageType>(type), |
2907 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); | 2919 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
2908 } | 2920 } |
2909 | 2921 |
2910 void RenderView::requestStorageQuota( | 2922 void RenderViewImpl::requestStorageQuota( |
2911 WebFrame* frame, | 2923 WebFrame* frame, |
2912 WebStorageQuotaType type, | 2924 WebStorageQuotaType type, |
2913 unsigned long long requested_size, | 2925 unsigned long long requested_size, |
2914 WebStorageQuotaCallbacks* callbacks) { | 2926 WebStorageQuotaCallbacks* callbacks) { |
2915 DCHECK(frame); | 2927 DCHECK(frame); |
2916 WebSecurityOrigin origin = frame->document().securityOrigin(); | 2928 WebSecurityOrigin origin = frame->document().securityOrigin(); |
2917 if (origin.isEmpty()) { | 2929 if (origin.isEmpty()) { |
2918 // Uninitialized document? | 2930 // Uninitialized document? |
2919 callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); | 2931 callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); |
2920 return; | 2932 return; |
2921 } | 2933 } |
2922 ChildThread::current()->quota_dispatcher()->RequestStorageQuota( | 2934 ChildThread::current()->quota_dispatcher()->RequestStorageQuota( |
2923 routing_id(), GURL(origin.toString()), | 2935 routing_id(), GURL(origin.toString()), |
2924 static_cast<quota::StorageType>(type), requested_size, | 2936 static_cast<quota::StorageType>(type), requested_size, |
2925 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); | 2937 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
2926 } | 2938 } |
2927 | 2939 |
2928 // WebKit::WebPageSerializerClient implementation ------------------------------ | 2940 // WebKit::WebPageSerializerClient implementation ------------------------------ |
2929 | 2941 |
2930 void RenderView::didSerializeDataForFrame( | 2942 void RenderViewImpl::didSerializeDataForFrame( |
2931 const WebURL& frame_url, | 2943 const WebURL& frame_url, |
2932 const WebCString& data, | 2944 const WebCString& data, |
2933 WebPageSerializerClient::PageSerializationStatus status) { | 2945 WebPageSerializerClient::PageSerializationStatus status) { |
2934 Send(new ViewHostMsg_SendSerializedHtmlData( | 2946 Send(new ViewHostMsg_SendSerializedHtmlData( |
2935 routing_id(), | 2947 routing_id(), |
2936 frame_url, | 2948 frame_url, |
2937 data.data(), | 2949 data.data(), |
2938 static_cast<int32>(status))); | 2950 static_cast<int32>(status))); |
2939 } | 2951 } |
2940 | 2952 |
2941 // content::RenderView implementation ------------------------------------------ | 2953 // content::RenderView implementation ------------------------------------------ |
2942 | 2954 |
2943 bool RenderView::Send(IPC::Message* message) { | 2955 bool RenderViewImpl::Send(IPC::Message* message) { |
2944 return RenderWidget::Send(message); | 2956 return RenderWidget::Send(message); |
2945 } | 2957 } |
2946 | 2958 |
2947 int RenderView::GetRoutingId() const { | 2959 int RenderViewImpl::GetRoutingId() const { |
2948 return routing_id_; | 2960 return routing_id_; |
2949 } | 2961 } |
2950 | 2962 |
2951 int RenderView::GetPageId() { | 2963 int RenderViewImpl::GetPageId() { |
2952 return page_id_; | 2964 return page_id_; |
2953 } | 2965 } |
2954 | 2966 |
2955 gfx::Size RenderView::GetSize() { | 2967 gfx::Size RenderViewImpl::GetSize() { |
2956 return size(); | 2968 return size(); |
2957 } | 2969 } |
2958 | 2970 |
2959 gfx::NativeViewId RenderView::GetHostWindow() { | 2971 gfx::NativeViewId RenderViewImpl::GetHostWindow() { |
2960 return host_window(); | 2972 return host_window(); |
2961 } | 2973 } |
2962 | 2974 |
2963 WebPreferences& RenderView::GetWebkitPreferences() { | 2975 WebPreferences& RenderViewImpl::GetWebkitPreferences() { |
2964 return webkit_preferences_; | 2976 return webkit_preferences_; |
2965 } | 2977 } |
2966 | 2978 |
2967 WebKit::WebView* RenderView::GetWebView() { | 2979 WebKit::WebView* RenderViewImpl::GetWebView() { |
2968 return webview(); | 2980 return webview(); |
2969 } | 2981 } |
2970 | 2982 |
2971 WebKit::WebNode RenderView::GetFocusedNode() const { | 2983 WebKit::WebNode RenderViewImpl::GetFocusedNode() const { |
2972 if (!webview()) | 2984 if (!webview()) |
2973 return WebNode(); | 2985 return WebNode(); |
2974 WebFrame* focused_frame = webview()->focusedFrame(); | 2986 WebFrame* focused_frame = webview()->focusedFrame(); |
2975 if (focused_frame) { | 2987 if (focused_frame) { |
2976 WebDocument doc = focused_frame->document(); | 2988 WebDocument doc = focused_frame->document(); |
2977 if (!doc.isNull()) | 2989 if (!doc.isNull()) |
2978 return doc.focusedNode(); | 2990 return doc.focusedNode(); |
2979 } | 2991 } |
2980 | 2992 |
2981 return WebNode(); | 2993 return WebNode(); |
2982 } | 2994 } |
2983 | 2995 |
2984 WebKit::WebNode RenderView::GetContextMenuNode() const { | 2996 WebKit::WebNode RenderViewImpl::GetContextMenuNode() const { |
2985 return context_menu_node_; | 2997 return context_menu_node_; |
2986 } | 2998 } |
2987 | 2999 |
2988 bool RenderView::IsEditableNode(const WebKit::WebNode& node) { | 3000 bool RenderViewImpl::IsEditableNode(const WebKit::WebNode& node) { |
2989 bool is_editable_node = false; | 3001 bool is_editable_node = false; |
2990 if (!node.isNull()) { | 3002 if (!node.isNull()) { |
2991 if (node.isContentEditable()) { | 3003 if (node.isContentEditable()) { |
2992 is_editable_node = true; | 3004 is_editable_node = true; |
2993 } else if (node.isElementNode()) { | 3005 } else if (node.isElementNode()) { |
2994 is_editable_node = | 3006 is_editable_node = |
2995 node.toConst<WebElement>().isTextFormControlElement(); | 3007 node.toConst<WebElement>().isTextFormControlElement(); |
2996 } | 3008 } |
2997 } | 3009 } |
2998 return is_editable_node; | 3010 return is_editable_node; |
2999 } | 3011 } |
3000 | 3012 |
3001 WebKit::WebPlugin* RenderView::CreatePlugin( | 3013 WebKit::WebPlugin* RenderViewImpl::CreatePlugin( |
3002 WebKit::WebFrame* frame, | 3014 WebKit::WebFrame* frame, |
3003 const webkit::WebPluginInfo& info, | 3015 const webkit::WebPluginInfo& info, |
3004 const WebKit::WebPluginParams& params) { | 3016 const WebKit::WebPluginParams& params) { |
3005 bool pepper_plugin_was_registered = false; | 3017 bool pepper_plugin_was_registered = false; |
3006 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( | 3018 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( |
3007 pepper_delegate_.CreatePepperPluginModule(info, | 3019 pepper_delegate_.CreatePepperPluginModule(info, |
3008 &pepper_plugin_was_registered)); | 3020 &pepper_plugin_was_registered)); |
3009 if (pepper_plugin_was_registered) { | 3021 if (pepper_plugin_was_registered) { |
3010 if (!pepper_module) | 3022 if (!pepper_module) |
3011 return NULL; | 3023 return NULL; |
3012 return new webkit::ppapi::WebPluginImpl( | 3024 return new webkit::ppapi::WebPluginImpl( |
3013 pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); | 3025 pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); |
3014 } | 3026 } |
3015 | 3027 |
3016 return new webkit::npapi::WebPluginImpl( | 3028 return new webkit::npapi::WebPluginImpl( |
3017 frame, params, info.path, AsWeakPtr()); | 3029 frame, params, info.path, AsWeakPtr()); |
3018 } | 3030 } |
3019 | 3031 |
3020 void RenderView::EvaluateScript(const string16& frame_xpath, | 3032 void RenderViewImpl::EvaluateScript(const string16& frame_xpath, |
3021 const string16& jscript, | 3033 const string16& jscript, |
3022 int id, | 3034 int id, |
3023 bool notify_result) { | 3035 bool notify_result) { |
3024 v8::Handle<v8::Value> result; | 3036 v8::Handle<v8::Value> result; |
3025 WebFrame* web_frame = GetChildFrame(frame_xpath); | 3037 WebFrame* web_frame = GetChildFrame(frame_xpath); |
3026 if (web_frame) | 3038 if (web_frame) |
3027 result = web_frame->executeScriptAndReturnValue(WebScriptSource(jscript)); | 3039 result = web_frame->executeScriptAndReturnValue(WebScriptSource(jscript)); |
3028 if (notify_result) { | 3040 if (notify_result) { |
3029 ListValue list; | 3041 ListValue list; |
3030 if (!result.IsEmpty() && web_frame) { | 3042 if (!result.IsEmpty() && web_frame) { |
3031 v8::HandleScope handle_scope; | 3043 v8::HandleScope handle_scope; |
3032 v8::Local<v8::Context> context = web_frame->mainWorldScriptContext(); | 3044 v8::Local<v8::Context> context = web_frame->mainWorldScriptContext(); |
3033 v8::Context::Scope context_scope(context); | 3045 v8::Context::Scope context_scope(context); |
3034 V8ValueConverterImpl converter; | 3046 V8ValueConverterImpl converter; |
3035 converter.set_allow_date(true); | 3047 converter.set_allow_date(true); |
3036 converter.set_allow_regexp(true); | 3048 converter.set_allow_regexp(true); |
3037 list.Set(0, converter.FromV8Value(result, context)); | 3049 list.Set(0, converter.FromV8Value(result, context)); |
3038 } else { | 3050 } else { |
3039 list.Set(0, Value::CreateNullValue()); | 3051 list.Set(0, Value::CreateNullValue()); |
3040 } | 3052 } |
3041 Send(new ViewHostMsg_ScriptEvalResponse(routing_id_, id, list)); | 3053 Send(new ViewHostMsg_ScriptEvalResponse(routing_id_, id, list)); |
3042 } | 3054 } |
3043 } | 3055 } |
3044 | 3056 |
3045 bool RenderView::ShouldDisplayScrollbars(int width, int height) const { | 3057 bool RenderViewImpl::ShouldDisplayScrollbars(int width, int height) const { |
3046 return (!send_preferred_size_changes_ || | 3058 return (!send_preferred_size_changes_ || |
3047 (disable_scrollbars_size_limit_.width() <= width || | 3059 (disable_scrollbars_size_limit_.width() <= width || |
3048 disable_scrollbars_size_limit_.height() <= height)); | 3060 disable_scrollbars_size_limit_.height() <= height)); |
3049 } | 3061 } |
3050 | 3062 |
3051 int RenderView::GetEnabledBindings() { | 3063 int RenderViewImpl::GetEnabledBindings() { |
3052 return enabled_bindings_; | 3064 return enabled_bindings_; |
3053 } | 3065 } |
3054 | 3066 |
3055 void RenderView::SetEnabledBindings(int enabled_bindings) { | 3067 void RenderViewImpl::SetEnabledBindings(int enabled_bindings) { |
3056 enabled_bindings_ = enabled_bindings; | 3068 enabled_bindings_ = enabled_bindings; |
3057 } | 3069 } |
3058 | 3070 |
3059 bool RenderView::GetContentStateImmediately() { | 3071 bool RenderViewImpl::GetContentStateImmediately() { |
3060 return send_content_state_immediately_; | 3072 return send_content_state_immediately_; |
3061 } | 3073 } |
3062 | 3074 |
3063 float RenderView::GetFilteredTimePerFrame() { | 3075 float RenderViewImpl::GetFilteredTimePerFrame() { |
3064 return filtered_time_per_frame(); | 3076 return filtered_time_per_frame(); |
3065 } | 3077 } |
3066 | 3078 |
3067 void RenderView::ShowContextMenu(WebKit::WebFrame* frame, | 3079 void RenderViewImpl::ShowContextMenu(WebKit::WebFrame* frame, |
3068 const WebKit::WebContextMenuData& data) { | 3080 const WebKit::WebContextMenuData& data) { |
3069 showContextMenu(frame, data); | 3081 showContextMenu(frame, data); |
3070 } | 3082 } |
3071 | 3083 |
3072 WebKit::WebPageVisibilityState RenderView::GetVisibilityState() const { | 3084 WebKit::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const { |
3073 return visibilityState(); | 3085 return visibilityState(); |
3074 } | 3086 } |
3075 | 3087 |
3076 void RenderView::RunModalAlertDialog(WebKit::WebFrame* frame, | 3088 void RenderViewImpl::RunModalAlertDialog(WebKit::WebFrame* frame, |
3077 const WebKit::WebString& message) { | 3089 const WebKit::WebString& message) { |
3078 return runModalAlertDialog(frame, message); | 3090 return runModalAlertDialog(frame, message); |
3079 } | 3091 } |
3080 | 3092 |
3081 void RenderView::LoadURLExternally( | 3093 void RenderViewImpl::LoadURLExternally( |
3082 WebKit::WebFrame* frame, | 3094 WebKit::WebFrame* frame, |
3083 const WebKit::WebURLRequest& request, | 3095 const WebKit::WebURLRequest& request, |
3084 WebKit::WebNavigationPolicy policy) { | 3096 WebKit::WebNavigationPolicy policy) { |
3085 loadURLExternally(frame, request, policy); | 3097 loadURLExternally(frame, request, policy); |
3086 } | 3098 } |
3087 | 3099 |
3088 // webkit_glue::WebPluginPageDelegate ------------------------------------------ | 3100 // webkit_glue::WebPluginPageDelegate ------------------------------------------ |
3089 | 3101 |
3090 webkit::npapi::WebPluginDelegate* RenderView::CreatePluginDelegate( | 3102 webkit::npapi::WebPluginDelegate* RenderViewImpl::CreatePluginDelegate( |
3091 const FilePath& file_path, | 3103 const FilePath& file_path, |
3092 const std::string& mime_type) { | 3104 const std::string& mime_type) { |
3093 if (!PluginChannelHost::IsListening()) | 3105 if (!PluginChannelHost::IsListening()) |
3094 return NULL; | 3106 return NULL; |
3095 | 3107 |
3096 bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); | 3108 bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); |
3097 if (in_process_plugin) { | 3109 if (in_process_plugin) { |
3098 #if defined(OS_WIN) && !defined(USE_AURA) | 3110 #if defined(OS_WIN) && !defined(USE_AURA) |
3099 return webkit::npapi::WebPluginDelegateImpl::Create( | 3111 return webkit::npapi::WebPluginDelegateImpl::Create( |
3100 file_path, mime_type, gfx::NativeViewFromId(host_window_)); | 3112 file_path, mime_type, gfx::NativeViewFromId(host_window_)); |
3101 #else | 3113 #else |
3102 // In-proc plugins aren't supported on non-Windows. | 3114 // In-proc plugins aren't supported on non-Windows. |
3103 NOTIMPLEMENTED(); | 3115 NOTIMPLEMENTED(); |
3104 return NULL; | 3116 return NULL; |
3105 #endif | 3117 #endif |
3106 } | 3118 } |
3107 | 3119 |
3108 return new WebPluginDelegateProxy(mime_type, AsWeakPtr()); | 3120 return new WebPluginDelegateProxy(mime_type, AsWeakPtr()); |
3109 } | 3121 } |
3110 | 3122 |
3111 void RenderView::CreatedPluginWindow(gfx::PluginWindowHandle window) { | 3123 void RenderViewImpl::CreatedPluginWindow(gfx::PluginWindowHandle window) { |
3112 #if defined(USE_X11) | 3124 #if defined(USE_X11) |
3113 Send(new ViewHostMsg_CreatePluginContainer(routing_id(), window)); | 3125 Send(new ViewHostMsg_CreatePluginContainer(routing_id(), window)); |
3114 #endif | 3126 #endif |
3115 } | 3127 } |
3116 | 3128 |
3117 void RenderView::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { | 3129 void RenderViewImpl::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { |
3118 #if defined(USE_X11) | 3130 #if defined(USE_X11) |
3119 Send(new ViewHostMsg_DestroyPluginContainer(routing_id(), window)); | 3131 Send(new ViewHostMsg_DestroyPluginContainer(routing_id(), window)); |
3120 #endif | 3132 #endif |
3121 CleanupWindowInPluginMoves(window); | 3133 CleanupWindowInPluginMoves(window); |
3122 } | 3134 } |
3123 | 3135 |
3124 void RenderView::DidMovePlugin(const webkit::npapi::WebPluginGeometry& move) { | 3136 void RenderViewImpl::DidMovePlugin( |
| 3137 const webkit::npapi::WebPluginGeometry& move) { |
3125 SchedulePluginMove(move); | 3138 SchedulePluginMove(move); |
3126 } | 3139 } |
3127 | 3140 |
3128 void RenderView::DidStartLoadingForPlugin() { | 3141 void RenderViewImpl::DidStartLoadingForPlugin() { |
3129 // TODO(darin): Make is_loading_ be a counter! | 3142 // TODO(darin): Make is_loading_ be a counter! |
3130 didStartLoading(); | 3143 didStartLoading(); |
3131 } | 3144 } |
3132 | 3145 |
3133 void RenderView::DidStopLoadingForPlugin() { | 3146 void RenderViewImpl::DidStopLoadingForPlugin() { |
3134 // TODO(darin): Make is_loading_ be a counter! | 3147 // TODO(darin): Make is_loading_ be a counter! |
3135 didStopLoading(); | 3148 didStopLoading(); |
3136 } | 3149 } |
3137 | 3150 |
3138 WebCookieJar* RenderView::GetCookieJar() { | 3151 WebCookieJar* RenderViewImpl::GetCookieJar() { |
3139 return &cookie_jar_; | 3152 return &cookie_jar_; |
3140 } | 3153 } |
3141 | 3154 |
3142 void RenderView::SyncNavigationState() { | 3155 void RenderViewImpl::SyncNavigationState() { |
3143 if (!webview()) | 3156 if (!webview()) |
3144 return; | 3157 return; |
3145 | 3158 |
3146 const WebHistoryItem& item = webview()->mainFrame()->currentHistoryItem(); | 3159 const WebHistoryItem& item = webview()->mainFrame()->currentHistoryItem(); |
3147 if (item.isNull()) | 3160 if (item.isNull()) |
3148 return; | 3161 return; |
3149 | 3162 |
3150 Send(new ViewHostMsg_UpdateState( | 3163 Send(new ViewHostMsg_UpdateState( |
3151 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 3164 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
3152 } | 3165 } |
3153 | 3166 |
3154 void RenderView::SyncSelectionIfRequired() { | 3167 void RenderViewImpl::SyncSelectionIfRequired() { |
3155 WebFrame* frame = webview()->focusedFrame(); | 3168 WebFrame* frame = webview()->focusedFrame(); |
3156 const std::string& text = frame->selectionAsText().utf8(); | 3169 const std::string& text = frame->selectionAsText().utf8(); |
3157 | 3170 |
3158 ui::Range range(ui::Range::InvalidRange()); | 3171 ui::Range range(ui::Range::InvalidRange()); |
3159 size_t location, length; | 3172 size_t location, length; |
3160 if (webview()->caretOrSelectionRange(&location, &length)) { | 3173 if (webview()->caretOrSelectionRange(&location, &length)) { |
3161 range.set_start(location); | 3174 range.set_start(location); |
3162 range.set_end(location + length); | 3175 range.set_end(location + length); |
3163 } | 3176 } |
3164 | 3177 |
3165 WebPoint start, end; | 3178 WebPoint start, end; |
3166 webview()->selectionRange(start, end); | 3179 webview()->selectionRange(start, end); |
3167 | 3180 |
3168 RenderViewSelection this_selection(text, range, start, end); | 3181 RenderViewSelection this_selection(text, range, start, end); |
3169 | 3182 |
3170 // Sometimes we get repeated didChangeSelection calls from webkit when | 3183 // Sometimes we get repeated didChangeSelection calls from webkit when |
3171 // the selection hasn't actually changed. We don't want to report these | 3184 // the selection hasn't actually changed. We don't want to report these |
3172 // because it will cause us to continually claim the X clipboard. | 3185 // because it will cause us to continually claim the X clipboard. |
3173 if (this_selection.Equals(last_selection_)) | 3186 if (this_selection.Equals(last_selection_)) |
3174 return; | 3187 return; |
3175 last_selection_ = this_selection; | 3188 last_selection_ = this_selection; |
3176 | 3189 |
3177 Send(new ViewHostMsg_SelectionChanged(routing_id_, text, range, | 3190 Send(new ViewHostMsg_SelectionChanged(routing_id_, text, range, |
3178 start, end)); | 3191 start, end)); |
3179 } | 3192 } |
3180 | 3193 |
3181 GURL RenderView::GetAlternateErrorPageURL(const GURL& failed_url, | 3194 GURL RenderViewImpl::GetAlternateErrorPageURL(const GURL& failed_url, |
3182 ErrorPageType error_type) { | 3195 ErrorPageType error_type) { |
3183 if (failed_url.SchemeIsSecure()) { | 3196 if (failed_url.SchemeIsSecure()) { |
3184 // If the URL that failed was secure, then the embedding web page was not | 3197 // If the URL that failed was secure, then the embedding web page was not |
3185 // expecting a network attacker to be able to manipulate its contents. As | 3198 // expecting a network attacker to be able to manipulate its contents. As |
3186 // we fetch alternate error pages over HTTP, we would be allowing a network | 3199 // we fetch alternate error pages over HTTP, we would be allowing a network |
3187 // attacker to manipulate the contents of the response if we tried to use | 3200 // attacker to manipulate the contents of the response if we tried to use |
3188 // the link doctor here. | 3201 // the link doctor here. |
3189 return GURL(); | 3202 return GURL(); |
3190 } | 3203 } |
3191 | 3204 |
3192 // Grab the base URL from the browser process. | 3205 // Grab the base URL from the browser process. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3228 NOTREACHED() << "unknown ErrorPageType"; | 3241 NOTREACHED() << "unknown ErrorPageType"; |
3229 } | 3242 } |
3230 | 3243 |
3231 // OK, build the final url to return. | 3244 // OK, build the final url to return. |
3232 GURL::Replacements link_doctor_params; | 3245 GURL::Replacements link_doctor_params; |
3233 link_doctor_params.SetQueryStr(params); | 3246 link_doctor_params.SetQueryStr(params); |
3234 GURL url = alternate_error_page_url_.ReplaceComponents(link_doctor_params); | 3247 GURL url = alternate_error_page_url_.ReplaceComponents(link_doctor_params); |
3235 return url; | 3248 return url; |
3236 } | 3249 } |
3237 | 3250 |
3238 GURL RenderView::GetOpenerUrl() const { | 3251 GURL RenderViewImpl::GetOpenerUrl() const { |
3239 if (opener_id_ == MSG_ROUTING_NONE || opener_suppressed_) | 3252 if (opener_id_ == MSG_ROUTING_NONE || opener_suppressed_) |
3240 return GURL(); | 3253 return GURL(); |
3241 else | 3254 else |
3242 return creator_url_; | 3255 return creator_url_; |
3243 } | 3256 } |
3244 | 3257 |
3245 WebUIBindings* RenderView::GetWebUIBindings() { | 3258 WebUIBindings* RenderViewImpl::GetWebUIBindings() { |
3246 if (!web_ui_bindings_.get()) { | 3259 if (!web_ui_bindings_.get()) { |
3247 web_ui_bindings_.reset(new WebUIBindings( | 3260 web_ui_bindings_.reset(new WebUIBindings( |
3248 static_cast<content::RenderView*>(this), routing_id_)); | 3261 static_cast<content::RenderView*>(this), routing_id_)); |
3249 } | 3262 } |
3250 return web_ui_bindings_.get(); | 3263 return web_ui_bindings_.get(); |
3251 } | 3264 } |
3252 | 3265 |
3253 WebKit::WebPlugin* RenderView::GetWebPluginFromPluginDocument() { | 3266 WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { |
3254 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); | 3267 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
3255 } | 3268 } |
3256 | 3269 |
3257 void RenderView::OnFind(int request_id, const string16& search_text, | 3270 void RenderViewImpl::OnFind(int request_id, const string16& search_text, |
3258 const WebFindOptions& options) { | 3271 const WebFindOptions& options) { |
3259 WebFrame* main_frame = webview()->mainFrame(); | 3272 WebFrame* main_frame = webview()->mainFrame(); |
3260 | 3273 |
3261 // Check if the plugin still exists in the document. | 3274 // Check if the plugin still exists in the document. |
3262 if (main_frame->document().isPluginDocument() && | 3275 if (main_frame->document().isPluginDocument() && |
3263 GetWebPluginFromPluginDocument()) { | 3276 GetWebPluginFromPluginDocument()) { |
3264 if (options.findNext) { | 3277 if (options.findNext) { |
3265 // Just navigate back/forward. | 3278 // Just navigate back/forward. |
3266 GetWebPluginFromPluginDocument()->selectFindResult(options.forward); | 3279 GetWebPluginFromPluginDocument()->selectFindResult(options.forward); |
3267 } else { | 3280 } else { |
3268 if (GetWebPluginFromPluginDocument()->startFind( | 3281 if (GetWebPluginFromPluginDocument()->startFind( |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3375 true); // reset the tickmarks | 3388 true); // reset the tickmarks |
3376 } | 3389 } |
3377 | 3390 |
3378 // Iterate to the next frame. The frame will not necessarily scope, for | 3391 // Iterate to the next frame. The frame will not necessarily scope, for |
3379 // example if it is not visible. | 3392 // example if it is not visible. |
3380 search_frame = search_frame->traverseNext(true); | 3393 search_frame = search_frame->traverseNext(true); |
3381 } while (search_frame != main_frame); | 3394 } while (search_frame != main_frame); |
3382 } | 3395 } |
3383 } | 3396 } |
3384 | 3397 |
3385 void RenderView::OnStopFinding(const ViewMsg_StopFinding_Params& params) { | 3398 void RenderViewImpl::OnStopFinding(const ViewMsg_StopFinding_Params& params) { |
3386 WebView* view = webview(); | 3399 WebView* view = webview(); |
3387 if (!view) | 3400 if (!view) |
3388 return; | 3401 return; |
3389 | 3402 |
3390 WebDocument doc = view->mainFrame()->document(); | 3403 WebDocument doc = view->mainFrame()->document(); |
3391 if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) { | 3404 if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) { |
3392 GetWebPluginFromPluginDocument()->stopFind(); | 3405 GetWebPluginFromPluginDocument()->stopFind(); |
3393 return; | 3406 return; |
3394 } | 3407 } |
3395 | 3408 |
(...skipping 14 matching lines...) Expand all Loading... |
3410 WebDocument doc = focused_frame->document(); | 3423 WebDocument doc = focused_frame->document(); |
3411 if (!doc.isNull()) { | 3424 if (!doc.isNull()) { |
3412 WebNode node = doc.focusedNode(); | 3425 WebNode node = doc.focusedNode(); |
3413 if (!node.isNull()) | 3426 if (!node.isNull()) |
3414 node.simulateClick(); | 3427 node.simulateClick(); |
3415 } | 3428 } |
3416 } | 3429 } |
3417 } | 3430 } |
3418 } | 3431 } |
3419 | 3432 |
3420 void RenderView::OnFindReplyAck() { | 3433 void RenderViewImpl::OnFindReplyAck() { |
3421 // Check if there is any queued up request waiting to be sent. | 3434 // Check if there is any queued up request waiting to be sent. |
3422 if (queued_find_reply_message_.get()) { | 3435 if (queued_find_reply_message_.get()) { |
3423 // Send the search result over to the browser process. | 3436 // Send the search result over to the browser process. |
3424 Send(queued_find_reply_message_.release()); | 3437 Send(queued_find_reply_message_.release()); |
3425 } | 3438 } |
3426 } | 3439 } |
3427 | 3440 |
3428 void RenderView::OnZoom(PageZoom::Function function) { | 3441 void RenderViewImpl::OnZoom(PageZoom::Function function) { |
3429 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 3442 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
3430 return; | 3443 return; |
3431 | 3444 |
3432 webview()->hidePopups(); | 3445 webview()->hidePopups(); |
3433 #if !defined(TOUCH_UI) | 3446 #if !defined(TOUCH_UI) |
3434 double old_zoom_level = webview()->zoomLevel(); | 3447 double old_zoom_level = webview()->zoomLevel(); |
3435 double zoom_level; | 3448 double zoom_level; |
3436 if (function == PageZoom::RESET) { | 3449 if (function == PageZoom::RESET) { |
3437 zoom_level = 0; | 3450 zoom_level = 0; |
3438 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { | 3451 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { |
(...skipping 20 matching lines...) Expand all Loading... |
3459 page_scale_factor = 1.0; | 3472 page_scale_factor = 1.0; |
3460 } else { | 3473 } else { |
3461 page_scale_factor = old_page_scale_factor + | 3474 page_scale_factor = old_page_scale_factor + |
3462 (function > 0 ? kScalingIncrement : -kScalingIncrement); | 3475 (function > 0 ? kScalingIncrement : -kScalingIncrement); |
3463 } | 3476 } |
3464 webview()->scalePage(page_scale_factor, WebPoint(0, 0)); | 3477 webview()->scalePage(page_scale_factor, WebPoint(0, 0)); |
3465 #endif | 3478 #endif |
3466 zoomLevelChanged(); | 3479 zoomLevelChanged(); |
3467 } | 3480 } |
3468 | 3481 |
3469 void RenderView::OnSetZoomLevel(double zoom_level) { | 3482 void RenderViewImpl::OnSetZoomLevel(double zoom_level) { |
3470 // Don't set zoom level for full-page plugin since they don't use the same | 3483 // Don't set zoom level for full-page plugin since they don't use the same |
3471 // zoom settings. | 3484 // zoom settings. |
3472 if (webview()->mainFrame()->document().isPluginDocument()) | 3485 if (webview()->mainFrame()->document().isPluginDocument()) |
3473 return; | 3486 return; |
3474 | 3487 |
3475 webview()->hidePopups(); | 3488 webview()->hidePopups(); |
3476 webview()->setZoomLevel(false, zoom_level); | 3489 webview()->setZoomLevel(false, zoom_level); |
3477 zoomLevelChanged(); | 3490 zoomLevelChanged(); |
3478 } | 3491 } |
3479 | 3492 |
3480 void RenderView::OnSetZoomLevelForLoadingURL(const GURL& url, | 3493 void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, |
3481 double zoom_level) { | 3494 double zoom_level) { |
3482 host_zoom_levels_[url] = zoom_level; | 3495 host_zoom_levels_[url] = zoom_level; |
3483 } | 3496 } |
3484 | 3497 |
3485 void RenderView::OnExitFullscreen() { | 3498 void RenderViewImpl::OnExitFullscreen() { |
3486 webview()->exitFullscreen(); | 3499 webview()->exitFullscreen(); |
3487 } | 3500 } |
3488 | 3501 |
3489 void RenderView::OnSetPageEncoding(const std::string& encoding_name) { | 3502 void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) { |
3490 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); | 3503 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); |
3491 } | 3504 } |
3492 | 3505 |
3493 void RenderView::OnResetPageEncodingToDefault() { | 3506 void RenderViewImpl::OnResetPageEncodingToDefault() { |
3494 WebString no_encoding; | 3507 WebString no_encoding; |
3495 webview()->setPageEncoding(no_encoding); | 3508 webview()->setPageEncoding(no_encoding); |
3496 } | 3509 } |
3497 | 3510 |
3498 WebFrame* RenderView::GetChildFrame(const string16& xpath) const { | 3511 WebFrame* RenderViewImpl::GetChildFrame(const string16& xpath) const { |
3499 if (xpath.empty()) | 3512 if (xpath.empty()) |
3500 return webview()->mainFrame(); | 3513 return webview()->mainFrame(); |
3501 | 3514 |
3502 // xpath string can represent a frame deep down the tree (across multiple | 3515 // xpath string can represent a frame deep down the tree (across multiple |
3503 // frame DOMs). | 3516 // frame DOMs). |
3504 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0] | 3517 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0] |
3505 // should break into 2 xpaths | 3518 // should break into 2 xpaths |
3506 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0] | 3519 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0] |
3507 std::vector<string16> xpaths; | 3520 std::vector<string16> xpaths; |
3508 base::SplitString(xpath, '\n', &xpaths); | 3521 base::SplitString(xpath, '\n', &xpaths); |
3509 | 3522 |
3510 WebFrame* frame = webview()->mainFrame(); | 3523 WebFrame* frame = webview()->mainFrame(); |
3511 for (std::vector<string16>::const_iterator i = xpaths.begin(); | 3524 for (std::vector<string16>::const_iterator i = xpaths.begin(); |
3512 frame && i != xpaths.end(); ++i) { | 3525 frame && i != xpaths.end(); ++i) { |
3513 frame = frame->findChildByExpression(*i); | 3526 frame = frame->findChildByExpression(*i); |
3514 } | 3527 } |
3515 | 3528 |
3516 return frame; | 3529 return frame; |
3517 } | 3530 } |
3518 | 3531 |
3519 void RenderView::OnScriptEvalRequest(const string16& frame_xpath, | 3532 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, |
3520 const string16& jscript, | 3533 const string16& jscript, |
3521 int id, | 3534 int id, |
3522 bool notify_result) { | 3535 bool notify_result) { |
3523 EvaluateScript(frame_xpath, jscript, id, notify_result); | 3536 EvaluateScript(frame_xpath, jscript, id, notify_result); |
3524 } | 3537 } |
3525 | 3538 |
3526 void RenderView::OnCSSInsertRequest(const string16& frame_xpath, | 3539 void RenderViewImpl::OnCSSInsertRequest(const string16& frame_xpath, |
3527 const std::string& css) { | 3540 const std::string& css) { |
3528 WebFrame* frame = GetChildFrame(frame_xpath); | 3541 WebFrame* frame = GetChildFrame(frame_xpath); |
3529 if (!frame) | 3542 if (!frame) |
3530 return; | 3543 return; |
3531 | 3544 |
3532 frame->document().insertUserStyleSheet( | 3545 frame->document().insertUserStyleSheet( |
3533 WebString::fromUTF8(css), | 3546 WebString::fromUTF8(css), |
3534 WebDocument::UserStyleAuthorLevel); | 3547 WebDocument::UserStyleAuthorLevel); |
3535 } | 3548 } |
3536 | 3549 |
3537 void RenderView::OnAllowBindings(int enabled_bindings_flags) { | 3550 void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
3538 enabled_bindings_ |= enabled_bindings_flags; | 3551 enabled_bindings_ |= enabled_bindings_flags; |
3539 } | 3552 } |
3540 | 3553 |
3541 void RenderView::OnSetWebUIProperty(const std::string& name, | 3554 void RenderViewImpl::OnSetWebUIProperty(const std::string& name, |
3542 const std::string& value) { | 3555 const std::string& value) { |
3543 DCHECK(BindingsPolicy::is_web_ui_enabled(enabled_bindings_)); | 3556 DCHECK(BindingsPolicy::is_web_ui_enabled(enabled_bindings_)); |
3544 GetWebUIBindings()->SetProperty(name, value); | 3557 GetWebUIBindings()->SetProperty(name, value); |
3545 } | 3558 } |
3546 | 3559 |
3547 void RenderView::OnReservePageIDRange(int size_of_range) { | 3560 void RenderViewImpl::OnReservePageIDRange(int size_of_range) { |
3548 next_page_id_ += size_of_range + 1; | 3561 next_page_id_ += size_of_range + 1; |
3549 } | 3562 } |
3550 | 3563 |
3551 void RenderView::OnDragTargetDragEnter(const WebDropData& drop_data, | 3564 void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, |
3552 const gfx::Point& client_point, | 3565 const gfx::Point& client_point, |
3553 const gfx::Point& screen_point, | 3566 const gfx::Point& screen_point, |
3554 WebDragOperationsMask ops) { | 3567 WebDragOperationsMask ops) { |
3555 WebDragOperation operation = webview()->dragTargetDragEnter( | 3568 WebDragOperation operation = webview()->dragTargetDragEnter( |
3556 drop_data.ToDragData(), | 3569 drop_data.ToDragData(), |
3557 client_point, | 3570 client_point, |
3558 screen_point, | 3571 screen_point, |
3559 ops); | 3572 ops); |
3560 | 3573 |
3561 Send(new DragHostMsg_UpdateDragCursor(routing_id_, operation)); | 3574 Send(new DragHostMsg_UpdateDragCursor(routing_id_, operation)); |
3562 } | 3575 } |
3563 | 3576 |
3564 void RenderView::OnDragTargetDragOver(const gfx::Point& client_point, | 3577 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, |
3565 const gfx::Point& screen_point, | 3578 const gfx::Point& screen_point, |
3566 WebDragOperationsMask ops) { | 3579 WebDragOperationsMask ops) { |
3567 WebDragOperation operation = webview()->dragTargetDragOver( | 3580 WebDragOperation operation = webview()->dragTargetDragOver( |
3568 client_point, | 3581 client_point, |
3569 screen_point, | 3582 screen_point, |
3570 ops); | 3583 ops); |
3571 | 3584 |
3572 Send(new DragHostMsg_UpdateDragCursor(routing_id_, operation)); | 3585 Send(new DragHostMsg_UpdateDragCursor(routing_id_, operation)); |
3573 } | 3586 } |
3574 | 3587 |
3575 void RenderView::OnDragTargetDragLeave() { | 3588 void RenderViewImpl::OnDragTargetDragLeave() { |
3576 webview()->dragTargetDragLeave(); | 3589 webview()->dragTargetDragLeave(); |
3577 } | 3590 } |
3578 | 3591 |
3579 void RenderView::OnDragTargetDrop(const gfx::Point& client_point, | 3592 void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, |
3580 const gfx::Point& screen_point) { | 3593 const gfx::Point& screen_point) { |
3581 webview()->dragTargetDrop(client_point, screen_point); | 3594 webview()->dragTargetDrop(client_point, screen_point); |
3582 | 3595 |
3583 Send(new DragHostMsg_TargetDrop_ACK(routing_id_)); | 3596 Send(new DragHostMsg_TargetDrop_ACK(routing_id_)); |
3584 } | 3597 } |
3585 | 3598 |
3586 void RenderView::OnDragSourceEndedOrMoved(const gfx::Point& client_point, | 3599 void RenderViewImpl::OnDragSourceEndedOrMoved(const gfx::Point& client_point, |
3587 const gfx::Point& screen_point, | 3600 const gfx::Point& screen_point, |
3588 bool ended, | 3601 bool ended, |
3589 WebDragOperation op) { | 3602 WebDragOperation op) { |
3590 if (ended) { | 3603 if (ended) { |
3591 webview()->dragSourceEndedAt(client_point, screen_point, op); | 3604 webview()->dragSourceEndedAt(client_point, screen_point, op); |
3592 } else { | 3605 } else { |
3593 webview()->dragSourceMovedTo(client_point, screen_point, op); | 3606 webview()->dragSourceMovedTo(client_point, screen_point, op); |
3594 } | 3607 } |
3595 } | 3608 } |
3596 | 3609 |
3597 void RenderView::OnDragSourceSystemDragEnded() { | 3610 void RenderViewImpl::OnDragSourceSystemDragEnded() { |
3598 webview()->dragSourceSystemDragEnded(); | 3611 webview()->dragSourceSystemDragEnded(); |
3599 } | 3612 } |
3600 | 3613 |
3601 void RenderView::OnUpdateWebPreferences(const WebPreferences& prefs) { | 3614 void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { |
3602 webkit_preferences_ = prefs; | 3615 webkit_preferences_ = prefs; |
3603 webkit_preferences_.Apply(webview()); | 3616 webkit_preferences_.Apply(webview()); |
3604 } | 3617 } |
3605 | 3618 |
3606 void RenderView::OnUpdateRemoteAccessClientFirewallTraversal( | 3619 void RenderViewImpl::OnUpdateRemoteAccessClientFirewallTraversal( |
3607 const std::string& policy) { | 3620 const std::string& policy) { |
3608 pepper_delegate_.PublishPolicy(policy); | 3621 pepper_delegate_.PublishPolicy(policy); |
3609 } | 3622 } |
3610 | 3623 |
3611 void RenderView::OnSetAltErrorPageURL(const GURL& url) { | 3624 void RenderViewImpl::OnSetAltErrorPageURL(const GURL& url) { |
3612 alternate_error_page_url_ = url; | 3625 alternate_error_page_url_ = url; |
3613 } | 3626 } |
3614 | 3627 |
3615 void RenderView::OnCustomContextMenuAction( | 3628 void RenderViewImpl::OnCustomContextMenuAction( |
3616 const webkit_glue::CustomContextMenuContext& custom_context, | 3629 const webkit_glue::CustomContextMenuContext& custom_context, |
3617 unsigned action) { | 3630 unsigned action) { |
3618 if (custom_context.is_pepper_menu) | 3631 if (custom_context.is_pepper_menu) |
3619 pepper_delegate_.OnCustomContextMenuAction(custom_context, action); | 3632 pepper_delegate_.OnCustomContextMenuAction(custom_context, action); |
3620 else | 3633 else |
3621 webview()->performCustomContextMenuAction(action); | 3634 webview()->performCustomContextMenuAction(action); |
3622 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 3635 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
3623 ContextMenuAction(action)); | 3636 ContextMenuAction(action)); |
3624 } | 3637 } |
3625 | 3638 |
3626 void RenderView::OnEnumerateDirectoryResponse( | 3639 void RenderViewImpl::OnEnumerateDirectoryResponse( |
3627 int id, | 3640 int id, |
3628 const std::vector<FilePath>& paths) { | 3641 const std::vector<FilePath>& paths) { |
3629 if (!enumeration_completions_[id]) | 3642 if (!enumeration_completions_[id]) |
3630 return; | 3643 return; |
3631 | 3644 |
3632 WebVector<WebString> ws_file_names(paths.size()); | 3645 WebVector<WebString> ws_file_names(paths.size()); |
3633 for (size_t i = 0; i < paths.size(); ++i) | 3646 for (size_t i = 0; i < paths.size(); ++i) |
3634 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); | 3647 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); |
3635 | 3648 |
3636 enumeration_completions_[id]->didChooseFile(ws_file_names); | 3649 enumeration_completions_[id]->didChooseFile(ws_file_names); |
3637 enumeration_completions_.erase(id); | 3650 enumeration_completions_.erase(id); |
3638 } | 3651 } |
3639 | 3652 |
3640 void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) { | 3653 void RenderViewImpl::OnFileChooserResponse(const std::vector<FilePath>& paths) { |
3641 // This could happen if we navigated to a different page before the user | 3654 // This could happen if we navigated to a different page before the user |
3642 // closed the chooser. | 3655 // closed the chooser. |
3643 if (file_chooser_completions_.empty()) | 3656 if (file_chooser_completions_.empty()) |
3644 return; | 3657 return; |
3645 | 3658 |
3646 WebVector<WebString> ws_file_names(paths.size()); | 3659 WebVector<WebString> ws_file_names(paths.size()); |
3647 for (size_t i = 0; i < paths.size(); ++i) | 3660 for (size_t i = 0; i < paths.size(); ++i) |
3648 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); | 3661 ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); |
3649 | 3662 |
3650 if (file_chooser_completions_.front()->completion) | 3663 if (file_chooser_completions_.front()->completion) |
3651 file_chooser_completions_.front()->completion->didChooseFile(ws_file_names); | 3664 file_chooser_completions_.front()->completion->didChooseFile(ws_file_names); |
3652 file_chooser_completions_.pop_front(); | 3665 file_chooser_completions_.pop_front(); |
3653 | 3666 |
3654 // If there are more pending file chooser requests, schedule one now. | 3667 // If there are more pending file chooser requests, schedule one now. |
3655 if (!file_chooser_completions_.empty()) { | 3668 if (!file_chooser_completions_.empty()) { |
3656 Send(new ViewHostMsg_RunFileChooser(routing_id_, | 3669 Send(new ViewHostMsg_RunFileChooser(routing_id_, |
3657 file_chooser_completions_.front()->params)); | 3670 file_chooser_completions_.front()->params)); |
3658 } | 3671 } |
3659 } | 3672 } |
3660 | 3673 |
3661 void RenderView::OnEnablePreferredSizeChangedMode(int flags) { | 3674 void RenderViewImpl::OnEnablePreferredSizeChangedMode(int flags) { |
3662 DCHECK(flags != kPreferredSizeNothing); | 3675 DCHECK(flags != kPreferredSizeNothing); |
3663 if (send_preferred_size_changes_) | 3676 if (send_preferred_size_changes_) |
3664 return; | 3677 return; |
3665 send_preferred_size_changes_ = true; | 3678 send_preferred_size_changes_ = true; |
3666 | 3679 |
3667 // Start off with an initial preferred size notification (in case | 3680 // Start off with an initial preferred size notification (in case |
3668 // |didUpdateLayout| was already called). | 3681 // |didUpdateLayout| was already called). |
3669 if (webview()) | 3682 if (webview()) |
3670 didUpdateLayout(webview()->mainFrame()); | 3683 didUpdateLayout(webview()->mainFrame()); |
3671 } | 3684 } |
3672 | 3685 |
3673 void RenderView::OnDisableScrollbarsForSmallWindows( | 3686 void RenderViewImpl::OnDisableScrollbarsForSmallWindows( |
3674 const gfx::Size& disable_scrollbar_size_limit) { | 3687 const gfx::Size& disable_scrollbar_size_limit) { |
3675 disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; | 3688 disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; |
3676 } | 3689 } |
3677 | 3690 |
3678 void RenderView::OnSetRendererPrefs(const RendererPreferences& renderer_prefs) { | 3691 void RenderViewImpl::OnSetRendererPrefs( |
| 3692 const RendererPreferences& renderer_prefs) { |
3679 renderer_preferences_ = renderer_prefs; | 3693 renderer_preferences_ = renderer_prefs; |
3680 UpdateFontRenderingFromRendererPrefs(); | 3694 UpdateFontRenderingFromRendererPrefs(); |
3681 #if defined(TOOLKIT_USES_GTK) | 3695 #if defined(TOOLKIT_USES_GTK) |
3682 WebColorName name = WebKit::WebColorWebkitFocusRingColor; | 3696 WebColorName name = WebKit::WebColorWebkitFocusRingColor; |
3683 WebKit::setNamedColors(&name, &renderer_prefs.focus_ring_color, 1); | 3697 WebKit::setNamedColors(&name, &renderer_prefs.focus_ring_color, 1); |
3684 WebKit::setCaretBlinkInterval(renderer_prefs.caret_blink_interval); | 3698 WebKit::setCaretBlinkInterval(renderer_prefs.caret_blink_interval); |
3685 gfx::NativeTheme::instance()->SetScrollbarColors( | 3699 gfx::NativeTheme::instance()->SetScrollbarColors( |
3686 renderer_prefs.thumb_inactive_color, | 3700 renderer_prefs.thumb_inactive_color, |
3687 renderer_prefs.thumb_active_color, | 3701 renderer_prefs.thumb_active_color, |
3688 renderer_prefs.track_color); | 3702 renderer_prefs.track_color); |
3689 | 3703 |
3690 if (webview()) { | 3704 if (webview()) { |
3691 webview()->setScrollbarColors( | 3705 webview()->setScrollbarColors( |
3692 renderer_prefs.thumb_inactive_color, | 3706 renderer_prefs.thumb_inactive_color, |
3693 renderer_prefs.thumb_active_color, | 3707 renderer_prefs.thumb_active_color, |
3694 renderer_prefs.track_color); | 3708 renderer_prefs.track_color); |
3695 webview()->setSelectionColors( | 3709 webview()->setSelectionColors( |
3696 renderer_prefs.active_selection_bg_color, | 3710 renderer_prefs.active_selection_bg_color, |
3697 renderer_prefs.active_selection_fg_color, | 3711 renderer_prefs.active_selection_fg_color, |
3698 renderer_prefs.inactive_selection_bg_color, | 3712 renderer_prefs.inactive_selection_bg_color, |
3699 renderer_prefs.inactive_selection_fg_color); | 3713 renderer_prefs.inactive_selection_fg_color); |
3700 webview()->themeChanged(); | 3714 webview()->themeChanged(); |
3701 } | 3715 } |
3702 #endif | 3716 #endif |
3703 } | 3717 } |
3704 | 3718 |
3705 void RenderView::OnMediaPlayerActionAt(const gfx::Point& location, | 3719 void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location, |
3706 const WebMediaPlayerAction& action) { | 3720 const WebMediaPlayerAction& action) { |
3707 if (webview()) | 3721 if (webview()) |
3708 webview()->performMediaPlayerAction(action, location); | 3722 webview()->performMediaPlayerAction(action, location); |
3709 } | 3723 } |
3710 | 3724 |
3711 void RenderView::OnGetAllSavableResourceLinksForCurrentPage( | 3725 void RenderViewImpl::OnGetAllSavableResourceLinksForCurrentPage( |
3712 const GURL& page_url) { | 3726 const GURL& page_url) { |
3713 // Prepare list to storage all savable resource links. | 3727 // Prepare list to storage all savable resource links. |
3714 std::vector<GURL> resources_list; | 3728 std::vector<GURL> resources_list; |
3715 std::vector<GURL> referrers_list; | 3729 std::vector<GURL> referrers_list; |
3716 std::vector<GURL> frames_list; | 3730 std::vector<GURL> frames_list; |
3717 webkit_glue::SavableResourcesResult result(&resources_list, | 3731 webkit_glue::SavableResourcesResult result(&resources_list, |
3718 &referrers_list, | 3732 &referrers_list, |
3719 &frames_list); | 3733 &frames_list); |
3720 | 3734 |
3721 if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( | 3735 if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( |
3722 webview(), | 3736 webview(), |
3723 page_url, | 3737 page_url, |
3724 &result, | 3738 &result, |
3725 chrome::GetSavableSchemes())) { | 3739 chrome::GetSavableSchemes())) { |
3726 // If something is wrong when collecting all savable resource links, | 3740 // If something is wrong when collecting all savable resource links, |
3727 // send empty list to embedder(browser) to tell it failed. | 3741 // send empty list to embedder(browser) to tell it failed. |
3728 referrers_list.clear(); | 3742 referrers_list.clear(); |
3729 resources_list.clear(); | 3743 resources_list.clear(); |
3730 frames_list.clear(); | 3744 frames_list.clear(); |
3731 } | 3745 } |
3732 | 3746 |
3733 // Send result of all savable resource links to embedder. | 3747 // Send result of all savable resource links to embedder. |
3734 Send(new ViewHostMsg_SendCurrentPageAllSavableResourceLinks(routing_id(), | 3748 Send(new ViewHostMsg_SendCurrentPageAllSavableResourceLinks(routing_id(), |
3735 resources_list, | 3749 resources_list, |
3736 referrers_list, | 3750 referrers_list, |
3737 frames_list)); | 3751 frames_list)); |
3738 } | 3752 } |
3739 | 3753 |
3740 void RenderView::OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( | 3754 void RenderViewImpl::OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( |
3741 const std::vector<GURL>& links, | 3755 const std::vector<GURL>& links, |
3742 const std::vector<FilePath>& local_paths, | 3756 const std::vector<FilePath>& local_paths, |
3743 const FilePath& local_directory_name) { | 3757 const FilePath& local_directory_name) { |
3744 | 3758 |
3745 // Convert std::vector of GURLs to WebVector<WebURL> | 3759 // Convert std::vector of GURLs to WebVector<WebURL> |
3746 WebVector<WebURL> weburl_links(links); | 3760 WebVector<WebURL> weburl_links(links); |
3747 | 3761 |
3748 // Convert std::vector of std::strings to WebVector<WebString> | 3762 // Convert std::vector of std::strings to WebVector<WebString> |
3749 WebVector<WebString> webstring_paths(local_paths.size()); | 3763 WebVector<WebString> webstring_paths(local_paths.size()); |
3750 for (size_t i = 0; i < local_paths.size(); i++) | 3764 for (size_t i = 0; i < local_paths.size(); i++) |
3751 webstring_paths[i] = webkit_glue::FilePathToWebString(local_paths[i]); | 3765 webstring_paths[i] = webkit_glue::FilePathToWebString(local_paths[i]); |
3752 | 3766 |
3753 WebPageSerializer::serialize(webview()->mainFrame(), true, this, weburl_links, | 3767 WebPageSerializer::serialize(webview()->mainFrame(), true, this, weburl_links, |
3754 webstring_paths, | 3768 webstring_paths, |
3755 webkit_glue::FilePathToWebString( | 3769 webkit_glue::FilePathToWebString( |
3756 local_directory_name)); | 3770 local_directory_name)); |
3757 } | 3771 } |
3758 | 3772 |
3759 void RenderView::OnShouldClose() { | 3773 void RenderViewImpl::OnShouldClose() { |
3760 bool should_close = webview()->dispatchBeforeUnloadEvent(); | 3774 bool should_close = webview()->dispatchBeforeUnloadEvent(); |
3761 Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close)); | 3775 Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close)); |
3762 } | 3776 } |
3763 | 3777 |
3764 void RenderView::OnSwapOut(const ViewMsg_SwapOut_Params& params) { | 3778 void RenderViewImpl::OnSwapOut(const ViewMsg_SwapOut_Params& params) { |
3765 if (is_swapped_out_) | 3779 if (is_swapped_out_) |
3766 return; | 3780 return; |
3767 | 3781 |
3768 // Swap this RenderView out so the tab can navigate to a page rendered by a | 3782 // Swap this RenderView out so the tab can navigate to a page rendered by a |
3769 // different process. This involves running the unload handler and clearing | 3783 // different process. This involves running the unload handler and clearing |
3770 // the page. Once WasSwappedOut is called, we also allow this process to exit | 3784 // the page. Once WasSwappedOut is called, we also allow this process to exit |
3771 // if there are no other active RenderViews in it. | 3785 // if there are no other active RenderViews in it. |
3772 | 3786 |
3773 // Send an UpdateState message before we get swapped out. | 3787 // Send an UpdateState message before we get swapped out. |
3774 SyncNavigationState(); | 3788 SyncNavigationState(); |
(...skipping 10 matching lines...) Expand all Loading... |
3785 // beforeunload handler. For now, we just run it a second time silently. | 3799 // beforeunload handler. For now, we just run it a second time silently. |
3786 webview()->mainFrame()->loadHTMLString(std::string(), | 3800 webview()->mainFrame()->loadHTMLString(std::string(), |
3787 GURL("about:swappedout"), | 3801 GURL("about:swappedout"), |
3788 GURL("about:swappedout"), | 3802 GURL("about:swappedout"), |
3789 false); | 3803 false); |
3790 | 3804 |
3791 // Just echo back the params in the ACK. | 3805 // Just echo back the params in the ACK. |
3792 Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); | 3806 Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); |
3793 } | 3807 } |
3794 | 3808 |
3795 void RenderView::OnClosePage() { | 3809 void RenderViewImpl::OnClosePage() { |
3796 // TODO(creis): We'd rather use webview()->Close() here, but that currently | 3810 // TODO(creis): We'd rather use webview()->Close() here, but that currently |
3797 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs | 3811 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
3798 // in the onunload handler from appearing. For now, we're bypassing that and | 3812 // in the onunload handler from appearing. For now, we're bypassing that and |
3799 // calling the FrameLoader's CloseURL method directly. This should be | 3813 // calling the FrameLoader's CloseURL method directly. This should be |
3800 // revisited to avoid having two ways to close a page. Having a single way | 3814 // revisited to avoid having two ways to close a page. Having a single way |
3801 // to close that can run onunload is also useful for fixing | 3815 // to close that can run onunload is also useful for fixing |
3802 // http://b/issue?id=753080. | 3816 // http://b/issue?id=753080. |
3803 webview()->dispatchUnloadEvent(); | 3817 webview()->dispatchUnloadEvent(); |
3804 | 3818 |
3805 Send(new ViewHostMsg_ClosePage_ACK(routing_id_)); | 3819 Send(new ViewHostMsg_ClosePage_ACK(routing_id_)); |
3806 } | 3820 } |
3807 | 3821 |
3808 void RenderView::OnThemeChanged() { | 3822 void RenderViewImpl::OnThemeChanged() { |
3809 #if defined(OS_WIN) | 3823 #if defined(OS_WIN) |
3810 gfx::NativeThemeWin::instance()->CloseHandles(); | 3824 gfx::NativeThemeWin::instance()->CloseHandles(); |
3811 if (webview()) | 3825 if (webview()) |
3812 webview()->themeChanged(); | 3826 webview()->themeChanged(); |
3813 #else // defined(OS_WIN) | 3827 #else // defined(OS_WIN) |
3814 // TODO(port): we don't support theming on non-Windows platforms yet | 3828 // TODO(port): we don't support theming on non-Windows platforms yet |
3815 NOTIMPLEMENTED(); | 3829 NOTIMPLEMENTED(); |
3816 #endif | 3830 #endif |
3817 } | 3831 } |
3818 | 3832 |
3819 void RenderView::OnDisassociateFromPopupCount() { | 3833 void RenderViewImpl::OnDisassociateFromPopupCount() { |
3820 if (decrement_shared_popup_at_destruction_) | 3834 if (decrement_shared_popup_at_destruction_) |
3821 shared_popup_counter_->data--; | 3835 shared_popup_counter_->data--; |
3822 shared_popup_counter_ = new SharedRenderViewCounter(0); | 3836 shared_popup_counter_ = new SharedRenderViewCounter(0); |
3823 decrement_shared_popup_at_destruction_ = false; | 3837 decrement_shared_popup_at_destruction_ = false; |
3824 } | 3838 } |
3825 | 3839 |
3826 bool RenderView::MaybeLoadAlternateErrorPage(WebFrame* frame, | 3840 bool RenderViewImpl::MaybeLoadAlternateErrorPage(WebFrame* frame, |
3827 const WebURLError& error, | 3841 const WebURLError& error, |
3828 bool replace) { | 3842 bool replace) { |
3829 // We only show alternate error pages in the main frame. They are | 3843 // We only show alternate error pages in the main frame. They are |
3830 // intended to assist the user when navigating, so there is not much | 3844 // intended to assist the user when navigating, so there is not much |
3831 // value in showing them for failed subframes. Ideally, we would be | 3845 // value in showing them for failed subframes. Ideally, we would be |
3832 // able to use the TYPED transition type for this, but that flag is | 3846 // able to use the TYPED transition type for this, but that flag is |
3833 // not preserved across page reloads. | 3847 // not preserved across page reloads. |
3834 if (frame->parent()) | 3848 if (frame->parent()) |
3835 return false; | 3849 return false; |
3836 | 3850 |
3837 // Use the alternate error page service if this is a DNS failure or | 3851 // Use the alternate error page service if this is a DNS failure or |
3838 // connection failure. | 3852 // connection failure. |
(...skipping 18 matching lines...) Expand all Loading... |
3857 replace); | 3871 replace); |
3858 | 3872 |
3859 // Now, create a fetcher for the error page and associate it with the data | 3873 // Now, create a fetcher for the error page and associate it with the data |
3860 // source we just created via the LoadHTMLString call. That way if another | 3874 // source we just created via the LoadHTMLString call. That way if another |
3861 // navigation occurs, the fetcher will get destroyed. | 3875 // navigation occurs, the fetcher will get destroyed. |
3862 NavigationState* navigation_state = | 3876 NavigationState* navigation_state = |
3863 NavigationState::FromDataSource(frame->provisionalDataSource()); | 3877 NavigationState::FromDataSource(frame->provisionalDataSource()); |
3864 navigation_state->set_alt_error_page_fetcher( | 3878 navigation_state->set_alt_error_page_fetcher( |
3865 new AltErrorPageResourceFetcher( | 3879 new AltErrorPageResourceFetcher( |
3866 error_page_url, frame, error, | 3880 error_page_url, frame, error, |
3867 NewCallback(this, &RenderView::AltErrorPageFinished))); | 3881 NewCallback(this, &RenderViewImpl::AltErrorPageFinished))); |
3868 return true; | 3882 return true; |
3869 } | 3883 } |
3870 | 3884 |
3871 void RenderView::AltErrorPageFinished(WebFrame* frame, | 3885 void RenderViewImpl::AltErrorPageFinished(WebFrame* frame, |
3872 const WebURLError& original_error, | 3886 const WebURLError& original_error, |
3873 const std::string& html) { | 3887 const std::string& html) { |
3874 // Here, we replace the blank page we loaded previously. | 3888 // Here, we replace the blank page we loaded previously. |
3875 // If we failed to download the alternate error page, LoadNavigationErrorPage | 3889 // If we failed to download the alternate error page, LoadNavigationErrorPage |
3876 // will simply display a default error page. | 3890 // will simply display a default error page. |
3877 LoadNavigationErrorPage(frame, WebURLRequest(), original_error, html, true); | 3891 LoadNavigationErrorPage(frame, WebURLRequest(), original_error, html, true); |
3878 } | 3892 } |
3879 | 3893 |
3880 void RenderView::OnMoveOrResizeStarted() { | 3894 void RenderViewImpl::OnMoveOrResizeStarted() { |
3881 if (webview()) | 3895 if (webview()) |
3882 webview()->hidePopups(); | 3896 webview()->hidePopups(); |
3883 } | 3897 } |
3884 | 3898 |
3885 void RenderView::OnResize(const gfx::Size& new_size, | 3899 void RenderViewImpl::OnResize(const gfx::Size& new_size, |
3886 const gfx::Rect& resizer_rect) { | 3900 const gfx::Rect& resizer_rect) { |
3887 if (webview()) { | 3901 if (webview()) { |
3888 webview()->hidePopups(); | 3902 webview()->hidePopups(); |
3889 if (send_preferred_size_changes_) { | 3903 if (send_preferred_size_changes_) { |
3890 webview()->mainFrame()->setCanHaveScrollbars( | 3904 webview()->mainFrame()->setCanHaveScrollbars( |
3891 ShouldDisplayScrollbars(new_size.width(), new_size.height())); | 3905 ShouldDisplayScrollbars(new_size.width(), new_size.height())); |
3892 } | 3906 } |
3893 UpdateScrollState(webview()->mainFrame()); | 3907 UpdateScrollState(webview()->mainFrame()); |
3894 } | 3908 } |
3895 | 3909 |
3896 RenderWidget::OnResize(new_size, resizer_rect); | 3910 RenderWidget::OnResize(new_size, resizer_rect); |
3897 } | 3911 } |
3898 | 3912 |
3899 void RenderView::DidInitiatePaint() { | 3913 void RenderViewImpl::DidInitiatePaint() { |
3900 // Notify the pepper plugins that we started painting. | 3914 // Notify the pepper plugins that we started painting. |
3901 pepper_delegate_.ViewInitiatedPaint(); | 3915 pepper_delegate_.ViewInitiatedPaint(); |
3902 } | 3916 } |
3903 | 3917 |
3904 void RenderView::DidFlushPaint() { | 3918 void RenderViewImpl::DidFlushPaint() { |
3905 // Notify any pepper plugins that we painted. This will call into the plugin, | 3919 // Notify any pepper plugins that we painted. This will call into the plugin, |
3906 // and we it may ask to close itself as a result. This will, in turn, modify | 3920 // and we it may ask to close itself as a result. This will, in turn, modify |
3907 // our set, possibly invalidating the iterator. So we iterate on a copy that | 3921 // our set, possibly invalidating the iterator. So we iterate on a copy that |
3908 // won't change out from under us. | 3922 // won't change out from under us. |
3909 pepper_delegate_.ViewFlushedPaint(); | 3923 pepper_delegate_.ViewFlushedPaint(); |
3910 | 3924 |
3911 WebFrame* main_frame = webview()->mainFrame(); | 3925 WebFrame* main_frame = webview()->mainFrame(); |
3912 | 3926 |
3913 // If we have a provisional frame we are between the start and commit stages | 3927 // If we have a provisional frame we are between the start and commit stages |
3914 // of loading and we don't want to save stats. | 3928 // of loading and we don't want to save stats. |
(...skipping 12 matching lines...) Expand all Loading... |
3927 !navigation_state->finish_load_time().is_null()) { | 3941 !navigation_state->finish_load_time().is_null()) { |
3928 navigation_state->set_first_paint_after_load_time(now); | 3942 navigation_state->set_first_paint_after_load_time(now); |
3929 } | 3943 } |
3930 } | 3944 } |
3931 | 3945 |
3932 #if defined(TOUCH_UI) | 3946 #if defined(TOUCH_UI) |
3933 SyncSelectionIfRequired(); | 3947 SyncSelectionIfRequired(); |
3934 #endif | 3948 #endif |
3935 } | 3949 } |
3936 | 3950 |
3937 void RenderView::OnViewContextSwapBuffersPosted() { | 3951 void RenderViewImpl::OnViewContextSwapBuffersPosted() { |
3938 RenderWidget::OnSwapBuffersPosted(); | 3952 RenderWidget::OnSwapBuffersPosted(); |
3939 } | 3953 } |
3940 | 3954 |
3941 void RenderView::OnViewContextSwapBuffersComplete() { | 3955 void RenderViewImpl::OnViewContextSwapBuffersComplete() { |
3942 RenderWidget::OnSwapBuffersComplete(); | 3956 RenderWidget::OnSwapBuffersComplete(); |
3943 } | 3957 } |
3944 | 3958 |
3945 void RenderView::OnViewContextSwapBuffersAborted() { | 3959 void RenderViewImpl::OnViewContextSwapBuffersAborted() { |
3946 RenderWidget::OnSwapBuffersAborted(); | 3960 RenderWidget::OnSwapBuffersAborted(); |
3947 } | 3961 } |
3948 | 3962 |
3949 webkit::ppapi::PluginInstance* RenderView::GetBitmapForOptimizedPluginPaint( | 3963 webkit::ppapi::PluginInstance* RenderViewImpl::GetBitmapForOptimizedPluginPaint( |
3950 const gfx::Rect& paint_bounds, | 3964 const gfx::Rect& paint_bounds, |
3951 TransportDIB** dib, | 3965 TransportDIB** dib, |
3952 gfx::Rect* location, | 3966 gfx::Rect* location, |
3953 gfx::Rect* clip) { | 3967 gfx::Rect* clip) { |
3954 return pepper_delegate_.GetBitmapForOptimizedPluginPaint( | 3968 return pepper_delegate_.GetBitmapForOptimizedPluginPaint( |
3955 paint_bounds, dib, location, clip); | 3969 paint_bounds, dib, location, clip); |
3956 } | 3970 } |
3957 | 3971 |
3958 gfx::Point RenderView::GetScrollOffset() { | 3972 gfx::Point RenderViewImpl::GetScrollOffset() { |
3959 WebSize scroll_offset = webview()->mainFrame()->scrollOffset(); | 3973 WebSize scroll_offset = webview()->mainFrame()->scrollOffset(); |
3960 return gfx::Point(scroll_offset.width, scroll_offset.height); | 3974 return gfx::Point(scroll_offset.width, scroll_offset.height); |
3961 } | 3975 } |
3962 | 3976 |
3963 void RenderView::OnClearFocusedNode() { | 3977 void RenderViewImpl::OnClearFocusedNode() { |
3964 if (webview()) | 3978 if (webview()) |
3965 webview()->clearFocusedNode(); | 3979 webview()->clearFocusedNode(); |
3966 } | 3980 } |
3967 | 3981 |
3968 void RenderView::OnSetBackground(const SkBitmap& background) { | 3982 void RenderViewImpl::OnSetBackground(const SkBitmap& background) { |
3969 if (webview()) | 3983 if (webview()) |
3970 webview()->setIsTransparent(!background.empty()); | 3984 webview()->setIsTransparent(!background.empty()); |
3971 | 3985 |
3972 SetBackground(background); | 3986 SetBackground(background); |
3973 } | 3987 } |
3974 | 3988 |
3975 void RenderView::OnSetActive(bool active) { | 3989 void RenderViewImpl::OnSetActive(bool active) { |
3976 if (webview()) | 3990 if (webview()) |
3977 webview()->setIsActive(active); | 3991 webview()->setIsActive(active); |
3978 | 3992 |
3979 #if defined(OS_MACOSX) | 3993 #if defined(OS_MACOSX) |
3980 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 3994 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
3981 for (plugin_it = plugin_delegates_.begin(); | 3995 for (plugin_it = plugin_delegates_.begin(); |
3982 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 3996 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
3983 (*plugin_it)->SetWindowFocus(active); | 3997 (*plugin_it)->SetWindowFocus(active); |
3984 } | 3998 } |
3985 #endif | 3999 #endif |
3986 } | 4000 } |
3987 | 4001 |
3988 #if defined(OS_MACOSX) | 4002 #if defined(OS_MACOSX) |
3989 void RenderView::OnSetWindowVisibility(bool visible) { | 4003 void RenderViewImpl::OnSetWindowVisibility(bool visible) { |
3990 // Inform plugins that their container has changed visibility. | 4004 // Inform plugins that their container has changed visibility. |
3991 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 4005 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
3992 for (plugin_it = plugin_delegates_.begin(); | 4006 for (plugin_it = plugin_delegates_.begin(); |
3993 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 4007 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
3994 (*plugin_it)->SetContainerVisibility(visible); | 4008 (*plugin_it)->SetContainerVisibility(visible); |
3995 } | 4009 } |
3996 } | 4010 } |
3997 | 4011 |
3998 void RenderView::OnWindowFrameChanged(const gfx::Rect& window_frame, | 4012 void RenderViewImpl::OnWindowFrameChanged(const gfx::Rect& window_frame, |
3999 const gfx::Rect& view_frame) { | 4013 const gfx::Rect& view_frame) { |
4000 // Inform plugins that their window's frame has changed. | 4014 // Inform plugins that their window's frame has changed. |
4001 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 4015 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
4002 for (plugin_it = plugin_delegates_.begin(); | 4016 for (plugin_it = plugin_delegates_.begin(); |
4003 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 4017 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
4004 (*plugin_it)->WindowFrameChanged(window_frame, view_frame); | 4018 (*plugin_it)->WindowFrameChanged(window_frame, view_frame); |
4005 } | 4019 } |
4006 } | 4020 } |
4007 | 4021 |
4008 void RenderView::OnPluginImeCompositionCompleted(const string16& text, | 4022 void RenderViewImpl::OnPluginImeCompositionCompleted(const string16& text, |
4009 int plugin_id) { | 4023 int plugin_id) { |
4010 // WebPluginDelegateProxy is responsible for figuring out if this event | 4024 // WebPluginDelegateProxy is responsible for figuring out if this event |
4011 // applies to it or not, so inform all the delegates. | 4025 // applies to it or not, so inform all the delegates. |
4012 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 4026 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
4013 for (plugin_it = plugin_delegates_.begin(); | 4027 for (plugin_it = plugin_delegates_.begin(); |
4014 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 4028 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
4015 (*plugin_it)->ImeCompositionCompleted(text, plugin_id); | 4029 (*plugin_it)->ImeCompositionCompleted(text, plugin_id); |
4016 } | 4030 } |
4017 } | 4031 } |
4018 #endif // OS_MACOSX | 4032 #endif // OS_MACOSX |
4019 | 4033 |
4020 void RenderView::OnSetEditCommandsForNextKeyEvent( | 4034 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( |
4021 const EditCommands& edit_commands) { | 4035 const EditCommands& edit_commands) { |
4022 edit_commands_ = edit_commands; | 4036 edit_commands_ = edit_commands; |
4023 } | 4037 } |
4024 | 4038 |
4025 void RenderView::Close() { | 4039 void RenderViewImpl::Close() { |
4026 // We need to grab a pointer to the doomed WebView before we destroy it. | 4040 // We need to grab a pointer to the doomed WebView before we destroy it. |
4027 WebView* doomed = webview(); | 4041 WebView* doomed = webview(); |
4028 RenderWidget::Close(); | 4042 RenderWidget::Close(); |
4029 g_view_map.Get().erase(doomed); | 4043 g_view_map.Get().erase(doomed); |
4030 } | 4044 } |
4031 | 4045 |
4032 void RenderView::DidHandleKeyEvent() { | 4046 void RenderViewImpl::DidHandleKeyEvent() { |
4033 edit_commands_.clear(); | 4047 edit_commands_.clear(); |
4034 } | 4048 } |
4035 | 4049 |
4036 bool RenderView::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 4050 bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
4037 return pepper_delegate_.HandleMouseEvent(event); | 4051 return pepper_delegate_.HandleMouseEvent(event); |
4038 } | 4052 } |
4039 | 4053 |
4040 void RenderView::DidHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 4054 void RenderViewImpl::DidHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
4041 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); | 4055 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); |
4042 } | 4056 } |
4043 | 4057 |
4044 void RenderView::DidHandleTouchEvent(const WebTouchEvent& event) { | 4058 void RenderViewImpl::DidHandleTouchEvent(const WebTouchEvent& event) { |
4045 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleTouchEvent(event)); | 4059 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleTouchEvent(event)); |
4046 } | 4060 } |
4047 | 4061 |
4048 void RenderView::OnWasHidden() { | 4062 void RenderViewImpl::OnWasHidden() { |
4049 RenderWidget::OnWasHidden(); | 4063 RenderWidget::OnWasHidden(); |
4050 | 4064 |
4051 if (webview()) { | 4065 if (webview()) { |
4052 webview()->settings()->setMinimumTimerInterval( | 4066 webview()->settings()->setMinimumTimerInterval( |
4053 webkit_glue::kBackgroundTabTimerInterval); | 4067 webkit_glue::kBackgroundTabTimerInterval); |
4054 webview()->setVisibilityState(visibilityState(), false); | 4068 webview()->setVisibilityState(visibilityState(), false); |
4055 } | 4069 } |
4056 | 4070 |
4057 #if defined(OS_MACOSX) | 4071 #if defined(OS_MACOSX) |
4058 // Inform plugins that their container is no longer visible. | 4072 // Inform plugins that their container is no longer visible. |
4059 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 4073 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
4060 for (plugin_it = plugin_delegates_.begin(); | 4074 for (plugin_it = plugin_delegates_.begin(); |
4061 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 4075 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
4062 (*plugin_it)->SetContainerVisibility(false); | 4076 (*plugin_it)->SetContainerVisibility(false); |
4063 } | 4077 } |
4064 #endif // OS_MACOSX | 4078 #endif // OS_MACOSX |
4065 } | 4079 } |
4066 | 4080 |
4067 void RenderView::OnWasRestored(bool needs_repainting) { | 4081 void RenderViewImpl::OnWasRestored(bool needs_repainting) { |
4068 RenderWidget::OnWasRestored(needs_repainting); | 4082 RenderWidget::OnWasRestored(needs_repainting); |
4069 | 4083 |
4070 if (webview()) { | 4084 if (webview()) { |
4071 webview()->settings()->setMinimumTimerInterval( | 4085 webview()->settings()->setMinimumTimerInterval( |
4072 webkit_glue::kForegroundTabTimerInterval); | 4086 webkit_glue::kForegroundTabTimerInterval); |
4073 webview()->setVisibilityState(visibilityState(), false); | 4087 webview()->setVisibilityState(visibilityState(), false); |
4074 } | 4088 } |
4075 | 4089 |
4076 #if defined(OS_MACOSX) | 4090 #if defined(OS_MACOSX) |
4077 // Inform plugins that their container is now visible. | 4091 // Inform plugins that their container is now visible. |
4078 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 4092 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
4079 for (plugin_it = plugin_delegates_.begin(); | 4093 for (plugin_it = plugin_delegates_.begin(); |
4080 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 4094 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
4081 (*plugin_it)->SetContainerVisibility(true); | 4095 (*plugin_it)->SetContainerVisibility(true); |
4082 } | 4096 } |
4083 #endif // OS_MACOSX | 4097 #endif // OS_MACOSX |
4084 } | 4098 } |
4085 | 4099 |
4086 bool RenderView::SupportsAsynchronousSwapBuffers() { | 4100 bool RenderViewImpl::SupportsAsynchronousSwapBuffers() { |
4087 if (WebWidgetHandlesCompositorScheduling()) | 4101 if (WebWidgetHandlesCompositorScheduling()) |
4088 return false; | 4102 return false; |
4089 | 4103 |
4090 WebKit::WebGraphicsContext3D* context = webview()->graphicsContext3D(); | 4104 WebKit::WebGraphicsContext3D* context = webview()->graphicsContext3D(); |
4091 if (!context) | 4105 if (!context) |
4092 return false; | 4106 return false; |
4093 std::string extensions(context->getRequestableExtensionsCHROMIUM().utf8()); | 4107 std::string extensions(context->getRequestableExtensionsCHROMIUM().utf8()); |
4094 return extensions.find("GL_CHROMIUM_swapbuffers_complete_callback") != | 4108 return extensions.find("GL_CHROMIUM_swapbuffers_complete_callback") != |
4095 std::string::npos; | 4109 std::string::npos; |
4096 } | 4110 } |
4097 | 4111 |
4098 void RenderView::OnSetFocus(bool enable) { | 4112 void RenderViewImpl::OnSetFocus(bool enable) { |
4099 RenderWidget::OnSetFocus(enable); | 4113 RenderWidget::OnSetFocus(enable); |
4100 | 4114 |
4101 if (webview() && webview()->isActive()) { | 4115 if (webview() && webview()->isActive()) { |
4102 // Notify all NPAPI plugins. | 4116 // Notify all NPAPI plugins. |
4103 std::set<WebPluginDelegateProxy*>::iterator plugin_it; | 4117 std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
4104 for (plugin_it = plugin_delegates_.begin(); | 4118 for (plugin_it = plugin_delegates_.begin(); |
4105 plugin_it != plugin_delegates_.end(); ++plugin_it) { | 4119 plugin_it != plugin_delegates_.end(); ++plugin_it) { |
4106 #if defined(OS_MACOSX) | 4120 #if defined(OS_MACOSX) |
4107 // RenderWidget's call to setFocus can cause the underlying webview's | 4121 // RenderWidget's call to setFocus can cause the underlying webview's |
4108 // activation state to change just like a call to setIsActive. | 4122 // activation state to change just like a call to setIsActive. |
4109 if (enable) | 4123 if (enable) |
4110 (*plugin_it)->SetWindowFocus(true); | 4124 (*plugin_it)->SetWindowFocus(true); |
4111 #endif | 4125 #endif |
4112 (*plugin_it)->SetContentAreaFocus(enable); | 4126 (*plugin_it)->SetContentAreaFocus(enable); |
4113 } | 4127 } |
4114 | 4128 |
4115 // Notify all Pepper plugins. | 4129 // Notify all Pepper plugins. |
4116 pepper_delegate_.OnSetFocus(enable); | 4130 pepper_delegate_.OnSetFocus(enable); |
4117 } | 4131 } |
4118 } | 4132 } |
4119 | 4133 |
4120 void RenderView::PpapiPluginFocusChanged() { | 4134 void RenderViewImpl::PpapiPluginFocusChanged() { |
4121 UpdateInputMethod(); | 4135 UpdateInputMethod(); |
4122 } | 4136 } |
4123 | 4137 |
4124 void RenderView::RequestRemoteAccessClientFirewallTraversal() { | 4138 void RenderViewImpl::RequestRemoteAccessClientFirewallTraversal() { |
4125 Send(new ViewHostMsg_RequestRemoteAccessClientFirewallTraversal(routing_id_)); | 4139 Send(new ViewHostMsg_RequestRemoteAccessClientFirewallTraversal(routing_id_)); |
4126 } | 4140 } |
4127 | 4141 |
4128 void RenderView::OnImeSetComposition( | 4142 void RenderViewImpl::OnImeSetComposition( |
4129 const string16& text, | 4143 const string16& text, |
4130 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 4144 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
4131 int selection_start, | 4145 int selection_start, |
4132 int selection_end) { | 4146 int selection_end) { |
4133 // Until PPAPI has an interface for handling IME events, we skip sending | 4147 // Until PPAPI has an interface for handling IME events, we skip sending |
4134 // OnImeSetComposition. Otherwise the composition is canceled when a | 4148 // OnImeSetComposition. Otherwise the composition is canceled when a |
4135 // non-editable DOM element is focused. | 4149 // non-editable DOM element is focused. |
4136 // | 4150 // |
4137 // TODO(kinaba) This temporal remedy can be removed after PPAPI is extended | 4151 // TODO(kinaba) This temporal remedy can be removed after PPAPI is extended |
4138 // with an IME handling interface. | 4152 // with an IME handling interface. |
(...skipping 24 matching lines...) Expand all Loading... |
4163 return; | 4177 return; |
4164 } | 4178 } |
4165 #endif | 4179 #endif |
4166 RenderWidget::OnImeSetComposition(text, | 4180 RenderWidget::OnImeSetComposition(text, |
4167 underlines, | 4181 underlines, |
4168 selection_start, | 4182 selection_start, |
4169 selection_end); | 4183 selection_end); |
4170 } | 4184 } |
4171 } | 4185 } |
4172 | 4186 |
4173 void RenderView::OnImeConfirmComposition(const string16& text) { | 4187 void RenderViewImpl::OnImeConfirmComposition(const string16& text) { |
4174 if (pepper_delegate_.IsPluginFocused()) { | 4188 if (pepper_delegate_.IsPluginFocused()) { |
4175 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4189 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we |
4176 // send character events. | 4190 // send character events. |
4177 for (size_t i = 0; i < text.size(); ++i) { | 4191 for (size_t i = 0; i < text.size(); ++i) { |
4178 WebKit::WebKeyboardEvent char_event; | 4192 WebKit::WebKeyboardEvent char_event; |
4179 char_event.type = WebKit::WebInputEvent::Char; | 4193 char_event.type = WebKit::WebInputEvent::Char; |
4180 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); | 4194 char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); |
4181 char_event.modifiers = 0; | 4195 char_event.modifiers = 0; |
4182 char_event.windowsKeyCode = text[i]; | 4196 char_event.windowsKeyCode = text[i]; |
4183 char_event.nativeKeyCode = text[i]; | 4197 char_event.nativeKeyCode = text[i]; |
(...skipping 13 matching lines...) Expand all Loading... |
4197 it != plugin_delegates_.end(); ++it) { | 4211 it != plugin_delegates_.end(); ++it) { |
4198 (*it)->ImeCompositionCompleted(text, focused_plugin_id_); | 4212 (*it)->ImeCompositionCompleted(text, focused_plugin_id_); |
4199 } | 4213 } |
4200 return; | 4214 return; |
4201 } | 4215 } |
4202 #endif | 4216 #endif |
4203 RenderWidget::OnImeConfirmComposition(text); | 4217 RenderWidget::OnImeConfirmComposition(text); |
4204 } | 4218 } |
4205 } | 4219 } |
4206 | 4220 |
4207 ui::TextInputType RenderView::GetTextInputType() { | 4221 ui::TextInputType RenderViewImpl::GetTextInputType() { |
4208 if (pepper_delegate_.IsPluginFocused()) { | 4222 if (pepper_delegate_.IsPluginFocused()) { |
4209 #if !defined(TOUCH_UI) | 4223 #if !defined(TOUCH_UI) |
4210 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we | 4224 // TODO(kinaba) Until PPAPI has an interface for handling IME events, we |
4211 // consider all the parts of PPAPI plugins are accepting text inputs. | 4225 // consider all the parts of PPAPI plugins are accepting text inputs. |
4212 return ui::TEXT_INPUT_TYPE_TEXT; | 4226 return ui::TEXT_INPUT_TYPE_TEXT; |
4213 #else | 4227 #else |
4214 // Disable keyboard input in flash for touch ui until PPAPI can support IME | 4228 // Disable keyboard input in flash for touch ui until PPAPI can support IME |
4215 // events. | 4229 // events. |
4216 return ui::TEXT_INPUT_TYPE_NONE; | 4230 return ui::TEXT_INPUT_TYPE_NONE; |
4217 #endif | 4231 #endif |
4218 } | 4232 } |
4219 return RenderWidget::GetTextInputType(); | 4233 return RenderWidget::GetTextInputType(); |
4220 } | 4234 } |
4221 | 4235 |
4222 bool RenderView::CanComposeInline() { | 4236 bool RenderViewImpl::CanComposeInline() { |
4223 if (pepper_delegate_.IsPluginFocused()) { | 4237 if (pepper_delegate_.IsPluginFocused()) { |
4224 // TODO(kinaba) Until PPAPI has an interface for handling IME events, there | 4238 // TODO(kinaba) Until PPAPI has an interface for handling IME events, there |
4225 // is no way for the browser to know whether the plugin is capable of | 4239 // is no way for the browser to know whether the plugin is capable of |
4226 // drawing composition text. We assume plugins are incapable and let the | 4240 // drawing composition text. We assume plugins are incapable and let the |
4227 // browser handle composition display for now. | 4241 // browser handle composition display for now. |
4228 return false; | 4242 return false; |
4229 } | 4243 } |
4230 return true; | 4244 return true; |
4231 } | 4245 } |
4232 | 4246 |
4233 #if defined(OS_WIN) | 4247 #if defined(OS_WIN) |
4234 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { | 4248 void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { |
4235 if (focused) | 4249 if (focused) |
4236 focused_plugin_id_ = plugin_id; | 4250 focused_plugin_id_ = plugin_id; |
4237 else | 4251 else |
4238 focused_plugin_id_ = -1; | 4252 focused_plugin_id_ = -1; |
4239 } | 4253 } |
4240 #endif | 4254 #endif |
4241 | 4255 |
4242 #if defined(OS_MACOSX) | 4256 #if defined(OS_MACOSX) |
4243 void RenderView::PluginFocusChanged(bool focused, int plugin_id) { | 4257 void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { |
4244 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), | 4258 IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), |
4245 focused, plugin_id); | 4259 focused, plugin_id); |
4246 Send(msg); | 4260 Send(msg); |
4247 } | 4261 } |
4248 | 4262 |
4249 void RenderView::StartPluginIme() { | 4263 void RenderViewImpl::StartPluginIme() { |
4250 IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id()); | 4264 IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id()); |
4251 // This message can be sent during event-handling, and needs to be delivered | 4265 // This message can be sent during event-handling, and needs to be delivered |
4252 // within that context. | 4266 // within that context. |
4253 msg->set_unblock(true); | 4267 msg->set_unblock(true); |
4254 Send(msg); | 4268 Send(msg); |
4255 } | 4269 } |
4256 | 4270 |
4257 gfx::PluginWindowHandle RenderView::AllocateFakePluginWindowHandle( | 4271 gfx::PluginWindowHandle RenderViewImpl::AllocateFakePluginWindowHandle( |
4258 bool opaque, bool root) { | 4272 bool opaque, bool root) { |
4259 gfx::PluginWindowHandle window = NULL; | 4273 gfx::PluginWindowHandle window = NULL; |
4260 Send(new ViewHostMsg_AllocateFakePluginWindowHandle( | 4274 Send(new ViewHostMsg_AllocateFakePluginWindowHandle( |
4261 routing_id(), opaque, root, &window)); | 4275 routing_id(), opaque, root, &window)); |
4262 if (window) { | 4276 if (window) { |
4263 fake_plugin_window_handles_.insert(window); | 4277 fake_plugin_window_handles_.insert(window); |
4264 } | 4278 } |
4265 return window; | 4279 return window; |
4266 } | 4280 } |
4267 | 4281 |
4268 void RenderView::DestroyFakePluginWindowHandle(gfx::PluginWindowHandle window) { | 4282 void RenderViewImpl::DestroyFakePluginWindowHandle( |
| 4283 gfx::PluginWindowHandle window) { |
4269 if (window && fake_plugin_window_handles_.find(window) != | 4284 if (window && fake_plugin_window_handles_.find(window) != |
4270 fake_plugin_window_handles_.end()) { | 4285 fake_plugin_window_handles_.end()) { |
4271 Send(new ViewHostMsg_DestroyFakePluginWindowHandle(routing_id(), window)); | 4286 Send(new ViewHostMsg_DestroyFakePluginWindowHandle(routing_id(), window)); |
4272 fake_plugin_window_handles_.erase(window); | 4287 fake_plugin_window_handles_.erase(window); |
4273 } | 4288 } |
4274 } | 4289 } |
4275 | 4290 |
4276 void RenderView::AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window, | 4291 void RenderViewImpl::AcceleratedSurfaceSetIOSurface( |
4277 int32 width, | 4292 gfx::PluginWindowHandle window, |
4278 int32 height, | 4293 int32 width, |
4279 uint64 io_surface_identifier) { | 4294 int32 height, |
| 4295 uint64 io_surface_identifier) { |
4280 Send(new ViewHostMsg_AcceleratedSurfaceSetIOSurface( | 4296 Send(new ViewHostMsg_AcceleratedSurfaceSetIOSurface( |
4281 routing_id(), window, width, height, io_surface_identifier)); | 4297 routing_id(), window, width, height, io_surface_identifier)); |
4282 } | 4298 } |
4283 | 4299 |
4284 void RenderView::AcceleratedSurfaceSetTransportDIB( | 4300 void RenderViewImpl::AcceleratedSurfaceSetTransportDIB( |
4285 gfx::PluginWindowHandle window, | 4301 gfx::PluginWindowHandle window, |
4286 int32 width, | 4302 int32 width, |
4287 int32 height, | 4303 int32 height, |
4288 TransportDIB::Handle transport_dib) { | 4304 TransportDIB::Handle transport_dib) { |
4289 Send(new ViewHostMsg_AcceleratedSurfaceSetTransportDIB( | 4305 Send(new ViewHostMsg_AcceleratedSurfaceSetTransportDIB( |
4290 routing_id(), window, width, height, transport_dib)); | 4306 routing_id(), window, width, height, transport_dib)); |
4291 } | 4307 } |
4292 | 4308 |
4293 TransportDIB::Handle RenderView::AcceleratedSurfaceAllocTransportDIB( | 4309 TransportDIB::Handle RenderViewImpl::AcceleratedSurfaceAllocTransportDIB( |
4294 size_t size) { | 4310 size_t size) { |
4295 TransportDIB::Handle dib_handle; | 4311 TransportDIB::Handle dib_handle; |
4296 // Assume this is a synchronous RPC. | 4312 // Assume this is a synchronous RPC. |
4297 if (Send(new ViewHostMsg_AllocTransportDIB(size, true, &dib_handle))) | 4313 if (Send(new ViewHostMsg_AllocTransportDIB(size, true, &dib_handle))) |
4298 return dib_handle; | 4314 return dib_handle; |
4299 // Return an invalid handle if Send() fails. | 4315 // Return an invalid handle if Send() fails. |
4300 return TransportDIB::DefaultHandleValue(); | 4316 return TransportDIB::DefaultHandleValue(); |
4301 } | 4317 } |
4302 | 4318 |
4303 void RenderView::AcceleratedSurfaceFreeTransportDIB(TransportDIB::Id dib_id) { | 4319 void RenderViewImpl::AcceleratedSurfaceFreeTransportDIB( |
| 4320 TransportDIB::Id dib_id) { |
4304 Send(new ViewHostMsg_FreeTransportDIB(dib_id)); | 4321 Send(new ViewHostMsg_FreeTransportDIB(dib_id)); |
4305 } | 4322 } |
4306 | 4323 |
4307 void RenderView::AcceleratedSurfaceBuffersSwapped( | 4324 void RenderViewImpl::AcceleratedSurfaceBuffersSwapped( |
4308 gfx::PluginWindowHandle window, uint64 surface_id) { | 4325 gfx::PluginWindowHandle window, uint64 surface_id) { |
4309 Send(new ViewHostMsg_AcceleratedSurfaceBuffersSwapped( | 4326 Send(new ViewHostMsg_AcceleratedSurfaceBuffersSwapped( |
4310 routing_id(), window, surface_id)); | 4327 routing_id(), window, surface_id)); |
4311 } | 4328 } |
4312 #endif | 4329 #endif |
4313 | 4330 |
4314 bool RenderView::ScheduleFileChooser( | 4331 bool RenderViewImpl::ScheduleFileChooser( |
4315 const ViewHostMsg_RunFileChooser_Params& params, | 4332 const ViewHostMsg_RunFileChooser_Params& params, |
4316 WebFileChooserCompletion* completion) { | 4333 WebFileChooserCompletion* completion) { |
4317 static const size_t kMaximumPendingFileChooseRequests = 4; | 4334 static const size_t kMaximumPendingFileChooseRequests = 4; |
4318 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { | 4335 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { |
4319 // This sanity check prevents too many file choose requests from getting | 4336 // This sanity check prevents too many file choose requests from getting |
4320 // queued which could DoS the user. Getting these is most likely a | 4337 // queued which could DoS the user. Getting these is most likely a |
4321 // programming error (there are many ways to DoS the user so it's not | 4338 // programming error (there are many ways to DoS the user so it's not |
4322 // considered a "real" security check), either in JS requesting many file | 4339 // considered a "real" security check), either in JS requesting many file |
4323 // choosers to pop up, or in a plugin. | 4340 // choosers to pop up, or in a plugin. |
4324 // | 4341 // |
4325 // TODO(brettw) we might possibly want to require a user gesture to open | 4342 // TODO(brettw) we might possibly want to require a user gesture to open |
4326 // a file picker, which will address this issue in a better way. | 4343 // a file picker, which will address this issue in a better way. |
4327 return false; | 4344 return false; |
4328 } | 4345 } |
4329 | 4346 |
4330 file_chooser_completions_.push_back(linked_ptr<PendingFileChooser>( | 4347 file_chooser_completions_.push_back(linked_ptr<PendingFileChooser>( |
4331 new PendingFileChooser(params, completion))); | 4348 new PendingFileChooser(params, completion))); |
4332 if (file_chooser_completions_.size() == 1) { | 4349 if (file_chooser_completions_.size() == 1) { |
4333 // Actually show the browse dialog when this is the first request. | 4350 // Actually show the browse dialog when this is the first request. |
4334 Send(new ViewHostMsg_RunFileChooser(routing_id_, params)); | 4351 Send(new ViewHostMsg_RunFileChooser(routing_id_, params)); |
4335 } | 4352 } |
4336 return true; | 4353 return true; |
4337 } | 4354 } |
4338 | 4355 |
4339 WebKit::WebGeolocationClient* RenderView::geolocationClient() { | 4356 WebKit::WebGeolocationClient* RenderViewImpl::geolocationClient() { |
4340 if (!geolocation_dispatcher_) | 4357 if (!geolocation_dispatcher_) |
4341 geolocation_dispatcher_ = new GeolocationDispatcher(this); | 4358 geolocation_dispatcher_ = new GeolocationDispatcher(this); |
4342 return geolocation_dispatcher_; | 4359 return geolocation_dispatcher_; |
4343 } | 4360 } |
4344 | 4361 |
4345 WebKit::WebSpeechInputController* RenderView::speechInputController( | 4362 WebKit::WebSpeechInputController* RenderViewImpl::speechInputController( |
4346 WebKit::WebSpeechInputListener* listener) { | 4363 WebKit::WebSpeechInputListener* listener) { |
4347 if (!speech_input_dispatcher_) | 4364 if (!speech_input_dispatcher_) |
4348 speech_input_dispatcher_ = new SpeechInputDispatcher(this, listener); | 4365 speech_input_dispatcher_ = new SpeechInputDispatcher(this, listener); |
4349 return speech_input_dispatcher_; | 4366 return speech_input_dispatcher_; |
4350 } | 4367 } |
4351 | 4368 |
4352 WebKit::WebDeviceOrientationClient* RenderView::deviceOrientationClient() { | 4369 WebKit::WebDeviceOrientationClient* RenderViewImpl::deviceOrientationClient() { |
4353 if (!device_orientation_dispatcher_) | 4370 if (!device_orientation_dispatcher_) |
4354 device_orientation_dispatcher_ = new DeviceOrientationDispatcher(this); | 4371 device_orientation_dispatcher_ = new DeviceOrientationDispatcher(this); |
4355 return device_orientation_dispatcher_; | 4372 return device_orientation_dispatcher_; |
4356 } | 4373 } |
4357 | 4374 |
4358 void RenderView::zoomLimitsChanged(double minimum_level, double maximum_level) { | 4375 void RenderViewImpl::zoomLimitsChanged(double minimum_level, |
| 4376 double maximum_level) { |
4359 // For now, don't remember plugin zoom values. We don't want to mix them with | 4377 // For now, don't remember plugin zoom values. We don't want to mix them with |
4360 // normal web content (i.e. a fixed layout plugin would usually want them | 4378 // normal web content (i.e. a fixed layout plugin would usually want them |
4361 // different). | 4379 // different). |
4362 bool remember = !webview()->mainFrame()->document().isPluginDocument(); | 4380 bool remember = !webview()->mainFrame()->document().isPluginDocument(); |
4363 | 4381 |
4364 int minimum_percent = static_cast<int>( | 4382 int minimum_percent = static_cast<int>( |
4365 WebView::zoomLevelToZoomFactor(minimum_level) * 100); | 4383 WebView::zoomLevelToZoomFactor(minimum_level) * 100); |
4366 int maximum_percent = static_cast<int>( | 4384 int maximum_percent = static_cast<int>( |
4367 WebView::zoomLevelToZoomFactor(maximum_level) * 100); | 4385 WebView::zoomLevelToZoomFactor(maximum_level) * 100); |
4368 | 4386 |
4369 Send(new ViewHostMsg_UpdateZoomLimits( | 4387 Send(new ViewHostMsg_UpdateZoomLimits( |
4370 routing_id_, minimum_percent, maximum_percent, remember)); | 4388 routing_id_, minimum_percent, maximum_percent, remember)); |
4371 } | 4389 } |
4372 | 4390 |
4373 void RenderView::zoomLevelChanged() { | 4391 void RenderViewImpl::zoomLevelChanged() { |
4374 bool remember = !webview()->mainFrame()->document().isPluginDocument(); | 4392 bool remember = !webview()->mainFrame()->document().isPluginDocument(); |
4375 #if defined(TOUCH_UI) | 4393 #if defined(TOUCH_UI) |
4376 float zoom_level = | 4394 float zoom_level = |
4377 WebView::zoomFactorToZoomLevel(webview()->pageScaleFactor()); | 4395 WebView::zoomFactorToZoomLevel(webview()->pageScaleFactor()); |
4378 #else | 4396 #else |
4379 float zoom_level = webview()->zoomLevel(); | 4397 float zoom_level = webview()->zoomLevel(); |
4380 #endif | 4398 #endif |
4381 // Tell the browser which url got zoomed so it can update the menu and the | 4399 // Tell the browser which url got zoomed so it can update the menu and the |
4382 // saved values if necessary | 4400 // saved values if necessary |
4383 Send(new ViewHostMsg_DidZoomURL( | 4401 Send(new ViewHostMsg_DidZoomURL( |
4384 routing_id_, zoom_level, remember, | 4402 routing_id_, zoom_level, remember, |
4385 GURL(webview()->mainFrame()->document().url()))); | 4403 GURL(webview()->mainFrame()->document().url()))); |
4386 } | 4404 } |
4387 | 4405 |
4388 void RenderView::registerProtocolHandler(const WebString& scheme, | 4406 void RenderViewImpl::registerProtocolHandler(const WebString& scheme, |
4389 const WebString& base_url, | 4407 const WebString& base_url, |
4390 const WebString& url, | 4408 const WebString& url, |
4391 const WebString& title) { | 4409 const WebString& title) { |
4392 GURL base(base_url); | 4410 GURL base(base_url); |
4393 GURL absolute_url = base.Resolve(UTF16ToUTF8(url)); | 4411 GURL absolute_url = base.Resolve(UTF16ToUTF8(url)); |
4394 if (base.GetOrigin() != absolute_url.GetOrigin()) { | 4412 if (base.GetOrigin() != absolute_url.GetOrigin()) { |
4395 return; | 4413 return; |
4396 } | 4414 } |
4397 Send(new ViewHostMsg_RegisterProtocolHandler(routing_id_, | 4415 Send(new ViewHostMsg_RegisterProtocolHandler(routing_id_, |
4398 UTF16ToUTF8(scheme), | 4416 UTF16ToUTF8(scheme), |
4399 absolute_url, | 4417 absolute_url, |
4400 title)); | 4418 title)); |
4401 } | 4419 } |
4402 | 4420 |
4403 void RenderView::registerIntentHandler(const WebString& action, | 4421 void RenderViewImpl::registerIntentHandler(const WebString& action, |
4404 const WebString& type, | 4422 const WebString& type, |
4405 const WebString& href, | 4423 const WebString& href, |
4406 const WebString& title) { | 4424 const WebString& title) { |
4407 Send(new ViewHostMsg_RegisterIntentHandler(routing_id_, | 4425 Send(new ViewHostMsg_RegisterIntentHandler(routing_id_, |
4408 action, | 4426 action, |
4409 type, | 4427 type, |
4410 href, | 4428 href, |
4411 title)); | 4429 title)); |
4412 } | 4430 } |
4413 | 4431 |
4414 WebKit::WebPageVisibilityState RenderView::visibilityState() const { | 4432 WebKit::WebPageVisibilityState RenderViewImpl::visibilityState() const { |
4415 WebKit::WebPageVisibilityState current_state = is_hidden() ? | 4433 WebKit::WebPageVisibilityState current_state = is_hidden() ? |
4416 WebKit::WebPageVisibilityStateHidden : | 4434 WebKit::WebPageVisibilityStateHidden : |
4417 WebKit::WebPageVisibilityStateVisible; | 4435 WebKit::WebPageVisibilityStateVisible; |
4418 WebKit::WebPageVisibilityState override_state = current_state; | 4436 WebKit::WebPageVisibilityState override_state = current_state; |
4419 if (content::GetContentClient()->renderer()-> | 4437 if (content::GetContentClient()->renderer()-> |
4420 ShouldOverridePageVisibilityState(this, | 4438 ShouldOverridePageVisibilityState(this, |
4421 &override_state)) | 4439 &override_state)) |
4422 return override_state; | 4440 return override_state; |
4423 return current_state; | 4441 return current_state; |
4424 } | 4442 } |
4425 | 4443 |
4426 void RenderView::startActivity(const WebKit::WebString& action, | 4444 void RenderViewImpl::startActivity(const WebKit::WebString& action, |
4427 const WebKit::WebString& type, | 4445 const WebKit::WebString& type, |
4428 const WebKit::WebString& data, | 4446 const WebKit::WebString& data, |
4429 int intent_id) { | 4447 int intent_id) { |
4430 webkit_glue::WebIntentData intent_data; | 4448 webkit_glue::WebIntentData intent_data; |
4431 intent_data.action = action; | 4449 intent_data.action = action; |
4432 intent_data.type = type; | 4450 intent_data.type = type; |
4433 intent_data.data = data; | 4451 intent_data.data = data; |
4434 Send(new IntentsHostMsg_WebIntentDispatch( | 4452 Send(new IntentsHostMsg_WebIntentDispatch( |
4435 routing_id_, intent_data, intent_id)); | 4453 routing_id_, intent_data, intent_id)); |
4436 } | 4454 } |
4437 | 4455 |
4438 bool RenderView::IsNonLocalTopLevelNavigation( | 4456 bool RenderViewImpl::IsNonLocalTopLevelNavigation( |
4439 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { | 4457 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { |
4440 // Must be a top level frame. | 4458 // Must be a top level frame. |
4441 if (frame->parent() != NULL) | 4459 if (frame->parent() != NULL) |
4442 return false; | 4460 return false; |
4443 | 4461 |
4444 // Navigations initiated within Webkit are not sent out to the external host | 4462 // Navigations initiated within Webkit are not sent out to the external host |
4445 // in the following cases. | 4463 // in the following cases. |
4446 // 1. The url scheme is not http/https | 4464 // 1. The url scheme is not http/https |
4447 // 2. The origin of the url and the opener is the same in which case the | 4465 // 2. The origin of the url and the opener is the same in which case the |
4448 // opener relationship is maintained. | 4466 // opener relationship is maintained. |
(...skipping 14 matching lines...) Expand all Loading... |
4463 if (!opener) { | 4481 if (!opener) { |
4464 return true; | 4482 return true; |
4465 } else { | 4483 } else { |
4466 if (url.GetOrigin() != GURL(opener->document().url()).GetOrigin()) | 4484 if (url.GetOrigin() != GURL(opener->document().url()).GetOrigin()) |
4467 return true; | 4485 return true; |
4468 } | 4486 } |
4469 } | 4487 } |
4470 return false; | 4488 return false; |
4471 } | 4489 } |
4472 | 4490 |
4473 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code, | 4491 void RenderViewImpl::OnAsyncFileOpened( |
4474 IPC::PlatformFileForTransit file_for_transit, | 4492 base::PlatformFileError error_code, |
4475 int message_id) { | 4493 IPC::PlatformFileForTransit file_for_transit, |
| 4494 int message_id) { |
4476 pepper_delegate_.OnAsyncFileOpened( | 4495 pepper_delegate_.OnAsyncFileOpened( |
4477 error_code, | 4496 error_code, |
4478 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), | 4497 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), |
4479 message_id); | 4498 message_id); |
4480 } | 4499 } |
4481 | 4500 |
4482 void RenderView::OnPpapiBrokerChannelCreated( | 4501 void RenderViewImpl::OnPpapiBrokerChannelCreated( |
4483 int request_id, | 4502 int request_id, |
4484 base::ProcessHandle broker_process_handle, | 4503 base::ProcessHandle broker_process_handle, |
4485 const IPC::ChannelHandle& handle) { | 4504 const IPC::ChannelHandle& handle) { |
4486 pepper_delegate_.OnPpapiBrokerChannelCreated(request_id, | 4505 pepper_delegate_.OnPpapiBrokerChannelCreated(request_id, |
4487 broker_process_handle, | 4506 broker_process_handle, |
4488 handle); | 4507 handle); |
4489 } | 4508 } |
4490 | 4509 |
4491 #if defined(OS_MACOSX) | 4510 #if defined(OS_MACOSX) |
4492 void RenderView::OnSelectPopupMenuItem(int selected_index) { | 4511 void RenderViewImpl::OnSelectPopupMenuItem(int selected_index) { |
4493 if (external_popup_menu_ == NULL) { | 4512 if (external_popup_menu_ == NULL) { |
4494 // Crash reports from the field indicate that we can be notified with a | 4513 // Crash reports from the field indicate that we can be notified with a |
4495 // NULL external popup menu (we probably get notified twice). | 4514 // NULL external popup menu (we probably get notified twice). |
4496 // If you hit this please file a bug against jcivelli and include the page | 4515 // If you hit this please file a bug against jcivelli and include the page |
4497 // and steps to repro. | 4516 // and steps to repro. |
4498 NOTREACHED(); | 4517 NOTREACHED(); |
4499 return; | 4518 return; |
4500 } | 4519 } |
4501 external_popup_menu_->DidSelectItem(selected_index); | 4520 external_popup_menu_->DidSelectItem(selected_index); |
4502 external_popup_menu_.reset(); | 4521 external_popup_menu_.reset(); |
4503 } | 4522 } |
4504 #endif | 4523 #endif |
4505 | 4524 |
4506 #if defined(ENABLE_FLAPPER_HACKS) | 4525 #if defined(ENABLE_FLAPPER_HACKS) |
4507 void RenderView::OnConnectTcpACK( | 4526 void RenderViewImpl::OnConnectTcpACK( |
4508 int request_id, | 4527 int request_id, |
4509 IPC::PlatformFileForTransit socket_for_transit, | 4528 IPC::PlatformFileForTransit socket_for_transit, |
4510 const PP_Flash_NetAddress& local_addr, | 4529 const PP_Flash_NetAddress& local_addr, |
4511 const PP_Flash_NetAddress& remote_addr) { | 4530 const PP_Flash_NetAddress& remote_addr) { |
4512 pepper_delegate_.OnConnectTcpACK( | 4531 pepper_delegate_.OnConnectTcpACK( |
4513 request_id, | 4532 request_id, |
4514 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), | 4533 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), |
4515 local_addr, | 4534 local_addr, |
4516 remote_addr); | 4535 remote_addr); |
4517 } | 4536 } |
4518 #endif | 4537 #endif |
4519 | 4538 |
4520 void RenderView::OnContextMenuClosed( | 4539 void RenderViewImpl::OnContextMenuClosed( |
4521 const webkit_glue::CustomContextMenuContext& custom_context) { | 4540 const webkit_glue::CustomContextMenuContext& custom_context) { |
4522 if (custom_context.is_pepper_menu) | 4541 if (custom_context.is_pepper_menu) |
4523 pepper_delegate_.OnContextMenuClosed(custom_context); | 4542 pepper_delegate_.OnContextMenuClosed(custom_context); |
4524 else | 4543 else |
4525 context_menu_node_.reset(); | 4544 context_menu_node_.reset(); |
4526 } | 4545 } |
4527 | 4546 |
4528 void RenderView::OnEnableViewSourceMode() { | 4547 void RenderViewImpl::OnEnableViewSourceMode() { |
4529 if (!webview()) | 4548 if (!webview()) |
4530 return; | 4549 return; |
4531 WebFrame* main_frame = webview()->mainFrame(); | 4550 WebFrame* main_frame = webview()->mainFrame(); |
4532 if (!main_frame) | 4551 if (!main_frame) |
4533 return; | 4552 return; |
4534 main_frame->enableViewSourceMode(true); | 4553 main_frame->enableViewSourceMode(true); |
4535 } | 4554 } |
4536 | 4555 |
4537 void RenderView::OnLockMouseACK(bool succeeded) { | 4556 void RenderViewImpl::OnLockMouseACK(bool succeeded) { |
4538 pepper_delegate_.OnLockMouseACK(succeeded); | 4557 pepper_delegate_.OnLockMouseACK(succeeded); |
4539 } | 4558 } |
4540 | 4559 |
4541 void RenderView::OnMouseLockLost() { | 4560 void RenderViewImpl::OnMouseLockLost() { |
4542 pepper_delegate_.OnMouseLockLost(); | 4561 pepper_delegate_.OnMouseLockLost(); |
4543 } | 4562 } |
4544 | 4563 |
4545 bool RenderView::WebWidgetHandlesCompositorScheduling() const { | 4564 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
4546 return webview()->settings()->useThreadedCompositor(); | 4565 return webview()->settings()->useThreadedCompositor(); |
4547 } | 4566 } |
OLD | NEW |