| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chrome_render_frame_observer.h" | 5 #include "chrome/renderer/chrome_render_frame_observer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 return; | 297 return; |
| 298 | 298 |
| 299 base::TimeTicks capture_begin_time = base::TimeTicks::Now(); | 299 base::TimeTicks capture_begin_time = base::TimeTicks::Now(); |
| 300 | 300 |
| 301 // Retrieve the frame's full text (up to kMaxIndexChars), and pass it to the | 301 // Retrieve the frame's full text (up to kMaxIndexChars), and pass it to the |
| 302 // translate helper for language detection and possible translation. | 302 // translate helper for language detection and possible translation. |
| 303 // TODO(dglazkov): WebFrameContentDumper should only be used for | 303 // TODO(dglazkov): WebFrameContentDumper should only be used for |
| 304 // testing purposes. See http://crbug.com/585164. | 304 // testing purposes. See http://crbug.com/585164. |
| 305 base::string16 contents = | 305 base::string16 contents = |
| 306 WebFrameContentDumper::deprecatedDumpFrameTreeAsText(frame, | 306 WebFrameContentDumper::deprecatedDumpFrameTreeAsText(frame, |
| 307 kMaxIndexChars); | 307 kMaxIndexChars) |
| 308 .utf16(); |
| 308 | 309 |
| 309 UMA_HISTOGRAM_TIMES(kTranslateCaptureText, | 310 UMA_HISTOGRAM_TIMES(kTranslateCaptureText, |
| 310 base::TimeTicks::Now() - capture_begin_time); | 311 base::TimeTicks::Now() - capture_begin_time); |
| 311 | 312 |
| 312 // We should run language detection only once. Parsing finishes before | 313 // We should run language detection only once. Parsing finishes before |
| 313 // the page loads, so let's pick that timing. | 314 // the page loads, so let's pick that timing. |
| 314 if (translate_helper_ && capture_type == PRELIMINARY_CAPTURE) | 315 if (translate_helper_ && capture_type == PRELIMINARY_CAPTURE) |
| 315 translate_helper_->PageCaptured(contents); | 316 translate_helper_->PageCaptured(contents); |
| 316 | 317 |
| 317 TRACE_EVENT0("renderer", "ChromeRenderFrameObserver::CapturePageText"); | 318 TRACE_EVENT0("renderer", "ChromeRenderFrameObserver::CapturePageText"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 338 CapturePageText(FINAL_CAPTURE); | 339 CapturePageText(FINAL_CAPTURE); |
| 339 break; | 340 break; |
| 340 default: | 341 default: |
| 341 break; | 342 break; |
| 342 } | 343 } |
| 343 } | 344 } |
| 344 | 345 |
| 345 void ChromeRenderFrameObserver::OnDestruct() { | 346 void ChromeRenderFrameObserver::OnDestruct() { |
| 346 delete this; | 347 delete this; |
| 347 } | 348 } |
| OLD | NEW |