| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 // Remember that we've already processed this request, so we don't update | 1966 // Remember that we've already processed this request, so we don't update |
| 1967 // the session history again. We do this regardless of whether this is | 1967 // the session history again. We do this regardless of whether this is |
| 1968 // a session history navigation, because if we attempted a session history | 1968 // a session history navigation, because if we attempted a session history |
| 1969 // navigation without valid HistoryItem state, WebCore will think it is a | 1969 // navigation without valid HistoryItem state, WebCore will think it is a |
| 1970 // new navigation. | 1970 // new navigation. |
| 1971 navigation_state->set_request_committed(true); | 1971 navigation_state->set_request_committed(true); |
| 1972 | 1972 |
| 1973 UpdateURL(frame); | 1973 UpdateURL(frame); |
| 1974 | 1974 |
| 1975 // Check whether we have new encoding name. | 1975 // Check whether we have new encoding name. |
| 1976 render_view_->UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 1976 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 1977 } | 1977 } |
| 1978 | 1978 |
| 1979 void RenderFrameImpl::didClearWindowObject(blink::WebLocalFrame* frame) { | 1979 void RenderFrameImpl::didClearWindowObject(blink::WebLocalFrame* frame) { |
| 1980 DCHECK(!frame_ || frame_ == frame); | 1980 DCHECK(!frame_ || frame_ == frame); |
| 1981 // TODO(nasko): Move implementation here. Needed state: | 1981 // TODO(nasko): Move implementation here. Needed state: |
| 1982 // * enabled_bindings_ | 1982 // * enabled_bindings_ |
| 1983 // * dom_automation_controller_ | 1983 // * dom_automation_controller_ |
| 1984 // * stats_collection_controller_ | 1984 // * stats_collection_controller_ |
| 1985 | 1985 |
| 1986 render_view_->didClearWindowObject(frame); | 1986 render_view_->didClearWindowObject(frame); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2006 } | 2006 } |
| 2007 | 2007 |
| 2008 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2008 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 2009 DidCreateDocumentElement(frame)); | 2009 DidCreateDocumentElement(frame)); |
| 2010 } | 2010 } |
| 2011 | 2011 |
| 2012 void RenderFrameImpl::didReceiveTitle(blink::WebLocalFrame* frame, | 2012 void RenderFrameImpl::didReceiveTitle(blink::WebLocalFrame* frame, |
| 2013 const blink::WebString& title, | 2013 const blink::WebString& title, |
| 2014 blink::WebTextDirection direction) { | 2014 blink::WebTextDirection direction) { |
| 2015 DCHECK(!frame_ || frame_ == frame); | 2015 DCHECK(!frame_ || frame_ == frame); |
| 2016 // TODO(nasko): Investigate wheather implementation should move here. | 2016 // Ignore all but top level navigations. |
| 2017 render_view_->didReceiveTitle(frame, title, direction); | 2017 if (!frame->parent()) { |
| 2018 base::string16 title16 = title; |
| 2019 base::debug::TraceLog::GetInstance()->UpdateProcessLabel( |
| 2020 routing_id_, base::UTF16ToUTF8(title16)); |
| 2021 |
| 2022 base::string16 shortened_title = title16.substr(0, kMaxTitleChars); |
| 2023 Send(new FrameHostMsg_UpdateTitle(routing_id_, |
| 2024 render_view_->page_id_, |
| 2025 shortened_title, direction)); |
| 2026 } |
| 2027 |
| 2028 // Also check whether we have new encoding name. |
| 2029 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 2018 } | 2030 } |
| 2019 | 2031 |
| 2020 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame, | 2032 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame, |
| 2021 blink::WebIconURL::Type icon_type) { | 2033 blink::WebIconURL::Type icon_type) { |
| 2022 DCHECK(!frame_ || frame_ == frame); | 2034 DCHECK(!frame_ || frame_ == frame); |
| 2023 // TODO(nasko): Investigate wheather implementation should move here. | 2035 // TODO(nasko): Investigate wheather implementation should move here. |
| 2024 render_view_->didChangeIcon(frame, icon_type); | 2036 render_view_->didChangeIcon(frame, icon_type); |
| 2025 } | 2037 } |
| 2026 | 2038 |
| 2027 void RenderFrameImpl::didFinishDocumentLoad(blink::WebLocalFrame* frame) { | 2039 void RenderFrameImpl::didFinishDocumentLoad(blink::WebLocalFrame* frame) { |
| 2028 DCHECK(!frame_ || frame_ == frame); | 2040 DCHECK(!frame_ || frame_ == frame); |
| 2029 WebDataSource* ds = frame->dataSource(); | 2041 WebDataSource* ds = frame->dataSource(); |
| 2030 DocumentState* document_state = DocumentState::FromDataSource(ds); | 2042 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2031 document_state->set_finish_document_load_time(Time::Now()); | 2043 document_state->set_finish_document_load_time(Time::Now()); |
| 2032 | 2044 |
| 2033 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); | 2045 Send(new FrameHostMsg_DidFinishDocumentLoad(routing_id_)); |
| 2034 | 2046 |
| 2035 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2047 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 2036 DidFinishDocumentLoad(frame)); | 2048 DidFinishDocumentLoad(frame)); |
| 2037 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishDocumentLoad()); | 2049 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishDocumentLoad()); |
| 2038 | 2050 |
| 2039 // Check whether we have new encoding name. | 2051 // Check whether we have new encoding name. |
| 2040 render_view_->UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2052 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
| 2041 } | 2053 } |
| 2042 | 2054 |
| 2043 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) { | 2055 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) { |
| 2044 DCHECK(!frame_ || frame_ == frame); | 2056 DCHECK(!frame_ || frame_ == frame); |
| 2045 if (!frame->parent()) | 2057 if (!frame->parent()) |
| 2046 Send(new FrameHostMsg_DocumentOnLoadCompleted(routing_id_)); | 2058 Send(new FrameHostMsg_DocumentOnLoadCompleted(routing_id_)); |
| 2047 } | 2059 } |
| 2048 | 2060 |
| 2049 void RenderFrameImpl::didFailLoad(blink::WebLocalFrame* frame, | 2061 void RenderFrameImpl::didFailLoad(blink::WebLocalFrame* frame, |
| 2050 const blink::WebURLError& error) { | 2062 const blink::WebURLError& error) { |
| (...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3294 if (policy == blink::WebNavigationPolicyNewBackgroundTab || | 3306 if (policy == blink::WebNavigationPolicyNewBackgroundTab || |
| 3295 policy == blink::WebNavigationPolicyNewForegroundTab || | 3307 policy == blink::WebNavigationPolicyNewForegroundTab || |
| 3296 policy == blink::WebNavigationPolicyNewWindow || | 3308 policy == blink::WebNavigationPolicyNewWindow || |
| 3297 policy == blink::WebNavigationPolicyNewPopup) { | 3309 policy == blink::WebNavigationPolicyNewPopup) { |
| 3298 WebUserGestureIndicator::consumeUserGesture(); | 3310 WebUserGestureIndicator::consumeUserGesture(); |
| 3299 } | 3311 } |
| 3300 | 3312 |
| 3301 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 3313 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
| 3302 } | 3314 } |
| 3303 | 3315 |
| 3316 void RenderFrameImpl::UpdateEncoding(WebFrame* frame, |
| 3317 const std::string& encoding_name) { |
| 3318 // Only update main frame's encoding_name. |
| 3319 if (!frame->parent()) |
| 3320 Send(new FrameHostMsg_UpdateEncoding(routing_id_, encoding_name)); |
| 3321 } |
| 3322 |
| 3304 void RenderFrameImpl::SyncSelectionIfRequired() { | 3323 void RenderFrameImpl::SyncSelectionIfRequired() { |
| 3305 base::string16 text; | 3324 base::string16 text; |
| 3306 size_t offset; | 3325 size_t offset; |
| 3307 gfx::Range range; | 3326 gfx::Range range; |
| 3308 #if defined(ENABLE_PLUGINS) | 3327 #if defined(ENABLE_PLUGINS) |
| 3309 if (render_view_->focused_pepper_plugin_) { | 3328 if (render_view_->focused_pepper_plugin_) { |
| 3310 render_view_->focused_pepper_plugin_->GetSurroundingText(&text, &range); | 3329 render_view_->focused_pepper_plugin_->GetSurroundingText(&text, &range); |
| 3311 offset = 0; // Pepper API does not support offset reporting. | 3330 offset = 0; // Pepper API does not support offset reporting. |
| 3312 // TODO(kinaba): cut as needed. | 3331 // TODO(kinaba): cut as needed. |
| 3313 } else | 3332 } else |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3451 weak_factory_.GetWeakPtr(), | 3470 weak_factory_.GetWeakPtr(), |
| 3452 render_view_->media_player_manager_, | 3471 render_view_->media_player_manager_, |
| 3453 stream_texture_factory, | 3472 stream_texture_factory, |
| 3454 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), | 3473 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), |
| 3455 new RenderMediaLog()); | 3474 new RenderMediaLog()); |
| 3456 } | 3475 } |
| 3457 | 3476 |
| 3458 #endif | 3477 #endif |
| 3459 | 3478 |
| 3460 } // namespace content | 3479 } // namespace content |
| OLD | NEW |