Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: content/renderer/render_view.cc

Issue 7514013: Enforce the page title direction (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ok Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 1170
1171 // Check if the navigation was within the same page, in which case we don't 1171 // Check if the navigation was within the same page, in which case we don't
1172 // want to clear the accessibility cache. 1172 // want to clear the accessibility cache.
1173 if (accessibility_.get() && !navigation_state->was_within_same_page()) { 1173 if (accessibility_.get() && !navigation_state->was_within_same_page()) {
1174 accessibility_.reset(); 1174 accessibility_.reset();
1175 pending_accessibility_notifications_.clear(); 1175 pending_accessibility_notifications_.clear();
1176 } 1176 }
1177 } 1177 }
1178 1178
1179 // Tell the embedding application that the title of the active page has changed 1179 // Tell the embedding application that the title of the active page has changed
1180 void RenderView::UpdateTitle(WebFrame* frame, const string16& title) { 1180 void RenderView::UpdateTitle(WebFrame* frame, const string16& title,
1181 // Ignore all but top level navigations... 1181 WebTextDirection title_direction) {
1182 if (!frame->parent()) { 1182 // Ignore all but top level navigations.
1183 Send(new ViewHostMsg_UpdateTitle( 1183 if (frame->parent())
1184 routing_id_, 1184 return;
1185 page_id_, 1185
1186 title.length() > content::kMaxTitleChars ? 1186 // Insert a direction mark to make the title strongly directional.
1187 title.substr(0, content::kMaxTitleChars) : title)); 1187 string16 fixed_title;
1188 } 1188 if (title_direction == WebKit::WebTextDirectionLeftToRight)
1189 fixed_title.push_back(0x200E); // U+200E LRM
brettw 2011/07/27 22:28:22 There are consts for these in base/i18n/rtl.h so y
1190 else
1191 fixed_title.push_back(0x200F); // U+200E RLM
1192 fixed_title.append(title.substr(0, content::kMaxTitleChars));
1193
1194 Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, fixed_title));
1189 } 1195 }
1190 1196
1191 void RenderView::UpdateEncoding(WebFrame* frame, 1197 void RenderView::UpdateEncoding(WebFrame* frame,
1192 const std::string& encoding_name) { 1198 const std::string& encoding_name) {
1193 // Only update main frame's encoding_name. 1199 // Only update main frame's encoding_name.
1194 if (webview()->mainFrame() == frame && 1200 if (webview()->mainFrame() == frame &&
1195 last_encoding_name_ != encoding_name) { 1201 last_encoding_name_ != encoding_name) {
1196 // Save the encoding name for later comparing. 1202 // Save the encoding name for later comparing.
1197 last_encoding_name_ = encoding_name; 1203 last_encoding_name_ = encoding_name;
1198 1204
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 if (frame == webview()->mainFrame()) 2517 if (frame == webview()->mainFrame())
2512 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); 2518 Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_));
2513 } 2519 }
2514 2520
2515 FOR_EACH_OBSERVER(RenderViewObserver, observers_, 2521 FOR_EACH_OBSERVER(RenderViewObserver, observers_,
2516 DidCreateDocumentElement(frame)); 2522 DidCreateDocumentElement(frame));
2517 } 2523 }
2518 2524
2519 void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title, 2525 void RenderView::didReceiveTitle(WebFrame* frame, const WebString& title,
2520 WebTextDirection direction) { 2526 WebTextDirection direction) {
2521 // TODO: pass direction through various APIs. 2527 UpdateTitle(frame, title, direction);
2522 // http://code.google.com/p/chromium/issues/detail?id=79903
2523 UpdateTitle(frame, title);
2524 2528
2525 // Also check whether we have new encoding name. 2529 // Also check whether we have new encoding name.
2526 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); 2530 UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
2527 } 2531 }
2528 2532
2529 void RenderView::didChangeIcon(WebFrame* frame, WebIconURL::Type type) { 2533 void RenderView::didChangeIcon(WebFrame* frame, WebIconURL::Type type) {
2530 FOR_EACH_OBSERVER(RenderViewObserver, observers_, 2534 FOR_EACH_OBSERVER(RenderViewObserver, observers_,
2531 DidChangeIcon(frame, type)); 2535 DidChangeIcon(frame, type));
2532 } 2536 }
2533 2537
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 // existing navigation state to a content-initiated navigation state. 2582 // existing navigation state to a content-initiated navigation state.
2579 // DidCreateDataSource conveniently takes care of this for us. 2583 // DidCreateDataSource conveniently takes care of this for us.
2580 didCreateDataSource(frame, frame->dataSource()); 2584 didCreateDataSource(frame, frame->dataSource());
2581 2585
2582 NavigationState* new_state = 2586 NavigationState* new_state =
2583 NavigationState::FromDataSource(frame->dataSource()); 2587 NavigationState::FromDataSource(frame->dataSource());
2584 new_state->set_was_within_same_page(true); 2588 new_state->set_was_within_same_page(true);
2585 2589
2586 didCommitProvisionalLoad(frame, is_new_navigation); 2590 didCommitProvisionalLoad(frame, is_new_navigation);
2587 2591
2588 UpdateTitle(frame, frame->view()->mainFrame()->dataSource()->pageTitle()); 2592 // TODO(evan): update this to use ->pageTitleDirection() once we pull in new
2593 // WebKit.
2594 // http://code.google.com/p/chromium/issues/detail?id=27094
2595 UpdateTitle(frame, frame->view()->mainFrame()->dataSource()->pageTitle(),
2596 WebKit::WebTextDirectionLeftToRight);
2589 } 2597 }
2590 2598
2591 void RenderView::didUpdateCurrentHistoryItem(WebFrame* frame) { 2599 void RenderView::didUpdateCurrentHistoryItem(WebFrame* frame) {
2592 StartNavStateSyncTimerIfNecessary(); 2600 StartNavStateSyncTimerIfNecessary();
2593 } 2601 }
2594 2602
2595 void RenderView::assignIdentifierToRequest( 2603 void RenderView::assignIdentifierToRequest(
2596 WebFrame* frame, unsigned identifier, const WebURLRequest& request) { 2604 WebFrame* frame, unsigned identifier, const WebURLRequest& request) {
2597 // Ignore 2605 // Ignore
2598 } 2606 }
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
4377 } 4385 }
4378 #endif 4386 #endif
4379 4387
4380 void RenderView::OnContextMenuClosed( 4388 void RenderView::OnContextMenuClosed(
4381 const webkit_glue::CustomContextMenuContext& custom_context) { 4389 const webkit_glue::CustomContextMenuContext& custom_context) {
4382 if (custom_context.is_pepper_menu) 4390 if (custom_context.is_pepper_menu)
4383 pepper_delegate_.OnContextMenuClosed(custom_context); 4391 pepper_delegate_.OnContextMenuClosed(custom_context);
4384 else 4392 else
4385 context_menu_node_.reset(); 4393 context_menu_node_.reset();
4386 } 4394 }
OLDNEW
« no previous file with comments | « content/renderer/render_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698