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

Unified Diff: content/renderer/render_view.cc

Issue 7550051: content: change the CSSInsertRequest message to string16 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view.cc
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index 368cc335081dad50c4f5741cabbfc0935738ff69..56d16d9107d11ce0856b22a1cd6b8c5ff28b7c62 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -18,6 +18,7 @@
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/string_piece.h"
+#include "base/string_split.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "base/time.h"
@@ -3321,7 +3322,7 @@ void RenderView::OnResetPageEncodingToDefault() {
webview()->setPageEncoding(no_encoding);
}
-WebFrame* RenderView::GetChildFrame(const std::wstring& xpath) const {
+WebFrame* RenderView::GetChildFrame(const string16& xpath) const {
if (xpath.empty())
return webview()->mainFrame();
@@ -3330,20 +3331,13 @@ WebFrame* RenderView::GetChildFrame(const std::wstring& xpath) const {
// Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0]
// should break into 2 xpaths
// /html/body/table/tbody/tr/td/iframe & /frameset/frame[0]
+ std::vector<string16> xpaths;
+ SplitString(xpath, '\n', &xpaths);
WebFrame* frame = webview()->mainFrame();
-
- std::wstring xpath_remaining = xpath;
- while (!xpath_remaining.empty()) {
- std::wstring::size_type delim_pos = xpath_remaining.find_first_of(L'\n');
- std::wstring xpath_child;
- if (delim_pos != std::wstring::npos) {
- xpath_child = xpath_remaining.substr(0, delim_pos);
- xpath_remaining.erase(0, delim_pos + 1);
- } else {
- xpath_remaining.swap(xpath_child);
- }
- frame = frame->findChildByExpression(WideToUTF16Hack(xpath_child));
+ for (std::vector<string16>::const_iterator i = xpaths.begin();
+ frame && i != xpaths.end(); ++i) {
+ frame = frame->findChildByExpression(*i);
}
return frame;
@@ -3380,7 +3374,7 @@ void RenderView::EvaluateScript(const string16& frame_xpath,
int id,
bool notify_result) {
v8::Handle<v8::Value> result;
- WebFrame* web_frame = GetChildFrame(UTF16ToWideHack(frame_xpath));
+ WebFrame* web_frame = GetChildFrame(frame_xpath);
if (web_frame)
result = web_frame->executeScriptAndReturnValue(WebScriptSource(script));
if (notify_result) {
@@ -3407,7 +3401,7 @@ void RenderView::OnScriptEvalRequest(const string16& frame_xpath,
EvaluateScript(frame_xpath, jscript, id, notify_result);
}
-void RenderView::OnCSSInsertRequest(const std::wstring& frame_xpath,
+void RenderView::OnCSSInsertRequest(const string16& frame_xpath,
const std::string& css) {
WebFrame* frame = GetChildFrame(frame_xpath);
if (!frame)
« 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