diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-08 17:12:41 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-08 17:12:41 +0000 |
commit | 318bf580e9dd0669904abc42cb2958376e4a43f5 (patch) | |
tree | 4f3753d458b663c1926453625f54516460262e46 /content | |
parent | c3c99970a48e0eca1146550c83851950279f8ed8 (diff) | |
download | chromium_src-318bf580e9dd0669904abc42cb2958376e4a43f5.zip chromium_src-318bf580e9dd0669904abc42cb2958376e4a43f5.tar.gz chromium_src-318bf580e9dd0669904abc42cb2958376e4a43f5.tar.bz2 |
content: change the CSSInsertRequest message to string16
While I'm at it, simplify some code.
Review URL: http://codereview.chromium.org/7550051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95832 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/common/view_messages.h | 2 | ||||
-rw-r--r-- | content/renderer/render_view.cc | 24 | ||||
-rw-r--r-- | content/renderer/render_view.h | 4 |
3 files changed, 12 insertions, 18 deletions
diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 4022238..885cc03 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -968,7 +968,7 @@ IPC_MESSAGE_ROUTED4(ViewMsg_ScriptEvalRequest, // into that frame's document. See ViewMsg_ScriptEvalRequest for details on // allowed xpath expressions. IPC_MESSAGE_ROUTED2(ViewMsg_CSSInsertRequest, - std::wstring, /* frame_xpath */ + string16, /* frame_xpath */ std::string /* css string */) // External popup menus. diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index a0bea3c..c9cb26c 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" @@ -3323,7 +3324,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(); @@ -3332,20 +3333,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; + base::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; @@ -3382,7 +3376,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) { @@ -3409,7 +3403,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) diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h index 0db5615..bb6cbaa 100644 --- a/content/renderer/render_view.h +++ b/content/renderer/render_view.h @@ -763,7 +763,7 @@ class RenderView : public RenderWidget, void OnCopyToFindPboard(); #endif void OnCut(); - void OnCSSInsertRequest(const std::wstring& frame_xpath, + void OnCSSInsertRequest(const string16& frame_xpath, const std::string& css); void OnCustomContextMenuAction( const webkit_glue::CustomContextMenuContext& custom_context, @@ -885,7 +885,7 @@ class RenderView : public RenderWidget, ErrorPageType error_type); // Locates a sub frame with given xpath - WebKit::WebFrame* GetChildFrame(const std::wstring& frame_xpath) const; + WebKit::WebFrame* GetChildFrame(const string16& frame_xpath) const; WebUIBindings* GetWebUIBindings(); |