diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 22:57:43 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 22:57:43 +0000 |
commit | 548bc0f318c74e9a69973cb43c5403d03d114b52 (patch) | |
tree | ab09daafc56330f21985c85eabe8adfc671ab7a6 | |
parent | 5963b7759a369d178866bdc5868bb601dc5ee262 (diff) | |
download | chromium_src-548bc0f318c74e9a69973cb43c5403d03d114b52.zip chromium_src-548bc0f318c74e9a69973cb43c5403d03d114b52.tar.gz chromium_src-548bc0f318c74e9a69973cb43c5403d03d114b52.tar.bz2 |
Remove wstring from RVH's run Javascript command.
BUG=23581
TEST=no visible changes; all tests pass
Review URL: http://codereview.chromium.org/6458013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74362 0039d316-1c4b-4281-b951-d872f2087c98
29 files changed, 145 insertions, 120 deletions
diff --git a/chrome/browser/accessibility/browser_accessibility_win_unittest.cc b/chrome/browser/accessibility/browser_accessibility_win_unittest.cc index ae157f0..fe5fa04 100644 --- a/chrome/browser/accessibility/browser_accessibility_win_unittest.cc +++ b/chrome/browser/accessibility/browser_accessibility_win_unittest.cc @@ -311,14 +311,14 @@ TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { SysFreeString(text); ASSERT_EQ(S_OK, text1_obj->get_text(0, 4, &text)); - ASSERT_EQ(text, std::wstring(L"One ")); + ASSERT_EQ(text, string16(L"One ")); SysFreeString(text); ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( 1, IA2_TEXT_BOUNDARY_CHAR, &start, &end, &text)); ASSERT_EQ(start, 1); ASSERT_EQ(end, 2); - ASSERT_EQ(text, std::wstring(L"n")); + ASSERT_EQ(text, string16(L"n")); SysFreeString(text); ASSERT_EQ(S_FALSE, text1_obj->get_textAtOffset( @@ -330,28 +330,28 @@ TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { 1, IA2_TEXT_BOUNDARY_WORD, &start, &end, &text)); ASSERT_EQ(start, 0); ASSERT_EQ(end, 3); - ASSERT_EQ(text, std::wstring(L"One")); + ASSERT_EQ(text, string16(L"One")); SysFreeString(text); ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( 6, IA2_TEXT_BOUNDARY_WORD, &start, &end, &text)); ASSERT_EQ(start, 4); ASSERT_EQ(end, 7); - ASSERT_EQ(text, std::wstring(L"two")); + ASSERT_EQ(text, string16(L"two")); SysFreeString(text); ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( text1_len, IA2_TEXT_BOUNDARY_WORD, &start, &end, &text)); ASSERT_EQ(start, 25); ASSERT_EQ(end, 29); - ASSERT_EQ(text, std::wstring(L"six.")); + ASSERT_EQ(text, string16(L"six.")); SysFreeString(text); ASSERT_EQ(S_OK, text1_obj->get_textAtOffset( 1, IA2_TEXT_BOUNDARY_LINE, &start, &end, &text)); ASSERT_EQ(start, 0); ASSERT_EQ(end, 13); - ASSERT_EQ(text, std::wstring(L"One two three")); + ASSERT_EQ(text, string16(L"One two three")); SysFreeString(text); // Delete the manager and test that all BrowserAccessibility instances are diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 7855a21..164d084 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -16,6 +16,7 @@ #include "base/string_util.h" #include "base/stringprintf.h" #include "base/threading/thread_restrictions.h" +#include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/automation/automation_provider.h" @@ -1634,8 +1635,10 @@ void PageSnapshotTaker::ExecuteScript(const std::wstring& javascript) { L"window.domAutomationController.setAutomationId(%d);", reply_message_->routing_id()); - render_view_->ExecuteJavascriptInWebFrame(L"", set_automation_id); - render_view_->ExecuteJavascriptInWebFrame(L"", javascript); + render_view_->ExecuteJavascriptInWebFrame(string16(), + WideToUTF16Hack(set_automation_id)); + render_view_->ExecuteJavascriptInWebFrame(string16(), + WideToUTF16Hack(javascript)); } void PageSnapshotTaker::SendMessage(bool success) { diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 4d08873..529a052 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -660,7 +660,7 @@ void TestingAutomationProvider::SetAuth(int tab_handle, // server auth, but it should be OK for now. LoginHandler* handler = iter->second; new NavigationNotificationObserver(tab, this, reply_message, 1, false); - handler->SetAuth(username, password); + handler->SetAuth(WideToUTF16Hack(username), WideToUTF16Hack(password)); return; } } @@ -1139,9 +1139,9 @@ void TestingAutomationProvider::ExecuteJavascript( reply_message_ = reply_message; tab_contents->render_view_host()->ExecuteJavascriptInWebFrame( - frame_xpath, UTF8ToWide(set_automation_id)); + WideToUTF16Hack(frame_xpath), UTF8ToUTF16(set_automation_id)); tab_contents->render_view_host()->ExecuteJavascriptInWebFrame( - frame_xpath, script); + WideToUTF16Hack(frame_xpath), WideToUTF16Hack(script)); } void TestingAutomationProvider::GetConstrainedWindowCount(int handle, diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index 63a0a0b..35e933f 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -47,13 +47,13 @@ namespace { -const std::string BEFORE_UNLOAD_HTML = +const char* kBeforeUnloadHTML = "<html><head><title>beforeunload</title></head><body>" "<script>window.onbeforeunload=function(e){return 'foo'}</script>" "</body></html>"; -const std::wstring OPEN_NEW_BEFOREUNLOAD_PAGE = - L"w=window.open(); w.onbeforeunload=function(e){return 'foo'};"; +const char* kOpenNewBeforeUnloadPage = + "w=window.open(); w.onbeforeunload=function(e){return 'foo'};"; const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); @@ -211,8 +211,9 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) { EXPECT_EQ(0, browser()->selected_index()); TabContents* second_tab = browser()->GetTabContentsAt(1); ASSERT_TRUE(second_tab); - second_tab->render_view_host()->ExecuteJavascriptInWebFrame(L"", - L"alert('Activate!');"); + second_tab->render_view_host()->ExecuteJavascriptInWebFrame( + string16(), + ASCIIToUTF16("alert('Activate!');")); AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); alert->CloseModalDialog(); EXPECT_EQ(2, browser()->tab_count()); @@ -246,7 +247,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, ThirtyFourTabs) { // Test for crbug.com/22004. Reloading a page with a before unload handler and // then canceling the dialog should not leave the throbber spinning. IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) { - GURL url("data:text/html," + BEFORE_UNLOAD_HTML); + GURL url(std::string("data:text/html,") + kBeforeUnloadHTML); ui_test_utils::NavigateToURL(browser(), url); // Navigate to another page, but click cancel in the dialog. Make sure that @@ -258,7 +259,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) { // Clear the beforeunload handler so the test can easily exit. browser()->GetSelectedTabContents()->render_view_host()-> - ExecuteJavascriptInWebFrame(L"", L"onbeforeunload=null;"); + ExecuteJavascriptInWebFrame(string16(), + ASCIIToUTF16("onbeforeunload=null;")); } // Crashy on mac. http://crbug.com/38522 @@ -274,13 +276,15 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) { // two beforeunload dialogs shown. IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) { browser()->GetSelectedTabContents()->render_view_host()-> - ExecuteJavascriptInWebFrame(L"", OPEN_NEW_BEFOREUNLOAD_PAGE); + ExecuteJavascriptInWebFrame(string16(), + ASCIIToUTF16(kOpenNewBeforeUnloadPage)); // Close the new window with JavaScript, which should show a single // beforeunload dialog. Then show another alert, to make it easy to verify // that a second beforeunload dialog isn't shown. browser()->GetTabContentsAt(0)->render_view_host()-> - ExecuteJavascriptInWebFrame(L"", L"w.close(); alert('bar');"); + ExecuteJavascriptInWebFrame(string16(), + ASCIIToUTF16("w.close(); alert('bar');")); AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); alert->native_dialog()->AcceptAppModalDialog(); diff --git a/chrome/browser/browser_signin.cc b/chrome/browser/browser_signin.cc index f077d0c..96de0e5 100644 --- a/chrome/browser/browser_signin.cc +++ b/chrome/browser/browser_signin.cc @@ -169,7 +169,8 @@ void BrowserSigninHtml::HandleSigninInit(const ListValue* args) { return; RenderViewHost* rvh = dom_ui_->tab_contents()->render_view_host(); - rvh->ExecuteJavascriptInWebFrame(L"//iframe[@id='login']", L"hideBlurb();"); + rvh->ExecuteJavascriptInWebFrame(ASCIIToUTF16("//iframe[@id='login']"), + ASCIIToUTF16("hideBlurb();")); DictionaryValue json_args; std::string json; @@ -188,7 +189,8 @@ void BrowserSigninHtml::HandleSigninInit(const ListValue* args) { base::JSONWriter::Write(&json_args, false, &json); javascript += L"showGaiaLogin(" + UTF8ToWide(json) + L");"; - rvh->ExecuteJavascriptInWebFrame(L"//iframe[@id='login']", javascript); + rvh->ExecuteJavascriptInWebFrame(ASCIIToUTF16("//iframe[@id='login']"), + WideToUTF16Hack(javascript)); } void BrowserSigninHtml::HandleSubmitAuth(const ListValue* args) { diff --git a/chrome/browser/chromeos/login/account_screen.cc b/chrome/browser/chromeos/login/account_screen.cc index 7d08f2a..e650b3e 100644 --- a/chrome/browser/chromeos/login/account_screen.cc +++ b/chrome/browser/chromeos/login/account_screen.cc @@ -126,7 +126,7 @@ void AccountScreen::NavigationStateChanged(const TabContents* source, source->render_view_host()->InsertCSSInWebFrame( L"", kCreateAccountCSS, ""); source->render_view_host()->ExecuteJavascriptInWebFrame( - L"", ASCIIToWide(kCreateAccountJS)); + string16(), ASCIIToUTF16(kCreateAccountJS)); } } diff --git a/chrome/browser/chromeos/views/webui_menu_widget.cc b/chrome/browser/chromeos/views/webui_menu_widget.cc index 314877b..b51d57e 100644 --- a/chrome/browser/chromeos/views/webui_menu_widget.cc +++ b/chrome/browser/chromeos/views/webui_menu_widget.cc @@ -9,6 +9,7 @@ #include "base/stringprintf.h" #include "base/singleton.h" #include "base/task.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/chromeos/views/menu_locator.h" #include "chrome/browser/chromeos/views/native_menu_webui.h" #include "chrome/browser/chromeos/wm_ipc.h" @@ -27,7 +28,7 @@ namespace { -// Colors for menu's graident background. +// Colors for the menu's gradient background. const SkColor kMenuStartColor = SK_ColorWHITE; const SkColor kMenuEndColor = 0xFFEEEEEE; @@ -41,7 +42,7 @@ class RoundedBorder : public views::Border { } private: - // views::Border implementatios. + // views::Border implementations. virtual void Paint(const views::View& view, gfx::Canvas* canvas) const { const SkScalar* corners = menu_locator_->GetCorners(); // The menu is in off screen so no need to draw corners. @@ -80,7 +81,7 @@ class InsetsLayout : public views::LayoutManager { InsetsLayout() : views::LayoutManager() {} private: - // views::LayoutManager implementatios. + // views::LayoutManager implementations. virtual void Layout(views::View* host) { if (!host->has_children()) return; @@ -253,7 +254,7 @@ void WebUIMenuWidget::ExecuteJavascript(const std::wstring& script) { DCHECK(dom_view_->tab_contents()->render_view_host()); dom_view_->tab_contents()->render_view_host()-> - ExecuteJavascriptInWebFrame(std::wstring(), script); + ExecuteJavascriptInWebFrame(string16(), WideToUTF16Hack(script)); } void WebUIMenuWidget::ShowAt(chromeos::MenuLocator* locator) { diff --git a/chrome/browser/debugger/debugger_remote_service.cc b/chrome/browser/debugger/debugger_remote_service.cc index e2ea5f2..b930365 100644 --- a/chrome/browser/debugger/debugger_remote_service.cc +++ b/chrome/browser/debugger/debugger_remote_service.cc @@ -330,7 +330,7 @@ bool DebuggerRemoteService::DispatchEvaluateJavascript( } std::string javascript; content->GetString(kDataKey, &javascript); - render_view_host->ExecuteJavascriptInWebFrame(std::wstring(), - UTF8ToWide(javascript)); + render_view_host->ExecuteJavascriptInWebFrame(string16(), + UTF8ToUTF16(javascript)); return false; } diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index 26c1025..07caf026 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -276,17 +276,17 @@ bool DevToolsWindow::IsInspectedBrowserPopup() { } void DevToolsWindow::SetAttachedWindow() { - tab_contents_->render_view_host()-> - ExecuteJavascriptInWebFrame( - L"", docked_ ? L"WebInspector.setAttachedWindow(true);" : - L"WebInspector.setAttachedWindow(false);"); + tab_contents_->render_view_host()->ExecuteJavascriptInWebFrame( + string16(), + docked_ ? ASCIIToUTF16("WebInspector.setAttachedWindow(true);") + : ASCIIToUTF16("WebInspector.setAttachedWindow(false);")); } void DevToolsWindow::AddDevToolsExtensionsToClient() { if (inspected_tab_) { FundamentalValue tabId(inspected_tab_->controller().session_id().id()); - CallClientFunction(L"WebInspector.setInspectedTabId", tabId); + CallClientFunction(ASCIIToUTF16("WebInspector.setInspectedTabId"), tabId); } ListValue results; const ExtensionService* extension_service = @@ -306,16 +306,17 @@ void DevToolsWindow::AddDevToolsExtensionsToClient() { new StringValue((*extension)->devtools_url().spec())); results.Append(extension_info); } - CallClientFunction(L"WebInspector.addExtensions", results); + CallClientFunction(ASCIIToUTF16("WebInspector.addExtensions"), results); } -void DevToolsWindow::CallClientFunction(const std::wstring& function_name, - const Value& arg) { +void DevToolsWindow::CallClientFunction(const string16& function_name, + const Value& arg) { std::string json; base::JSONWriter::Write(&arg, false, &json); - std::wstring javascript = function_name + L"(" + UTF8ToWide(json) + L");"; + string16 javascript = function_name + char16('(') + UTF8ToUTF16(json) + + ASCIIToUTF16(");"); tab_contents_->render_view_host()-> - ExecuteJavascriptInWebFrame(L"", javascript); + ExecuteJavascriptInWebFrame(string16(), javascript); } void DevToolsWindow::Observe(NotificationType type, @@ -352,13 +353,12 @@ void DevToolsWindow::DoAction() { // TODO: these messages should be pushed through the WebKit API instead. switch (action_on_load_) { case DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE: - tab_contents_->render_view_host()-> - ExecuteJavascriptInWebFrame(L"", L"WebInspector.showConsole();"); + tab_contents_->render_view_host()->ExecuteJavascriptInWebFrame( + string16(), ASCIIToUTF16("WebInspector.showConsole();")); break; case DEVTOOLS_TOGGLE_ACTION_INSPECT: - tab_contents_->render_view_host()-> - ExecuteJavascriptInWebFrame( - L"", L"WebInspector.toggleSearchingForNode();"); + tab_contents_->render_view_host()->ExecuteJavascriptInWebFrame( + string16(), ASCIIToUTF16("WebInspector.toggleSearchingForNode();")); case DEVTOOLS_TOGGLE_ACTION_NONE: // Do nothing. break; @@ -407,7 +407,7 @@ void DevToolsWindow::UpdateTheme() { SkColorToRGBAString(color_toolbar).c_str(), SkColorToRGBAString(color_tab_text).c_str()); tab_contents_->render_view_host()-> - ExecuteJavascriptInWebFrame(L"", UTF8ToWide(command)); + ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(command)); } void DevToolsWindow::AddNewContents(TabContents* source, diff --git a/chrome/browser/debugger/devtools_window.h b/chrome/browser/debugger/devtools_window.h index d5a81c6..689ae40 100644 --- a/chrome/browser/debugger/devtools_window.h +++ b/chrome/browser/debugger/devtools_window.h @@ -68,7 +68,7 @@ class DevToolsWindow GURL GetDevToolsUrl(); void UpdateTheme(); void AddDevToolsExtensionsToClient(); - void CallClientFunction(const std::wstring& function_name, + void CallClientFunction(const string16& function_name, const Value& arg); // Overridden from TabContentsDelegate. virtual void OpenURLFromTab(TabContents* source, diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc index 56ccc02..1b92009 100644 --- a/chrome/browser/dom_ui/dom_ui.cc +++ b/chrome/browser/dom_ui/dom_ui.cc @@ -152,7 +152,8 @@ void DOMUI::AddMessageHandler(WebUIMessageHandler* handler) { } void DOMUI::ExecuteJavascript(const std::wstring& javascript) { - GetRenderViewHost()->ExecuteJavascriptInWebFrame(std::wstring(), javascript); + GetRenderViewHost()->ExecuteJavascriptInWebFrame(string16(), + WideToUTF16Hack(javascript)); } /////////////////////////////////////////////////////////////////////////////// @@ -164,7 +165,7 @@ WebUIMessageHandler* WebUIMessageHandler::Attach(DOMUI* dom_ui) { return this; } -// WebUIMessageHandler, protected: ---------------------------------------------- +// WebUIMessageHandler, protected: --------------------------------------------- void WebUIMessageHandler::SetURLAndTitle(DictionaryValue* dictionary, string16 title, diff --git a/chrome/browser/dom_ui/dom_ui_handler_browsertest.cc b/chrome/browser/dom_ui/dom_ui_handler_browsertest.cc index 89acbcb..0405fce 100644 --- a/chrome/browser/dom_ui/dom_ui_handler_browsertest.cc +++ b/chrome/browser/dom_ui/dom_ui_handler_browsertest.cc @@ -10,7 +10,7 @@ bool DOMUITestHandler::Execute(const std::string& js_test) { dom_ui_->GetRenderViewHost()->ExecuteJavascriptInWebFrame( - std::wstring(), UTF8ToWide(js_test)); + string16(), UTF8ToUTF16(js_test)); return WaitForResult(); } diff --git a/chrome/browser/extensions/alert_apitest.cc b/chrome/browser/extensions/alert_apitest.cc index 10b310b..cbe2a78 100644 --- a/chrome/browser/extensions/alert_apitest.cc +++ b/chrome/browser/extensions/alert_apitest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/utf_string_conversions.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_process_manager.h" @@ -18,8 +19,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AlertBasic) { ExtensionHost* host = browser()->profile()->GetExtensionProcessManager()-> GetBackgroundHostForExtension(extension); ASSERT_TRUE(host); - host->render_view_host()->ExecuteJavascriptInWebFrame(L"", - L"alert('This should not crash.');"); + host->render_view_host()->ExecuteJavascriptInWebFrame(string16(), + ASCIIToUTF16("alert('This should not crash.');")); AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); ASSERT_TRUE(alert); diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc index 43c2eab..d31ba67 100644 --- a/chrome/browser/geolocation/geolocation_browsertest.cc +++ b/chrome/browser/geolocation/geolocation_browsertest.cc @@ -51,7 +51,7 @@ class IFrameLoader : public NotificationObserver { iframe_id, url.spec().c_str()); browser->GetSelectedTabContents()->render_view_host()-> - ExecuteJavascriptInWebFrame(L"", UTF8ToWide(script)); + ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(script)); ui_test_utils::RunMessageLoop(); EXPECT_EQ(StringPrintf("\"%d\"", iframe_id), javascript_response_); @@ -130,8 +130,8 @@ class GeolocationNotificationObserver : public NotificationObserver { std::string script = "window.domAutomationController.setAutomationId(0);" "window.domAutomationController.send(geoStart());"; - render_view_host->ExecuteJavascriptInWebFrame(iframe_xpath, - UTF8ToWide(script)); + render_view_host->ExecuteJavascriptInWebFrame(WideToUTF16Hack(iframe_xpath), + UTF8ToUTF16(script)); ui_test_utils::RunMessageLoop(); registrar_.RemoveAll(); LOG(WARNING) << "got geolocation watch" << javascript_response_; diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc index 0e2f79d..fdcf244 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc @@ -288,6 +288,7 @@ void CloudPrintSetupFlow::ExecuteJavascriptInIFrame( const std::wstring& js) { if (dom_ui_) { RenderViewHost* rvh = dom_ui_->tab_contents()->render_view_host(); - rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js); + rvh->ExecuteJavascriptInWebFrame(WideToUTF16Hack(iframe_xpath), + WideToUTF16Hack(js)); } } diff --git a/chrome/browser/printing/print_dialog_cloud_uitest.cc b/chrome/browser/printing/print_dialog_cloud_uitest.cc index e64ff81..caced65 100644 --- a/chrome/browser/printing/print_dialog_cloud_uitest.cc +++ b/chrome/browser/printing/print_dialog_cloud_uitest.cc @@ -12,6 +12,7 @@ #include "base/path_service.h" #include "base/singleton.h" #include "base/threading/thread_restrictions.h" +#include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_thread.h" @@ -249,9 +250,9 @@ IN_PROC_BROWSER_TEST_F(PrintDialogCloudTest, DISABLED_DialogGrabbed) { ASSERT_TRUE(browser()->GetSelectedTabContents()); ASSERT_TRUE(browser()->GetSelectedTabContents()->render_view_host()); - std::wstring window_print(L"window.print()"); + string16 window_print = ASCIIToUTF16("window.print()"); browser()->GetSelectedTabContents()->render_view_host()-> - ExecuteJavascriptInWebFrame(std::wstring(), window_print); + ExecuteJavascriptInWebFrame(string16(), window_print); ui_test_utils::RunMessageLoop(); diff --git a/chrome/browser/remoting/setup_flow.cc b/chrome/browser/remoting/setup_flow.cc index 918855a..29052f2 100644 --- a/chrome/browser/remoting/setup_flow.cc +++ b/chrome/browser/remoting/setup_flow.cc @@ -55,7 +55,8 @@ void SetupFlowStepBase::ExecuteJavascriptInIFrame( DCHECK(dom_ui); RenderViewHost* rvh = dom_ui->tab_contents()->render_view_host(); - rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js); + rvh->ExecuteJavascriptInWebFrame(WideToUTF16Hack(iframe_xpath), + WideToUTF16Hack(js)); } void SetupFlowStepBase::FinishStep(SetupFlowStep* next_step) { diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index dd2dd5d..22231df 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -471,10 +471,9 @@ void RenderViewHost::ReservePageIDRange(int size) { } void RenderViewHost::ExecuteJavascriptInWebFrame( - const std::wstring& frame_xpath, - const std::wstring& jscript) { - Send(new ViewMsg_ScriptEvalRequest(routing_id(), WideToUTF16(frame_xpath), - WideToUTF16(jscript), + const string16& frame_xpath, + const string16& jscript) { + Send(new ViewMsg_ScriptEvalRequest(routing_id(), frame_xpath, jscript, 0, false)); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 5f6188d..a16168a 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -261,8 +261,8 @@ class RenderViewHost : public RenderWidgetHost { void ReservePageIDRange(int size); // Runs some javascript within the context of a frame in the page. - void ExecuteJavascriptInWebFrame(const std::wstring& frame_xpath, - const std::wstring& jscript); + void ExecuteJavascriptInWebFrame(const string16& frame_xpath, + const string16& jscript); // Runs some javascript within the context of a frame in the page. The result // is sent back via the notification EXECUTE_JAVASCRIPT_RESULT. diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc index 25b8a31..9e49a28 100644 --- a/chrome/browser/sync/sync_setup_flow.cc +++ b/chrome/browser/sync/sync_setup_flow.cc @@ -357,7 +357,8 @@ void FlowHandler::ExecuteJavascriptInIFrame(const std::wstring& iframe_xpath, const std::wstring& js) { if (dom_ui_) { RenderViewHost* rvh = dom_ui_->tab_contents()->render_view_host(); - rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js); + rvh->ExecuteJavascriptInWebFrame(WideToUTF16Hack(iframe_xpath), + WideToUTF16Hack(js)); } } diff --git a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm index 3a10095..b99fcd8 100644 --- a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm +++ b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm @@ -285,9 +285,9 @@ return nil; } - std::wstring script = base::SysNSStringToWide( + string16 script = base::SysNSStringToUTF16( [[command evaluatedArguments] objectForKey:@"javascript"]); - view->ExecuteJavascriptInWebFrame(L"", script); + view->ExecuteJavascriptInWebFrame(string16(), script); // TODO(Shreyas): Figure out a way to get the response back. return nil; diff --git a/chrome/browser/ui/login/login_prompt.cc b/chrome/browser/ui/login/login_prompt.cc index 380f7b5..4f8189a 100644 --- a/chrome/browser/ui/login/login_prompt.cc +++ b/chrome/browser/ui/login/login_prompt.cc @@ -124,8 +124,8 @@ RenderViewHostDelegate* LoginHandler::GetRenderViewHostDelegate() const { return rvh->delegate(); } -void LoginHandler::SetAuth(const std::wstring& username, - const std::wstring& password) { +void LoginHandler::SetAuth(const string16& username, + const string16& password) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (TestAndSetAuthHandled()) @@ -133,8 +133,8 @@ void LoginHandler::SetAuth(const std::wstring& username, // Tell the password manager the credentials were submitted / accepted. if (password_manager_) { - password_form_.username_value = WideToUTF16Hack(username); - password_form_.password_value = WideToUTF16Hack(password); + password_form_.username_value = username; + password_form_.password_value = password; password_manager_->ProvisionallySavePassword(password_form_); } @@ -293,8 +293,8 @@ void LoginHandler::NotifyAuthCancelled() { Details<LoginNotificationDetails>(&details)); } -void LoginHandler::NotifyAuthSupplied(const std::wstring& username, - const std::wstring& password) { +void LoginHandler::NotifyAuthSupplied(const string16& username, + const string16& password) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(WasAuthHandled()); @@ -345,12 +345,12 @@ bool LoginHandler::TestAndSetAuthHandled() { } // Calls SetAuth from the IO loop. -void LoginHandler::SetAuthDeferred(const std::wstring& username, - const std::wstring& password) { +void LoginHandler::SetAuthDeferred(const string16& username, + const string16& password) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (request_) { - request_->SetAuth(WideToUTF16Hack(username), WideToUTF16Hack(password)); + request_->SetAuth(username, password); ResetLoginHandlerForRequest(request_); } } @@ -421,8 +421,7 @@ class LoginDialogTask : public Task { l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION, host_and_port_hack16, realm_hack16); - handler_->BuildViewForPasswordManager(password_manager, - UTF16ToWideHack(explanation)); + handler_->BuildViewForPasswordManager(password_manager, explanation); } private: diff --git a/chrome/browser/ui/login/login_prompt.h b/chrome/browser/ui/login/login_prompt.h index 7c8ae9d..7742996 100644 --- a/chrome/browser/ui/login/login_prompt.h +++ b/chrome/browser/ui/login/login_prompt.h @@ -41,7 +41,7 @@ class LoginHandler : public base::RefCountedThreadSafe<LoginHandler>, // Initializes the underlying platform specific view. virtual void BuildViewForPasswordManager(PasswordManager* manager, - std::wstring explanation) = 0; + const string16& explanation) = 0; // Sets information about the authentication type (|form|) and the // |password_manager| for this profile. @@ -56,7 +56,7 @@ class LoginHandler : public base::RefCountedThreadSafe<LoginHandler>, // Resend the request with authentication credentials. // This function can be called from either thread. - void SetAuth(const std::wstring& username, const std::wstring& password); + void SetAuth(const string16& username, const string16& password); // Display the error page without asking for credentials again. // This function can be called from either thread. @@ -99,8 +99,8 @@ class LoginHandler : public base::RefCountedThreadSafe<LoginHandler>, void RemoveObservers(); // Notify observers that authentication is supplied. - void NotifyAuthSupplied(const std::wstring& username, - const std::wstring& password); + void NotifyAuthSupplied(const string16& username, + const string16& password); // Notify observers that authentication is cancelled. void NotifyAuthCancelled(); @@ -110,8 +110,8 @@ class LoginHandler : public base::RefCountedThreadSafe<LoginHandler>, bool TestAndSetAuthHandled(); // Calls SetAuth from the IO loop. - void SetAuthDeferred(const std::wstring& username, - const std::wstring& password); + void SetAuthDeferred(const string16& username, + const string16& password); // Calls CancelAuth from the IO loop. void CancelAuthDeferred(); @@ -179,20 +179,20 @@ class LoginNotificationDetails { class AuthSuppliedLoginNotificationDetails : public LoginNotificationDetails { public: AuthSuppliedLoginNotificationDetails(LoginHandler* handler, - const std::wstring& username, - const std::wstring& password) + const string16& username, + const string16& password) : LoginNotificationDetails(handler), username_(username), password_(password) {} - const std::wstring& username() const { return username_; } - const std::wstring& password() const { return password_; } + const string16& username() const { return username_; } + const string16& password() const { return password_; } private: // The username that was used for the authentication. - const std::wstring username_; + const string16 username_; // The password that was used for the authentication. - const std::wstring password_; + const string16 password_; DISALLOW_COPY_AND_ASSIGN(AuthSuppliedLoginNotificationDetails); }; diff --git a/chrome/browser/ui/login/login_prompt_browsertest.cc b/chrome/browser/ui/login/login_prompt_browsertest.cc index 8c2db99..bc52d66 100644 --- a/chrome/browser/ui/login/login_prompt_browsertest.cc +++ b/chrome/browser/ui/login/login_prompt_browsertest.cc @@ -6,6 +6,7 @@ #include <list> #include <map> +#include "base/utf_string_conversions.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" #include "chrome/browser/ui/browser.h" @@ -56,7 +57,8 @@ void LoginPromptBrowserTest::SetAuthFor(LoginHandler* handler) { EXPECT_TRUE(auth_map_.end() != i); if (i != auth_map_.end()) { const AuthInfo& info = i->second; - handler->SetAuth(info.username_, info.password_); + handler->SetAuth(WideToUTF16Hack(info.username_), + WideToUTF16Hack(info.password_)); } } @@ -364,7 +366,8 @@ IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, DISABLED_IncorrectConfirmation) { LoginHandler* handler = *observer.handlers_.begin(); ASSERT_TRUE(handler); - handler->SetAuth(bad_username_, bad_password_); + handler->SetAuth(WideToUTF16Hack(bad_username_), + WideToUTF16Hack(bad_password_)); LOG(INFO) << "Waiting for initial AUTH_SUPPLIED"; auth_supplied_waiter.Wait(); diff --git a/chrome/browser/ui/login/login_prompt_gtk.cc b/chrome/browser/ui/login/login_prompt_gtk.cc index f070b65a..e6487a5 100644 --- a/chrome/browser/ui/login/login_prompt_gtk.cc +++ b/chrome/browser/ui/login/login_prompt_gtk.cc @@ -64,11 +64,11 @@ class LoginHandlerGtk : public LoginHandler, // LoginHandler: virtual void BuildViewForPasswordManager(PasswordManager* manager, - std::wstring explanation) { + const string16& explanation) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); root_.Own(gtk_vbox_new(FALSE, gtk_util::kContentAreaBorder)); - GtkWidget* label = gtk_label_new(WideToUTF8(explanation).c_str()); + GtkWidget* label = gtk_label_new(UTF16ToUTF8(explanation).c_str()); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_box_pack_start(GTK_BOX(root_.get()), label, FALSE, FALSE, 0); @@ -153,8 +153,8 @@ class LoginHandlerGtk : public LoginHandler, void LoginHandlerGtk::OnOKClicked(GtkWidget* sender) { SetAuth( - UTF8ToWide(gtk_entry_get_text(GTK_ENTRY(username_entry_))), - UTF8ToWide(gtk_entry_get_text(GTK_ENTRY(password_entry_)))); + UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(username_entry_))), + UTF8ToUTF16(gtk_entry_get_text(GTK_ENTRY(password_entry_)))); } void LoginHandlerGtk::OnCancelClicked(GtkWidget* sender) { diff --git a/chrome/browser/ui/login/login_prompt_mac.mm b/chrome/browser/ui/login/login_prompt_mac.mm index f663632..6036831 100644 --- a/chrome/browser/ui/login/login_prompt_mac.mm +++ b/chrome/browser/ui/login/login_prompt_mac.mm @@ -53,7 +53,7 @@ class LoginHandlerMac : public LoginHandler, // LoginHandler: virtual void BuildViewForPasswordManager(PasswordManager* manager, - std::wstring explanation) { + const string16& explanation) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // Load nib here instead of in constructor. @@ -64,7 +64,7 @@ class LoginHandlerMac : public LoginHandler, SetModel(manager); - [sheet_controller_ setExplanation:base::SysWideToNSString(explanation)]; + [sheet_controller_ setExplanation:base::SysUTF16ToNSString(explanation)]; // Scary thread safety note: This can potentially be called *after* SetAuth // or CancelAuth (say, if the request was cancelled before the UI thread got @@ -92,8 +92,8 @@ class LoginHandlerMac : public LoginHandler, ReleaseSoon(); } - void OnLoginPressed(const std::wstring& username, - const std::wstring& password) { + void OnLoginPressed(const string16& username, + const string16& password) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); SetAuth(username, password); @@ -147,8 +147,9 @@ LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, - (IBAction)loginPressed:(id)sender { using base::SysNSStringToWide; [NSApp endSheet:[self window]]; - handler_->OnLoginPressed(SysNSStringToWide([nameField_ stringValue]), - SysNSStringToWide([passwordField_ stringValue])); + handler_->OnLoginPressed( + base::SysNSStringToUTF16([nameField_ stringValue]), + base::SysNSStringToUTF16([passwordField_ stringValue])); } - (IBAction)cancelPressed:(id)sender { diff --git a/chrome/browser/ui/login/login_prompt_win.cc b/chrome/browser/ui/login/login_prompt_win.cc index cf111d1..019679c 100644 --- a/chrome/browser/ui/login/login_prompt_win.cc +++ b/chrome/browser/ui/login/login_prompt_win.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ui/login/login_prompt.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/password_manager/password_manager.h" #include "chrome/browser/renderer_host/render_process_host.h" @@ -101,14 +102,15 @@ class LoginHandlerWin : public LoginHandler, // LoginHandler: virtual void BuildViewForPasswordManager(PasswordManager* manager, - std::wstring explanation) { + const string16& explanation) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); TabContents* tab_contents = GetTabContentsForLogin(); bool should_focus_view = !tab_contents->delegate() || tab_contents->delegate()->ShouldFocusConstrainedWindow(); - LoginView* view = new LoginView(explanation, should_focus_view); + LoginView* view = new LoginView(UTF16ToWideHack(explanation), + should_focus_view); // Set the model for the login view. The model (password manager) is owned // by the view's parent TabContents, so natural destruction order means we diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc index 436273b..4712faf 100644 --- a/chrome/test/ui_test_utils.cc +++ b/chrome/test/ui_test_utils.cc @@ -288,7 +288,8 @@ class InProcessJavaScriptExecutionController // Executes |script| and sets the JSON response |json|. virtual bool ExecuteJavaScriptAndGetJSON(const std::string& script, std::string* json) { - render_view_host_->ExecuteJavascriptInWebFrame(L"", UTF8ToWide(script)); + render_view_host_->ExecuteJavascriptInWebFrame(string16(), + UTF8ToUTF16(script)); DOMOperationObserver dom_op_observer(render_view_host_); return dom_op_observer.GetResponse(json); } @@ -323,7 +324,8 @@ bool ExecuteJavaScriptHelper(RenderViewHost* render_view_host, // automation id. std::wstring script = L"window.domAutomationController.setAutomationId(0);" + original_script; - render_view_host->ExecuteJavascriptInWebFrame(frame_xpath, script); + render_view_host->ExecuteJavascriptInWebFrame(WideToUTF16Hack(frame_xpath), + WideToUTF16Hack(script)); DOMOperationObserver dom_op_observer(render_view_host); std::string json; if (!dom_op_observer.GetResponse(&json)) diff --git a/chrome/tools/convert_dict/convert_dict_unittest.cc b/chrome/tools/convert_dict/convert_dict_unittest.cc index 5f56c69..f8d1971 100644 --- a/chrome/tools/convert_dict/convert_dict_unittest.cc +++ b/chrome/tools/convert_dict/convert_dict_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,18 +62,18 @@ bool VerifyWords(const convert_dict::DicReader::WordList& org_words, // * Creates bdict data. // * Verify the bdict data. void RunDictionaryTest(const char* codepage, - const std::map<std::wstring, bool>& word_list) { + const std::map<string16, bool>& word_list) { // Create an affix data and a dictionary data. std::string aff_data(StringPrintf("SET %s\n", codepage)); std::string dic_data(StringPrintf("%" PRIuS "\n", word_list.size())); - for (std::map<std::wstring, bool>::const_iterator it = word_list.begin(); + for (std::map<string16, bool>::const_iterator it = word_list.begin(); it != word_list.end(); ++it) { std::string encoded_word; - EXPECT_TRUE(WideToCodepage(it->first, - codepage, - base::OnStringConversionError::FAIL, - &encoded_word)); + EXPECT_TRUE(UTF16ToCodepage(it->first, + codepage, + base::OnStringConversionError::FAIL, + &encoded_word)); dic_data += encoded_word; dic_data += "\n"; } @@ -101,7 +101,7 @@ void RunDictionaryTest(const char* codepage, for (size_t i = 0; i < dic_reader.words().size(); ++i) { SCOPED_TRACE(StringPrintf("dic_reader.words()[%" PRIuS "]: %s", i, dic_reader.words()[i].first.c_str())); - std::wstring word(UTF8ToWide(dic_reader.words()[i].first)); + string16 word(UTF8ToUTF16(dic_reader.words()[i].first)); EXPECT_TRUE(word_list.find(word) != word_list.end()); } @@ -149,9 +149,10 @@ TEST(ConvertDictTest, English) { L"they", }; - std::map<std::wstring, bool> word_list; + std::map<string16, bool> word_list; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kWords); ++i) - word_list.insert(std::make_pair<std::wstring, bool>(kWords[i], true)); + word_list.insert(std::make_pair<string16, bool>(WideToUTF16(kWords[i]), + true)); RunDictionaryTest(kCodepage, word_list); } @@ -170,9 +171,10 @@ TEST(ConvertDictTest, Russian) { L"\x043e\x043d\x0438", }; - std::map<std::wstring, bool> word_list; + std::map<string16, bool> word_list; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kWords); ++i) - word_list.insert(std::make_pair<std::wstring, bool>(kWords[i], true)); + word_list.insert(std::make_pair<string16, bool>(WideToUTF16(kWords[i]), + true)); RunDictionaryTest(kCodepage, word_list); } @@ -193,9 +195,10 @@ TEST(ConvertDictTest, Hungarian) { L"\x006d\x0061\x0067\x0075\x006b", }; - std::map<std::wstring, bool> word_list; + std::map<string16, bool> word_list; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kWords); ++i) - word_list.insert(std::make_pair<std::wstring, bool>(kWords[i], true)); + word_list.insert(std::make_pair<string16, bool>(WideToUTF16(kWords[i]), + true)); RunDictionaryTest(kCodepage, word_list); } |