| 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 #include "chrome/renderer/translate/translate_helper.h" | 5 #include "chrome/renderer/translate/translate_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "third_party/WebKit/public/web/WebElement.h" | 23 #include "third_party/WebKit/public/web/WebElement.h" |
| 24 #include "third_party/WebKit/public/web/WebFrame.h" | 24 #include "third_party/WebKit/public/web/WebFrame.h" |
| 25 #include "third_party/WebKit/public/web/WebNode.h" | 25 #include "third_party/WebKit/public/web/WebNode.h" |
| 26 #include "third_party/WebKit/public/web/WebNodeList.h" | 26 #include "third_party/WebKit/public/web/WebNodeList.h" |
| 27 #include "third_party/WebKit/public/web/WebScriptSource.h" | 27 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 28 #include "third_party/WebKit/public/web/WebView.h" | 28 #include "third_party/WebKit/public/web/WebView.h" |
| 29 #include "third_party/WebKit/public/web/WebWidget.h" | 29 #include "third_party/WebKit/public/web/WebWidget.h" |
| 30 #include "url/gurl.h" | 30 #include "url/gurl.h" |
| 31 #include "v8/include/v8.h" | 31 #include "v8/include/v8.h" |
| 32 | 32 |
| 33 using WebKit::WebDocument; | 33 using blink::WebDocument; |
| 34 using WebKit::WebElement; | 34 using blink::WebElement; |
| 35 using WebKit::WebFrame; | 35 using blink::WebFrame; |
| 36 using WebKit::WebNode; | 36 using blink::WebNode; |
| 37 using WebKit::WebNodeList; | 37 using blink::WebNodeList; |
| 38 using WebKit::WebScriptSource; | 38 using blink::WebScriptSource; |
| 39 using WebKit::WebSecurityOrigin; | 39 using blink::WebSecurityOrigin; |
| 40 using WebKit::WebString; | 40 using blink::WebString; |
| 41 using WebKit::WebVector; | 41 using blink::WebVector; |
| 42 using WebKit::WebView; | 42 using blink::WebView; |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 // The delay in milliseconds that we'll wait before checking to see if the | 46 // The delay in milliseconds that we'll wait before checking to see if the |
| 47 // translate library injected in the page is ready. | 47 // translate library injected in the page is ready. |
| 48 const int kTranslateInitCheckDelayMs = 150; | 48 const int kTranslateInitCheckDelayMs = 150; |
| 49 | 49 |
| 50 // The maximum number of times we'll check to see if the translate library | 50 // The maximum number of times we'll check to see if the translate library |
| 51 // injected in the page is ready. | 51 // injected in the page is ready. |
| 52 const int kMaxTranslateInitCheckAttempts = 5; | 52 const int kMaxTranslateInitCheckAttempts = 5; |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 490 |
| 491 WebFrame* TranslateHelper::GetMainFrame() { | 491 WebFrame* TranslateHelper::GetMainFrame() { |
| 492 WebView* web_view = render_view()->GetWebView(); | 492 WebView* web_view = render_view()->GetWebView(); |
| 493 | 493 |
| 494 // When the tab is going to be closed, the web_view can be NULL. | 494 // When the tab is going to be closed, the web_view can be NULL. |
| 495 if (!web_view) | 495 if (!web_view) |
| 496 return NULL; | 496 return NULL; |
| 497 | 497 |
| 498 return web_view->mainFrame(); | 498 return web_view->mainFrame(); |
| 499 } | 499 } |
| OLD | NEW |