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 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 | 1119 |
1120 // Check if the navigation was within the same page, in which case we don't | 1120 // Check if the navigation was within the same page, in which case we don't |
1121 // want to clear the accessibility cache. | 1121 // want to clear the accessibility cache. |
1122 if (accessibility_.get() && !navigation_state->was_within_same_page()) { | 1122 if (accessibility_.get() && !navigation_state->was_within_same_page()) { |
1123 accessibility_.reset(); | 1123 accessibility_.reset(); |
1124 pending_accessibility_notifications_.clear(); | 1124 pending_accessibility_notifications_.clear(); |
1125 } | 1125 } |
1126 } | 1126 } |
1127 | 1127 |
1128 // Tell the embedding application that the title of the active page has changed | 1128 // Tell the embedding application that the title of the active page has changed |
1129 void RenderView::UpdateTitle(WebFrame* frame, const string16& title) { | 1129 void RenderView::UpdateTitle(WebFrame* frame, const string16& title, |
| 1130 WebTextDirection title_direction) { |
1130 // Ignore all but top level navigations... | 1131 // Ignore all but top level navigations... |
1131 if (!frame->parent()) { | 1132 if (!frame->parent()) { |
1132 Send(new ViewHostMsg_UpdateTitle( | 1133 Send(new ViewHostMsg_UpdateTitle( |
1133 routing_id_, | 1134 routing_id_, |
1134 page_id_, | 1135 page_id_, |
1135 UTF16ToWideHack(title.length() > content::kMaxTitleChars ? | 1136 title.length() > content::kMaxTitleChars ? |
1136 title.substr(0, content::kMaxTitleChars) : title))); | 1137 title.substr(0, content::kMaxTitleChars) : title, |
| 1138 title_direction)); |
1137 } | 1139 } |
1138 } | 1140 } |
1139 | 1141 |
1140 void RenderView::UpdateEncoding(WebFrame* frame, | 1142 void RenderView::UpdateEncoding(WebFrame* frame, |
1141 const std::string& encoding_name) { | 1143 const std::string& encoding_name) { |
1142 // Only update main frame's encoding_name. | 1144 // Only update main frame's encoding_name. |
1143 if (webview()->mainFrame() == frame && | 1145 if (webview()->mainFrame() == frame && |
1144 last_encoding_name_ != encoding_name) { | 1146 last_encoding_name_ != encoding_name) { |
1145 // Save the encoding name for later comparing. | 1147 // Save the encoding name for later comparing. |
1146 last_encoding_name_ = encoding_name; | 1148 last_encoding_name_ = encoding_name; |
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2468 if (frame == webview()->mainFrame()) | 2470 if (frame == webview()->mainFrame()) |
2469 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); | 2471 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); |
2470 } | 2472 } |
2471 | 2473 |
2472 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 2474 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
2473 DidCreateDocumentElement(frame)); | 2475 DidCreateDocumentElement(frame)); |
2474 } | 2476 } |
2475 | 2477 |
2476 void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title, | 2478 void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title, |
2477 WebTextDirection direction) { | 2479 WebTextDirection direction) { |
2478 // TODO: pass direction through various APIs. | 2480 UpdateTitle(frame, title, direction); |
2479 // http://code.google.com/p/chromium/issues/detail?id=79903 | |
2480 UpdateTitle(frame, title); | |
2481 | 2481 |
2482 // Also check whether we have new encoding name. | 2482 // Also check whether we have new encoding name. |
2483 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); | 2483 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
2484 } | 2484 } |
2485 | 2485 |
2486 void RenderView::didChangeIcons(WebFrame* frame) { | 2486 void RenderView::didChangeIcons(WebFrame* frame) { |
2487 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidChangeIcons(frame)); | 2487 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidChangeIcons(frame)); |
2488 } | 2488 } |
2489 | 2489 |
2490 void RenderView::didFinishDocumentLoad(WebFrame* frame) { | 2490 void RenderView::didFinishDocumentLoad(WebFrame* frame) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2534 // existing navigation state to a content-initiated navigation state. | 2534 // existing navigation state to a content-initiated navigation state. |
2535 // DidCreateDataSource conveniently takes care of this for us. | 2535 // DidCreateDataSource conveniently takes care of this for us. |
2536 didCreateDataSource(frame, frame->dataSource()); | 2536 didCreateDataSource(frame, frame->dataSource()); |
2537 | 2537 |
2538 NavigationState* new_state = | 2538 NavigationState* new_state = |
2539 NavigationState::FromDataSource(frame->dataSource()); | 2539 NavigationState::FromDataSource(frame->dataSource()); |
2540 new_state->set_was_within_same_page(true); | 2540 new_state->set_was_within_same_page(true); |
2541 | 2541 |
2542 didCommitProvisionalLoad(frame, is_new_navigation); | 2542 didCommitProvisionalLoad(frame, is_new_navigation); |
2543 | 2543 |
2544 UpdateTitle(frame, frame->view()->mainFrame()->dataSource()->pageTitle()); | 2544 // TODO(evan): update this to use ->pageTitleDirection() once we pull in new |
| 2545 // WebKit. |
| 2546 UpdateTitle(frame, frame->view()->mainFrame()->dataSource()->pageTitle(), |
| 2547 WebKit::WebTextDirectionLeftToRight); |
2545 } | 2548 } |
2546 | 2549 |
2547 void RenderView::didUpdateCurrentHistoryItem(WebFrame* frame) { | 2550 void RenderView::didUpdateCurrentHistoryItem(WebFrame* frame) { |
2548 StartNavStateSyncTimerIfNecessary(); | 2551 StartNavStateSyncTimerIfNecessary(); |
2549 } | 2552 } |
2550 | 2553 |
2551 void RenderView::assignIdentifierToRequest( | 2554 void RenderView::assignIdentifierToRequest( |
2552 WebFrame* frame, unsigned identifier, const WebURLRequest& request) { | 2555 WebFrame* frame, unsigned identifier, const WebURLRequest& request) { |
2553 // Ignore | 2556 // Ignore |
2554 } | 2557 } |
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4254 const webkit_glue::CustomContextMenuContext& custom_context) { | 4257 const webkit_glue::CustomContextMenuContext& custom_context) { |
4255 if (custom_context.is_pepper_menu) | 4258 if (custom_context.is_pepper_menu) |
4256 pepper_delegate_.OnContextMenuClosed(custom_context); | 4259 pepper_delegate_.OnContextMenuClosed(custom_context); |
4257 else | 4260 else |
4258 context_menu_node_.reset(); | 4261 context_menu_node_.reset(); |
4259 } | 4262 } |
4260 | 4263 |
4261 void RenderView::OnNetworkStateChanged(bool online) { | 4264 void RenderView::OnNetworkStateChanged(bool online) { |
4262 WebNetworkStateNotifier::setOnLine(online); | 4265 WebNetworkStateNotifier::setOnLine(online); |
4263 } | 4266 } |
OLD | NEW |