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.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> |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1172 | 1172 |
1173 // Check if the navigation was within the same page, in which case we don't | 1173 // Check if the navigation was within the same page, in which case we don't |
1174 // want to clear the accessibility cache. | 1174 // want to clear the accessibility cache. |
1175 if (accessibility_.get() && !navigation_state->was_within_same_page()) { | 1175 if (accessibility_.get() && !navigation_state->was_within_same_page()) { |
1176 accessibility_.reset(); | 1176 accessibility_.reset(); |
1177 pending_accessibility_notifications_.clear(); | 1177 pending_accessibility_notifications_.clear(); |
1178 } | 1178 } |
1179 } | 1179 } |
1180 | 1180 |
1181 // Tell the embedding application that the title of the active page has changed | 1181 // Tell the embedding application that the title of the active page has changed |
1182 void RenderView::UpdateTitle(WebFrame* frame, const string16& title) { | 1182 void RenderView::UpdateTitle(WebFrame* frame, const string16& title, |
1183 // Ignore all but top level navigations... | 1183 WebTextDirection title_direction) { |
1184 if (!frame->parent()) { | 1184 // Ignore all but top level navigations. |
1185 Send(new ViewHostMsg_UpdateTitle( | 1185 if (frame->parent()) |
1186 routing_id_, | 1186 return; |
1187 page_id_, | 1187 |
1188 title.length() > content::kMaxTitleChars ? | 1188 string16 shortened_title = title.substr(0, content::kMaxTitleChars); |
brettw
2011/08/01 21:40:02
Personally, I'd remove the blank line after this,
| |
1189 title.substr(0, content::kMaxTitleChars) : title)); | 1189 |
1190 } | 1190 Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title, |
1191 title_direction)); | |
1191 } | 1192 } |
1192 | 1193 |
1193 void RenderView::UpdateEncoding(WebFrame* frame, | 1194 void RenderView::UpdateEncoding(WebFrame* frame, |
1194 const std::string& encoding_name) { | 1195 const std::string& encoding_name) { |
1195 // Only update main frame's encoding_name. | 1196 // Only update main frame's encoding_name. |
1196 if (webview()->mainFrame() == frame && | 1197 if (webview()->mainFrame() == frame && |
1197 last_encoding_name_ != encoding_name) { | 1198 last_encoding_name_ != encoding_name) { |
1198 // Save the encoding name for later comparing. | 1199 // Save the encoding name for later comparing. |
1199 last_encoding_name_ = encoding_name; | 1200 last_encoding_name_ = encoding_name; |
1200 | 1201 |
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2534 if (frame == webview()->mainFrame()) | 2535 if (frame == webview()->mainFrame()) |
2535 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); | 2536 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); |
2536 } | 2537 } |
2537 | 2538 |
2538 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 2539 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
2539 DidCreateDocumentElement(frame)); | 2540 DidCreateDocumentElement(frame)); |
2540 } | 2541 } |
2541 | 2542 |
2542 void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title, | 2543 void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title, |
2543 WebTextDirection direction) { | 2544 WebTextDirection direction) { |
2544 // TODO: pass direction through various APIs. | 2545 UpdateTitle(frame, title, direction); |
2545 // http://code.google.com/p/chromium/issues/detail?id=79903 | |
2546 UpdateTitle(frame, title); | |
2547 | 2546 |
2548 // Also check whether we have new encoding name. | 2547 // Also check whether we have new encoding name. |
2549 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2548 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
2550 } | 2549 } |
2551 | 2550 |
2552 void RenderView::didChangeIcon(WebFrame* frame, WebIconURL::Type type) { | 2551 void RenderView::didChangeIcon(WebFrame* frame, WebIconURL::Type type) { |
2553 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 2552 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
2554 DidChangeIcon(frame, type)); | 2553 DidChangeIcon(frame, type)); |
2555 } | 2554 } |
2556 | 2555 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2601 // existing navigation state to a content-initiated navigation state. | 2600 // existing navigation state to a content-initiated navigation state. |
2602 // DidCreateDataSource conveniently takes care of this for us. | 2601 // DidCreateDataSource conveniently takes care of this for us. |
2603 didCreateDataSource(frame, frame->dataSource()); | 2602 didCreateDataSource(frame, frame->dataSource()); |
2604 | 2603 |
2605 NavigationState* new_state = | 2604 NavigationState* new_state = |
2606 NavigationState::FromDataSource(frame->dataSource()); | 2605 NavigationState::FromDataSource(frame->dataSource()); |
2607 new_state->set_was_within_same_page(true); | 2606 new_state->set_was_within_same_page(true); |
2608 | 2607 |
2609 didCommitProvisionalLoad(frame, is_new_navigation); | 2608 didCommitProvisionalLoad(frame, is_new_navigation); |
2610 | 2609 |
2611 UpdateTitle(frame, frame->view()->mainFrame()->dataSource()->pageTitle()); | 2610 UpdateTitle(frame, frame->view()->mainFrame()->dataSource()->pageTitle(), |
2611 frame->view()->mainFrame()->dataSource()->pageTitleDirection()); | |
2612 } | 2612 } |
2613 | 2613 |
2614 void RenderView::didUpdateCurrentHistoryItem(WebFrame* frame) { | 2614 void RenderView::didUpdateCurrentHistoryItem(WebFrame* frame) { |
2615 StartNavStateSyncTimerIfNecessary(); | 2615 StartNavStateSyncTimerIfNecessary(); |
2616 } | 2616 } |
2617 | 2617 |
2618 void RenderView::assignIdentifierToRequest( | 2618 void RenderView::assignIdentifierToRequest( |
2619 WebFrame* frame, unsigned identifier, const WebURLRequest& request) { | 2619 WebFrame* frame, unsigned identifier, const WebURLRequest& request) { |
2620 // Ignore | 2620 // Ignore |
2621 } | 2621 } |
(...skipping 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4431 } | 4431 } |
4432 #endif | 4432 #endif |
4433 | 4433 |
4434 void RenderView::OnContextMenuClosed( | 4434 void RenderView::OnContextMenuClosed( |
4435 const webkit_glue::CustomContextMenuContext& custom_context) { | 4435 const webkit_glue::CustomContextMenuContext& custom_context) { |
4436 if (custom_context.is_pepper_menu) | 4436 if (custom_context.is_pepper_menu) |
4437 pepper_delegate_.OnContextMenuClosed(custom_context); | 4437 pepper_delegate_.OnContextMenuClosed(custom_context); |
4438 else | 4438 else |
4439 context_menu_node_.reset(); | 4439 context_menu_node_.reset(); |
4440 } | 4440 } |
OLD | NEW |