| OLD | NEW |
| 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 // This file contains the implementation of TestWebViewDelegate, which serves | 5 // This file contains the implementation of TestWebViewDelegate, which serves |
| 6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to | 6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to |
| 7 // have initialized a MessageLoop before these methods are called. | 7 // have initialized a MessageLoop before these methods are called. |
| 8 | 8 |
| 9 #include "webkit/tools/test_shell/test_webview_delegate.h" | 9 #include "webkit/tools/test_shell/test_webview_delegate.h" |
| 10 | 10 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 WebString::fromUTF8(edit_command_value_)); | 325 WebString::fromUTF8(edit_command_value_)); |
| 326 } | 326 } |
| 327 | 327 |
| 328 void TestWebViewDelegate::spellCheck(const WebString& text, | 328 void TestWebViewDelegate::spellCheck(const WebString& text, |
| 329 int& misspelledOffset, | 329 int& misspelledOffset, |
| 330 int& misspelledLength) { | 330 int& misspelledLength) { |
| 331 #if defined(OS_MACOSX) | 331 #if defined(OS_MACOSX) |
| 332 // Check the spelling of the given text. | 332 // Check the spelling of the given text. |
| 333 // TODO(hbono): rebaseline layout-test results of Windows and Linux so we | 333 // TODO(hbono): rebaseline layout-test results of Windows and Linux so we |
| 334 // can enable this mock spellchecker on them. | 334 // can enable this mock spellchecker on them. |
| 335 string16 word(text); | 335 base::string16 word(text); |
| 336 mock_spellcheck_.SpellCheckWord(word, &misspelledOffset, &misspelledLength); | 336 mock_spellcheck_.SpellCheckWord(word, &misspelledOffset, &misspelledLength); |
| 337 #endif | 337 #endif |
| 338 } | 338 } |
| 339 | 339 |
| 340 WebString TestWebViewDelegate::autoCorrectWord(const WebString& word) { | 340 WebString TestWebViewDelegate::autoCorrectWord(const WebString& word) { |
| 341 // Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm') | 341 // Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm') |
| 342 // does. (If this function returns a non-empty string, WebKit replaces the | 342 // does. (If this function returns a non-empty string, WebKit replaces the |
| 343 // given misspelled string with the result one. This process executes some | 343 // given misspelled string with the result one. This process executes some |
| 344 // editor commands and causes layout-test failures.) | 344 // editor commands and causes layout-test failures.) |
| 345 return WebString(); | 345 return WebString(); |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 return; | 974 return; |
| 975 | 975 |
| 976 const WebHistoryItem& history_item = | 976 const WebHistoryItem& history_item = |
| 977 shell_->webView()->mainFrame()->previousHistoryItem(); | 977 shell_->webView()->mainFrame()->previousHistoryItem(); |
| 978 if (history_item.isNull()) | 978 if (history_item.isNull()) |
| 979 return; | 979 return; |
| 980 | 980 |
| 981 entry->SetContentState(webkit_glue::HistoryItemToString(history_item)); | 981 entry->SetContentState(webkit_glue::HistoryItemToString(history_item)); |
| 982 } | 982 } |
| 983 | 983 |
| 984 string16 TestWebViewDelegate::GetFrameDescription(WebFrame* webframe) { | 984 base::string16 TestWebViewDelegate::GetFrameDescription(WebFrame* webframe) { |
| 985 std::string name = UTF16ToUTF8(webframe->uniqueName()); | 985 std::string name = UTF16ToUTF8(webframe->uniqueName()); |
| 986 | 986 |
| 987 if (webframe == shell_->webView()->mainFrame()) { | 987 if (webframe == shell_->webView()->mainFrame()) { |
| 988 if (name.length()) | 988 if (name.length()) |
| 989 name = "main frame \"" + name + "\""; | 989 name = "main frame \"" + name + "\""; |
| 990 else | 990 else |
| 991 name = "main frame"; | 991 name = "main frame"; |
| 992 } else { | 992 } else { |
| 993 if (name.length()) | 993 if (name.length()) |
| 994 name = "frame \"" + name + "\""; | 994 name = "frame \"" + name + "\""; |
| 995 else | 995 else |
| 996 name = "frame (anonymous)"; | 996 name = "frame (anonymous)"; |
| 997 } | 997 } |
| 998 return UTF8ToUTF16(name); | 998 return UTF8ToUTF16(name); |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { | 1001 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { |
| 1002 fake_rect_ = rect; | 1002 fake_rect_ = rect; |
| 1003 using_fake_rect_ = true; | 1003 using_fake_rect_ = true; |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 WebRect TestWebViewDelegate::fake_window_rect() { | 1006 WebRect TestWebViewDelegate::fake_window_rect() { |
| 1007 return fake_rect_; | 1007 return fake_rect_; |
| 1008 } | 1008 } |
| OLD | NEW |