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

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

Issue 102593002: Convert string16 to base::string16 in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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_impl.h ('k') | content/renderer/render_view_impl_params.h » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 1096
1097 /*static*/ 1097 /*static*/
1098 RenderViewImpl* RenderViewImpl::Create( 1098 RenderViewImpl* RenderViewImpl::Create(
1099 int32 opener_id, 1099 int32 opener_id,
1100 const RendererPreferences& renderer_prefs, 1100 const RendererPreferences& renderer_prefs,
1101 const WebPreferences& webkit_prefs, 1101 const WebPreferences& webkit_prefs,
1102 int32 routing_id, 1102 int32 routing_id,
1103 int32 main_frame_routing_id, 1103 int32 main_frame_routing_id,
1104 int32 surface_id, 1104 int32 surface_id,
1105 int64 session_storage_namespace_id, 1105 int64 session_storage_namespace_id,
1106 const string16& frame_name, 1106 const base::string16& frame_name,
1107 bool is_renderer_created, 1107 bool is_renderer_created,
1108 bool swapped_out, 1108 bool swapped_out,
1109 bool hidden, 1109 bool hidden,
1110 int32 next_page_id, 1110 int32 next_page_id,
1111 const blink::WebScreenInfo& screen_info, 1111 const blink::WebScreenInfo& screen_info,
1112 AccessibilityMode accessibility_mode, 1112 AccessibilityMode accessibility_mode,
1113 bool allow_partial_swap) { 1113 bool allow_partial_swap) {
1114 DCHECK(routing_id != MSG_ROUTING_NONE); 1114 DCHECK(routing_id != MSG_ROUTING_NONE);
1115 RenderViewImplParams params( 1115 RenderViewImplParams params(
1116 opener_id, 1116 opener_id,
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 } 1690 }
1691 1691
1692 void RenderViewImpl::OnRedo() { 1692 void RenderViewImpl::OnRedo() {
1693 if (!webview()) 1693 if (!webview())
1694 return; 1694 return;
1695 1695
1696 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Redo"), 1696 webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Redo"),
1697 GetFocusedNode()); 1697 GetFocusedNode());
1698 } 1698 }
1699 1699
1700 void RenderViewImpl::OnReplace(const string16& text) { 1700 void RenderViewImpl::OnReplace(const base::string16& text) {
1701 if (!webview()) 1701 if (!webview())
1702 return; 1702 return;
1703 1703
1704 WebFrame* frame = webview()->focusedFrame(); 1704 WebFrame* frame = webview()->focusedFrame();
1705 if (!frame->hasSelection()) 1705 if (!frame->hasSelection())
1706 frame->selectWordAroundCaret(); 1706 frame->selectWordAroundCaret();
1707 1707
1708 frame->replaceSelection(text); 1708 frame->replaceSelection(text);
1709 } 1709 }
1710 1710
1711 void RenderViewImpl::OnReplaceMisspelling(const string16& text) { 1711 void RenderViewImpl::OnReplaceMisspelling(const base::string16& text) {
1712 if (!webview()) 1712 if (!webview())
1713 return; 1713 return;
1714 1714
1715 WebFrame* frame = webview()->focusedFrame(); 1715 WebFrame* frame = webview()->focusedFrame();
1716 if (!frame->hasSelection()) 1716 if (!frame->hasSelection())
1717 return; 1717 return;
1718 1718
1719 frame->replaceMisspelledRange(text); 1719 frame->replaceMisspelledRange(text);
1720 } 1720 }
1721 1721
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 1774
1775 #if defined(OS_MACOSX) 1775 #if defined(OS_MACOSX)
1776 void RenderViewImpl::OnCopyToFindPboard() { 1776 void RenderViewImpl::OnCopyToFindPboard() {
1777 if (!webview()) 1777 if (!webview())
1778 return; 1778 return;
1779 1779
1780 // Since the find pasteboard supports only plain text, this can be simpler 1780 // Since the find pasteboard supports only plain text, this can be simpler
1781 // than the |OnCopy()| case. 1781 // than the |OnCopy()| case.
1782 WebFrame* frame = webview()->focusedFrame(); 1782 WebFrame* frame = webview()->focusedFrame();
1783 if (frame->hasSelection()) { 1783 if (frame->hasSelection()) {
1784 string16 selection = frame->selectionAsText(); 1784 base::string16 selection = frame->selectionAsText();
1785 RenderThread::Get()->Send( 1785 RenderThread::Get()->Send(
1786 new ClipboardHostMsg_FindPboardWriteStringAsync(selection)); 1786 new ClipboardHostMsg_FindPboardWriteStringAsync(selection));
1787 } 1787 }
1788 } 1788 }
1789 #endif 1789 #endif
1790 1790
1791 void RenderViewImpl::OnSetName(const std::string& name) { 1791 void RenderViewImpl::OnSetName(const std::string& name) {
1792 if (!webview()) 1792 if (!webview())
1793 return; 1793 return;
1794 1794
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 params.referrer = Referrer(params.redirects[0], 1984 params.referrer = Referrer(params.redirects[0],
1985 GetReferrerPolicyFromRequest(frame, ds->request())); 1985 GetReferrerPolicyFromRequest(frame, ds->request()));
1986 params.transition = static_cast<PageTransition>( 1986 params.transition = static_cast<PageTransition>(
1987 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT); 1987 params.transition | PAGE_TRANSITION_CLIENT_REDIRECT);
1988 } else { 1988 } else {
1989 // Bug 654101: the referrer will be empty on https->http transitions. It 1989 // Bug 654101: the referrer will be empty on https->http transitions. It
1990 // would be nice if we could get the real referrer from somewhere. 1990 // would be nice if we could get the real referrer from somewhere.
1991 params.referrer = GetReferrerFromRequest(frame, original_request); 1991 params.referrer = GetReferrerFromRequest(frame, original_request);
1992 } 1992 }
1993 1993
1994 string16 method = request.httpMethod(); 1994 base::string16 method = request.httpMethod();
1995 if (EqualsASCII(method, "POST")) { 1995 if (EqualsASCII(method, "POST")) {
1996 params.is_post = true; 1996 params.is_post = true;
1997 params.post_id = ExtractPostId(item); 1997 params.post_id = ExtractPostId(item);
1998 } 1998 }
1999 1999
2000 // Send the user agent override back. 2000 // Send the user agent override back.
2001 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); 2001 params.is_overriding_user_agent = internal_data->is_overriding_user_agent();
2002 2002
2003 // Track the URL of the original request. We use the first entry of the 2003 // Track the URL of the original request. We use the first entry of the
2004 // redirect chain if it exists because the chain may have started in another 2004 // redirect chain if it exists because the chain may have started in another
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 last_page_id_sent_to_browser_ = 2041 last_page_id_sent_to_browser_ =
2042 std::max(last_page_id_sent_to_browser_, page_id_); 2042 std::max(last_page_id_sent_to_browser_, page_id_);
2043 2043
2044 // If we end up reusing this WebRequest (for example, due to a #ref click), 2044 // If we end up reusing this WebRequest (for example, due to a #ref click),
2045 // we don't want the transition type to persist. Just clear it. 2045 // we don't want the transition type to persist. Just clear it.
2046 navigation_state->set_transition_type(PAGE_TRANSITION_LINK); 2046 navigation_state->set_transition_type(PAGE_TRANSITION_LINK);
2047 } 2047 }
2048 2048
2049 // Tell the embedding application that the title of the active page has changed 2049 // Tell the embedding application that the title of the active page has changed
2050 void RenderViewImpl::UpdateTitle(WebFrame* frame, 2050 void RenderViewImpl::UpdateTitle(WebFrame* frame,
2051 const string16& title, 2051 const base::string16& title,
2052 WebTextDirection title_direction) { 2052 WebTextDirection title_direction) {
2053 // Ignore all but top level navigations. 2053 // Ignore all but top level navigations.
2054 if (frame->parent()) 2054 if (frame->parent())
2055 return; 2055 return;
2056 2056
2057 base::debug::TraceLog::GetInstance()->UpdateProcessLabel( 2057 base::debug::TraceLog::GetInstance()->UpdateProcessLabel(
2058 routing_id_, UTF16ToUTF8(title)); 2058 routing_id_, UTF16ToUTF8(title));
2059 2059
2060 string16 shortened_title = title.substr(0, kMaxTitleChars); 2060 base::string16 shortened_title = title.substr(0, kMaxTitleChars);
2061 Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title, 2061 Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title,
2062 title_direction)); 2062 title_direction));
2063 } 2063 }
2064 2064
2065 void RenderViewImpl::UpdateEncoding(WebFrame* frame, 2065 void RenderViewImpl::UpdateEncoding(WebFrame* frame,
2066 const std::string& encoding_name) { 2066 const std::string& encoding_name) {
2067 // Only update main frame's encoding_name. 2067 // Only update main frame's encoding_name.
2068 if (webview()->mainFrame() == frame && 2068 if (webview()->mainFrame() == frame &&
2069 last_encoding_name_ != encoding_name) { 2069 last_encoding_name_ != encoding_name) {
2070 // Save the encoding name for later comparing. 2070 // Save the encoding name for later comparing.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 error_html = &alt_html; 2162 error_html = &alt_html;
2163 } 2163 }
2164 2164
2165 frame->loadHTMLString(*error_html, 2165 frame->loadHTMLString(*error_html,
2166 GURL(kUnreachableWebDataURL), 2166 GURL(kUnreachableWebDataURL),
2167 error.unreachableURL, 2167 error.unreachableURL,
2168 replace); 2168 replace);
2169 } 2169 }
2170 2170
2171 bool RenderViewImpl::RunJavaScriptMessage(JavaScriptMessageType type, 2171 bool RenderViewImpl::RunJavaScriptMessage(JavaScriptMessageType type,
2172 const string16& message, 2172 const base::string16& message,
2173 const string16& default_value, 2173 const base::string16& default_value,
2174 const GURL& frame_url, 2174 const GURL& frame_url,
2175 string16* result) { 2175 base::string16* result) {
2176 // Don't allow further dialogs if we are waiting to swap out, since the 2176 // Don't allow further dialogs if we are waiting to swap out, since the
2177 // PageGroupLoadDeferrer in our stack prevents it. 2177 // PageGroupLoadDeferrer in our stack prevents it.
2178 if (suppress_dialogs_until_swap_out_) 2178 if (suppress_dialogs_until_swap_out_)
2179 return false; 2179 return false;
2180 2180
2181 bool success = false; 2181 bool success = false;
2182 string16 result_temp; 2182 base::string16 result_temp;
2183 if (!result) 2183 if (!result)
2184 result = &result_temp; 2184 result = &result_temp;
2185 2185
2186 SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage( 2186 SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage(
2187 routing_id_, message, default_value, frame_url, type, &success, result)); 2187 routing_id_, message, default_value, frame_url, type, &success, result));
2188 return success; 2188 return success;
2189 } 2189 }
2190 2190
2191 bool RenderViewImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) { 2191 bool RenderViewImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) {
2192 // Before WebKit asks us to show an alert (etc.), it takes care of doing the 2192 // Before WebKit asks us to show an alert (etc.), it takes care of doing the
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2303 // and rely on the browser sending a WasHidden / WasShown message if it 2303 // and rely on the browser sending a WasHidden / WasShown message if it
2304 // disagrees. 2304 // disagrees.
2305 RenderViewImpl* view = RenderViewImpl::Create( 2305 RenderViewImpl* view = RenderViewImpl::Create(
2306 routing_id_, 2306 routing_id_,
2307 renderer_preferences_, 2307 renderer_preferences_,
2308 transferred_preferences, 2308 transferred_preferences,
2309 routing_id, 2309 routing_id,
2310 main_frame_routing_id, 2310 main_frame_routing_id,
2311 surface_id, 2311 surface_id,
2312 cloned_session_storage_namespace_id, 2312 cloned_session_storage_namespace_id,
2313 string16(), // WebCore will take care of setting the correct name. 2313 base::string16(), // WebCore will take care of setting the correct name.
2314 true, // is_renderer_created 2314 true, // is_renderer_created
2315 false, // swapped_out 2315 false, // swapped_out
2316 params.disposition == NEW_BACKGROUND_TAB, // hidden 2316 params.disposition == NEW_BACKGROUND_TAB, // hidden
2317 1, // next_page_id 2317 1, // next_page_id
2318 screen_info_, 2318 screen_info_,
2319 accessibility_mode_, 2319 accessibility_mode_,
2320 allow_partial_swap_); 2320 allow_partial_swap_);
2321 view->opened_by_user_gesture_ = params.user_gesture; 2321 view->opened_by_user_gesture_ = params.user_gesture;
2322 2322
2323 // Record whether the creator frame is trying to suppress the opener field. 2323 // Record whether the creator frame is trying to suppress the opener field.
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 ipc_params.capture = params.useMediaCapture; 2575 ipc_params.capture = params.useMediaCapture;
2576 #endif 2576 #endif
2577 2577
2578 return ScheduleFileChooser(ipc_params, chooser_completion); 2578 return ScheduleFileChooser(ipc_params, chooser_completion);
2579 } 2579 }
2580 2580
2581 void RenderViewImpl::runModalAlertDialog(WebFrame* frame, 2581 void RenderViewImpl::runModalAlertDialog(WebFrame* frame,
2582 const WebString& message) { 2582 const WebString& message) {
2583 RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_ALERT, 2583 RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_ALERT,
2584 message, 2584 message,
2585 string16(), 2585 base::string16(),
2586 frame->document().url(), 2586 frame->document().url(),
2587 NULL); 2587 NULL);
2588 } 2588 }
2589 2589
2590 bool RenderViewImpl::runModalConfirmDialog(WebFrame* frame, 2590 bool RenderViewImpl::runModalConfirmDialog(WebFrame* frame,
2591 const WebString& message) { 2591 const WebString& message) {
2592 return RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_CONFIRM, 2592 return RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_CONFIRM,
2593 message, 2593 message,
2594 string16(), 2594 base::string16(),
2595 frame->document().url(), 2595 frame->document().url(),
2596 NULL); 2596 NULL);
2597 } 2597 }
2598 2598
2599 bool RenderViewImpl::runModalPromptDialog(WebFrame* frame, 2599 bool RenderViewImpl::runModalPromptDialog(WebFrame* frame,
2600 const WebString& message, 2600 const WebString& message,
2601 const WebString& default_value, 2601 const WebString& default_value,
2602 WebString* actual_value) { 2602 WebString* actual_value) {
2603 string16 result; 2603 base::string16 result;
2604 bool ok = RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_PROMPT, 2604 bool ok = RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_PROMPT,
2605 message, 2605 message,
2606 default_value, 2606 default_value,
2607 frame->document().url(), 2607 frame->document().url(),
2608 &result); 2608 &result);
2609 if (ok) 2609 if (ok)
2610 actual_value->assign(result); 2610 actual_value->assign(result);
2611 return ok; 2611 return ok;
2612 } 2612 }
2613 2613
(...skipping 15 matching lines...) Expand all
2629 return true; 2629 return true;
2630 2630
2631 // Don't allow further dialogs if we are waiting to swap out, since the 2631 // Don't allow further dialogs if we are waiting to swap out, since the
2632 // PageGroupLoadDeferrer in our stack prevents it. 2632 // PageGroupLoadDeferrer in our stack prevents it.
2633 if (suppress_dialogs_until_swap_out_) 2633 if (suppress_dialogs_until_swap_out_)
2634 return false; 2634 return false;
2635 2635
2636 bool success = false; 2636 bool success = false;
2637 // This is an ignored return value, but is included so we can accept the same 2637 // This is an ignored return value, but is included so we can accept the same
2638 // response as RunJavaScriptMessage. 2638 // response as RunJavaScriptMessage.
2639 string16 ignored_result; 2639 base::string16 ignored_result;
2640 SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( 2640 SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm(
2641 routing_id_, frame->document().url(), message, is_reload, 2641 routing_id_, frame->document().url(), message, is_reload,
2642 &success, &ignored_result)); 2642 &success, &ignored_result));
2643 return success; 2643 return success;
2644 } 2644 }
2645 2645
2646 void RenderViewImpl::showContextMenu( 2646 void RenderViewImpl::showContextMenu(
2647 WebFrame* frame, const WebContextMenuData& data) { 2647 WebFrame* frame, const WebContextMenuData& data) {
2648 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); 2648 ContextMenuParams params = ContextMenuParamsBuilder::Build(data);
2649 params.source_type = context_menu_source_type_; 2649 params.source_type = context_menu_source_type_;
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
3799 } 3799 }
3800 3800
3801 void RenderViewImpl::didFailLoad(WebFrame* frame, const WebURLError& error) { 3801 void RenderViewImpl::didFailLoad(WebFrame* frame, const WebURLError& error) {
3802 WebDataSource* ds = frame->dataSource(); 3802 WebDataSource* ds = frame->dataSource();
3803 DCHECK(ds); 3803 DCHECK(ds);
3804 3804
3805 3805
3806 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); 3806 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error));
3807 3807
3808 const WebURLRequest& failed_request = ds->request(); 3808 const WebURLRequest& failed_request = ds->request();
3809 string16 error_description; 3809 base::string16 error_description;
3810 GetContentClient()->renderer()->GetNavigationErrorStrings( 3810 GetContentClient()->renderer()->GetNavigationErrorStrings(
3811 frame, 3811 frame,
3812 failed_request, 3812 failed_request,
3813 error, 3813 error,
3814 renderer_preferences_.accept_languages, 3814 renderer_preferences_.accept_languages,
3815 NULL, 3815 NULL,
3816 &error_description); 3816 &error_description);
3817 Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, 3817 Send(new ViewHostMsg_DidFailLoadWithError(routing_id_,
3818 frame->identifier(), 3818 frame->identifier(),
3819 failed_request.url(), 3819 failed_request.url(),
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
4101 Send(new ViewHostMsg_Find_Reply(routing_id_, 4101 Send(new ViewHostMsg_Find_Reply(routing_id_,
4102 request_id, 4102 request_id,
4103 match_count, 4103 match_count,
4104 selection_rect, 4104 selection_rect,
4105 ordinal, 4105 ordinal,
4106 final_status_update)); 4106 final_status_update));
4107 } 4107 }
4108 4108
4109 // static 4109 // static
4110 bool RenderViewImpl::ShouldUpdateSelectionTextFromContextMenuParams( 4110 bool RenderViewImpl::ShouldUpdateSelectionTextFromContextMenuParams(
4111 const string16& selection_text, 4111 const base::string16& selection_text,
4112 size_t selection_text_offset, 4112 size_t selection_text_offset,
4113 const gfx::Range& selection_range, 4113 const gfx::Range& selection_range,
4114 const ContextMenuParams& params) { 4114 const ContextMenuParams& params) {
4115 string16 trimmed_selection_text; 4115 base::string16 trimmed_selection_text;
4116 if (!selection_text.empty() && !selection_range.is_empty()) { 4116 if (!selection_text.empty() && !selection_range.is_empty()) {
4117 const int start = selection_range.GetMin() - selection_text_offset; 4117 const int start = selection_range.GetMin() - selection_text_offset;
4118 const size_t length = selection_range.length(); 4118 const size_t length = selection_range.length();
4119 if (start >= 0 && start + length <= selection_text.length()) { 4119 if (start >= 0 && start + length <= selection_text.length()) {
4120 TrimWhitespace(selection_text.substr(start, length), TRIM_ALL, 4120 TrimWhitespace(selection_text.substr(start, length), TRIM_ALL,
4121 &trimmed_selection_text); 4121 &trimmed_selection_text);
4122 } 4122 }
4123 } 4123 }
4124 string16 trimmed_params_text; 4124 base::string16 trimmed_params_text;
4125 TrimWhitespace(params.selection_text, TRIM_ALL, &trimmed_params_text); 4125 TrimWhitespace(params.selection_text, TRIM_ALL, &trimmed_params_text);
4126 return trimmed_params_text != trimmed_selection_text; 4126 return trimmed_params_text != trimmed_selection_text;
4127 } 4127 }
4128 4128
4129 void RenderViewImpl::reportFindInPageMatchCount(int request_id, 4129 void RenderViewImpl::reportFindInPageMatchCount(int request_id,
4130 int count, 4130 int count,
4131 bool final_update) { 4131 bool final_update) {
4132 NOTREACHED(); 4132 NOTREACHED();
4133 } 4133 }
4134 4134
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
4322 if (pepper_module.get()) 4322 if (pepper_module.get())
4323 return new PepperWebPluginImpl(pepper_module.get(), params, AsWeakPtr()); 4323 return new PepperWebPluginImpl(pepper_module.get(), params, AsWeakPtr());
4324 } 4324 }
4325 4325
4326 return new WebPluginImpl(frame, params, info.path, AsWeakPtr()); 4326 return new WebPluginImpl(frame, params, info.path, AsWeakPtr());
4327 #else 4327 #else
4328 return NULL; 4328 return NULL;
4329 #endif 4329 #endif
4330 } 4330 }
4331 4331
4332 void RenderViewImpl::EvaluateScript(const string16& frame_xpath, 4332 void RenderViewImpl::EvaluateScript(const base::string16& frame_xpath,
4333 const string16& jscript, 4333 const base::string16& jscript,
4334 int id, 4334 int id,
4335 bool notify_result) { 4335 bool notify_result) {
4336 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); 4336 v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
4337 v8::Handle<v8::Value> result; 4337 v8::Handle<v8::Value> result;
4338 WebFrame* web_frame = GetChildFrame(frame_xpath); 4338 WebFrame* web_frame = GetChildFrame(frame_xpath);
4339 if (web_frame) 4339 if (web_frame)
4340 result = web_frame->executeScriptAndReturnValue(WebScriptSource(jscript)); 4340 result = web_frame->executeScriptAndReturnValue(WebScriptSource(jscript));
4341 if (notify_result) { 4341 if (notify_result) {
4342 base::ListValue list; 4342 base::ListValue list;
4343 if (!result.IsEmpty() && web_frame) { 4343 if (!result.IsEmpty() && web_frame) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
4437 4437
4438 const WebHistoryItem& item = webview()->mainFrame()->currentHistoryItem(); 4438 const WebHistoryItem& item = webview()->mainFrame()->currentHistoryItem();
4439 SendUpdateState(item); 4439 SendUpdateState(item);
4440 } 4440 }
4441 4441
4442 void RenderViewImpl::SyncSelectionIfRequired() { 4442 void RenderViewImpl::SyncSelectionIfRequired() {
4443 WebFrame* frame = webview()->focusedFrame(); 4443 WebFrame* frame = webview()->focusedFrame();
4444 if (!frame) 4444 if (!frame)
4445 return; 4445 return;
4446 4446
4447 string16 text; 4447 base::string16 text;
4448 size_t offset; 4448 size_t offset;
4449 gfx::Range range; 4449 gfx::Range range;
4450 #if defined(ENABLE_PLUGINS) 4450 #if defined(ENABLE_PLUGINS)
4451 if (main_render_frame_->focused_pepper_plugin()) { 4451 if (main_render_frame_->focused_pepper_plugin()) {
4452 main_render_frame_->focused_pepper_plugin()->GetSurroundingText( 4452 main_render_frame_->focused_pepper_plugin()->GetSurroundingText(
4453 &text, &range); 4453 &text, &range);
4454 offset = 0; // Pepper API does not support offset reporting. 4454 offset = 0; // Pepper API does not support offset reporting.
4455 // TODO(kinaba): cut as needed. 4455 // TODO(kinaba): cut as needed.
4456 } else 4456 } else
4457 #endif 4457 #endif
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
4565 4565
4566 const WebURLRequest& request = ds->request(); 4566 const WebURLRequest& request = ds->request();
4567 return request.url(); 4567 return request.url();
4568 } 4568 }
4569 4569
4570 blink::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { 4570 blink::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() {
4571 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); 4571 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin();
4572 } 4572 }
4573 4573
4574 void RenderViewImpl::OnFind(int request_id, 4574 void RenderViewImpl::OnFind(int request_id,
4575 const string16& search_text, 4575 const base::string16& search_text,
4576 const WebFindOptions& options) { 4576 const WebFindOptions& options) {
4577 WebFrame* main_frame = webview()->mainFrame(); 4577 WebFrame* main_frame = webview()->mainFrame();
4578 4578
4579 // Check if the plugin still exists in the document. 4579 // Check if the plugin still exists in the document.
4580 if (main_frame->document().isPluginDocument() && 4580 if (main_frame->document().isPluginDocument() &&
4581 GetWebPluginFromPluginDocument()) { 4581 GetWebPluginFromPluginDocument()) {
4582 if (options.findNext) { 4582 if (options.findNext) {
4583 // Just navigate back/forward. 4583 // Just navigate back/forward.
4584 GetWebPluginFromPluginDocument()->selectFindResult(options.forward); 4584 GetWebPluginFromPluginDocument()->selectFindResult(options.forward);
4585 } else { 4585 } else {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
4851 4851
4852 void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) { 4852 void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) {
4853 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); 4853 webview()->setPageEncoding(WebString::fromUTF8(encoding_name));
4854 } 4854 }
4855 4855
4856 void RenderViewImpl::OnResetPageEncodingToDefault() { 4856 void RenderViewImpl::OnResetPageEncodingToDefault() {
4857 WebString no_encoding; 4857 WebString no_encoding;
4858 webview()->setPageEncoding(no_encoding); 4858 webview()->setPageEncoding(no_encoding);
4859 } 4859 }
4860 4860
4861 WebFrame* RenderViewImpl::GetChildFrame(const string16& xpath) const { 4861 WebFrame* RenderViewImpl::GetChildFrame(const base::string16& xpath) const {
4862 if (xpath.empty()) 4862 if (xpath.empty())
4863 return webview()->mainFrame(); 4863 return webview()->mainFrame();
4864 4864
4865 // xpath string can represent a frame deep down the tree (across multiple 4865 // xpath string can represent a frame deep down the tree (across multiple
4866 // frame DOMs). 4866 // frame DOMs).
4867 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0] 4867 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0]
4868 // should break into 2 xpaths 4868 // should break into 2 xpaths
4869 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0] 4869 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0]
4870 std::vector<string16> xpaths; 4870 std::vector<base::string16> xpaths;
4871 base::SplitString(xpath, '\n', &xpaths); 4871 base::SplitString(xpath, '\n', &xpaths);
4872 4872
4873 WebFrame* frame = webview()->mainFrame(); 4873 WebFrame* frame = webview()->mainFrame();
4874 for (std::vector<string16>::const_iterator i = xpaths.begin(); 4874 for (std::vector<base::string16>::const_iterator i = xpaths.begin();
4875 frame && i != xpaths.end(); ++i) { 4875 frame && i != xpaths.end(); ++i) {
4876 frame = frame->findChildByExpression(*i); 4876 frame = frame->findChildByExpression(*i);
4877 } 4877 }
4878 4878
4879 return frame; 4879 return frame;
4880 } 4880 }
4881 4881
4882 void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, 4882 void RenderViewImpl::OnScriptEvalRequest(const base::string16& frame_xpath,
4883 const string16& jscript, 4883 const base::string16& jscript,
4884 int id, 4884 int id,
4885 bool notify_result) { 4885 bool notify_result) {
4886 TRACE_EVENT_INSTANT0("test_tracing", "OnScriptEvalRequest", 4886 TRACE_EVENT_INSTANT0("test_tracing", "OnScriptEvalRequest",
4887 TRACE_EVENT_SCOPE_THREAD); 4887 TRACE_EVENT_SCOPE_THREAD);
4888 EvaluateScript(frame_xpath, jscript, id, notify_result); 4888 EvaluateScript(frame_xpath, jscript, id, notify_result);
4889 } 4889 }
4890 4890
4891 void RenderViewImpl::OnPostMessageEvent( 4891 void RenderViewImpl::OnPostMessageEvent(
4892 const ViewMsg_PostMessage_Params& params) { 4892 const ViewMsg_PostMessage_Params& params) {
4893 // TODO(nasko): Support sending to subframes. 4893 // TODO(nasko): Support sending to subframes.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4926 // We must pass in the target_origin to do the security check on this side, 4926 // We must pass in the target_origin to do the security check on this side,
4927 // since it may have changed since the original postMessage call was made. 4927 // since it may have changed since the original postMessage call was made.
4928 WebSecurityOrigin target_origin; 4928 WebSecurityOrigin target_origin;
4929 if (!params.target_origin.empty()) { 4929 if (!params.target_origin.empty()) {
4930 target_origin = 4930 target_origin =
4931 WebSecurityOrigin::createFromString(WebString(params.target_origin)); 4931 WebSecurityOrigin::createFromString(WebString(params.target_origin));
4932 } 4932 }
4933 frame->dispatchMessageEventWithOriginCheck(target_origin, msg_event); 4933 frame->dispatchMessageEventWithOriginCheck(target_origin, msg_event);
4934 } 4934 }
4935 4935
4936 void RenderViewImpl::OnCSSInsertRequest(const string16& frame_xpath, 4936 void RenderViewImpl::OnCSSInsertRequest(const base::string16& frame_xpath,
4937 const std::string& css) { 4937 const std::string& css) {
4938 WebFrame* frame = GetChildFrame(frame_xpath); 4938 WebFrame* frame = GetChildFrame(frame_xpath);
4939 if (!frame) 4939 if (!frame)
4940 return; 4940 return;
4941 4941
4942 frame->document().insertUserStyleSheet( 4942 frame->document().insertUserStyleSheet(
4943 WebString::fromUTF8(css), 4943 WebString::fromUTF8(css),
4944 WebDocument::UserStyleAuthorLevel); 4944 WebDocument::UserStyleAuthorLevel);
4945 } 4945 }
4946 4946
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
5545 #if defined(ENABLE_PLUGINS) 5545 #if defined(ENABLE_PLUGINS)
5546 // Inform plugins that their window's frame has changed. 5546 // Inform plugins that their window's frame has changed.
5547 std::set<WebPluginDelegateProxy*>::iterator plugin_it; 5547 std::set<WebPluginDelegateProxy*>::iterator plugin_it;
5548 for (plugin_it = plugin_delegates_.begin(); 5548 for (plugin_it = plugin_delegates_.begin();
5549 plugin_it != plugin_delegates_.end(); ++plugin_it) { 5549 plugin_it != plugin_delegates_.end(); ++plugin_it) {
5550 (*plugin_it)->WindowFrameChanged(window_frame, view_frame); 5550 (*plugin_it)->WindowFrameChanged(window_frame, view_frame);
5551 } 5551 }
5552 #endif 5552 #endif
5553 } 5553 }
5554 5554
5555 void RenderViewImpl::OnPluginImeCompositionCompleted(const string16& text, 5555 void RenderViewImpl::OnPluginImeCompositionCompleted(const base::string16& text,
5556 int plugin_id) { 5556 int plugin_id) {
5557 // WebPluginDelegateProxy is responsible for figuring out if this event 5557 // WebPluginDelegateProxy is responsible for figuring out if this event
5558 // applies to it or not, so inform all the delegates. 5558 // applies to it or not, so inform all the delegates.
5559 std::set<WebPluginDelegateProxy*>::iterator plugin_it; 5559 std::set<WebPluginDelegateProxy*>::iterator plugin_it;
5560 for (plugin_it = plugin_delegates_.begin(); 5560 for (plugin_it = plugin_delegates_.begin();
5561 plugin_it != plugin_delegates_.end(); ++plugin_it) { 5561 plugin_it != plugin_delegates_.end(); ++plugin_it) {
5562 (*plugin_it)->ImeCompositionCompleted(text, plugin_id); 5562 (*plugin_it)->ImeCompositionCompleted(text, plugin_id);
5563 } 5563 }
5564 } 5564 }
5565 #endif // OS_MACOSX 5565 #endif // OS_MACOSX
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
5702 } 5702 }
5703 } 5703 }
5704 main_render_frame_->OnSetFocus(enable); 5704 main_render_frame_->OnSetFocus(enable);
5705 #endif 5705 #endif
5706 // Notify all BrowserPlugins of the RenderView's focus state. 5706 // Notify all BrowserPlugins of the RenderView's focus state.
5707 if (browser_plugin_manager_.get()) 5707 if (browser_plugin_manager_.get())
5708 browser_plugin_manager_->UpdateFocusState(); 5708 browser_plugin_manager_->UpdateFocusState();
5709 } 5709 }
5710 5710
5711 void RenderViewImpl::OnImeSetComposition( 5711 void RenderViewImpl::OnImeSetComposition(
5712 const string16& text, 5712 const base::string16& text,
5713 const std::vector<blink::WebCompositionUnderline>& underlines, 5713 const std::vector<blink::WebCompositionUnderline>& underlines,
5714 int selection_start, 5714 int selection_start,
5715 int selection_end) { 5715 int selection_end) {
5716 #if defined(ENABLE_PLUGINS) 5716 #if defined(ENABLE_PLUGINS)
5717 if (main_render_frame_->focused_pepper_plugin()) { 5717 if (main_render_frame_->focused_pepper_plugin()) {
5718 main_render_frame_->OnImeSetComposition( 5718 main_render_frame_->OnImeSetComposition(
5719 text, underlines, selection_start, selection_end); 5719 text, underlines, selection_start, selection_end);
5720 return; 5720 return;
5721 } 5721 }
5722 5722
(...skipping 23 matching lines...) Expand all
5746 } 5746 }
5747 #endif // OS_WIN 5747 #endif // OS_WIN
5748 #endif // ENABLE_PLUGINS 5748 #endif // ENABLE_PLUGINS
5749 RenderWidget::OnImeSetComposition(text, 5749 RenderWidget::OnImeSetComposition(text,
5750 underlines, 5750 underlines,
5751 selection_start, 5751 selection_start,
5752 selection_end); 5752 selection_end);
5753 } 5753 }
5754 5754
5755 void RenderViewImpl::OnImeConfirmComposition( 5755 void RenderViewImpl::OnImeConfirmComposition(
5756 const string16& text, 5756 const base::string16& text,
5757 const gfx::Range& replacement_range, 5757 const gfx::Range& replacement_range,
5758 bool keep_selection) { 5758 bool keep_selection) {
5759 #if defined(ENABLE_PLUGINS) 5759 #if defined(ENABLE_PLUGINS)
5760 if (main_render_frame_->focused_pepper_plugin()) { 5760 if (main_render_frame_->focused_pepper_plugin()) {
5761 main_render_frame_->OnImeConfirmComposition( 5761 main_render_frame_->OnImeConfirmComposition(
5762 text, replacement_range, keep_selection); 5762 text, replacement_range, keep_selection);
5763 return; 5763 return;
5764 } 5764 }
5765 #if defined(OS_WIN) 5765 #if defined(OS_WIN)
5766 // Same as OnImeSetComposition(), we send the text from IMEs directly to 5766 // Same as OnImeSetComposition(), we send the text from IMEs directly to
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
6452 for (size_t i = 0; i < icon_urls.size(); i++) { 6452 for (size_t i = 0; i < icon_urls.size(); i++) {
6453 WebURL url = icon_urls[i].iconURL(); 6453 WebURL url = icon_urls[i].iconURL();
6454 if (!url.isEmpty()) 6454 if (!url.isEmpty())
6455 urls.push_back(FaviconURL(url, 6455 urls.push_back(FaviconURL(url,
6456 ToFaviconType(icon_urls[i].iconType()))); 6456 ToFaviconType(icon_urls[i].iconType())));
6457 } 6457 }
6458 SendUpdateFaviconURL(urls); 6458 SendUpdateFaviconURL(urls);
6459 } 6459 }
6460 6460
6461 } // namespace content 6461 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_view_impl_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698