OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // The |FeedbackSender| object stores the user feedback to spellcheck | 5 // The |FeedbackSender| object stores the user feedback to spellcheck |
6 // suggestions in a |Feedback| object. | 6 // suggestions in a |Feedback| object. |
7 // | 7 // |
8 // When spelling service returns spellcheck results, these results first arrive | 8 // When spelling service returns spellcheck results, these results first arrive |
9 // in |FeedbackSender| to assign hash identifiers for each | 9 // in |FeedbackSender| to assign hash identifiers for each |
10 // misspelling-suggestion pair. If the spelling service identifies the same | 10 // misspelling-suggestion pair. If the spelling service identifies the same |
11 // misspelling as already displayed to the user, then |FeedbackSender| reuses | 11 // misspelling as already displayed to the user, then |FeedbackSender| reuses |
12 // the same hash identifiers to avoid duplication. It detects the duplicates by | 12 // the same hash identifiers to avoid duplication. It detects the duplicates by |
13 // comparing misspelling offsets in text. Spelling service can return duplicates | 13 // comparing misspelling offsets in text. Spelling service can return duplicates |
14 // because we request spellcheck for whole paragraphs, as context around a | 14 // because we request spellcheck for whole paragraphs, as context around a |
15 // misspelled word is important to the spellcheck algorithm. | 15 // misspelled word is important to the spellcheck algorithm. |
16 // | 16 // |
17 // All feedback is initially pending. When a user acts upon a misspelling such | 17 // All feedback is initially pending. When a user acts upon a misspelling such |
18 // that the misspelling is no longer displayed (red squiggly line goes away), | 18 // that the misspelling is no longer displayed (red squiggly line goes away), |
19 // then the feedback for this misspelling is finalized. All finalized feedback | 19 // then the feedback for this misspelling is finalized. All finalized feedback |
20 // is erased after being sent to the spelling service. Pending feedback is kept | 20 // is erased after being sent to the spelling service. Pending feedback is kept |
21 // around for |kSessionHours| hours and then finalized even if user did not act | 21 // around for |kSessionHours| hours and then finalized even if user did not act |
22 // on the misspellings. | 22 // on the misspellings. |
23 // | 23 // |
24 // |FeedbackSender| periodically requests a list of hashes of all remaining | 24 // |FeedbackSender| periodically requests a list of hashes of all remaining |
25 // misspellings in renderers. When a renderer responds with a list of hashes, | 25 // misspellings in renderers. When a renderer responds with a list of hashes, |
26 // |FeedbackSender| uses the list to determine which misspellings are no longer | 26 // |FeedbackSender| uses the list to determine which misspellings are no longer |
27 // displayed to the user and sends the current state of user feedback to the | 27 // displayed to the user and sends the current state of user feedback to the |
28 // spelling service. | 28 // spelling service. |
29 | 29 |
30 #include "chrome/browser/spellchecker/feedback_sender.h" | 30 #include "components/spellcheck/browser/feedback_sender.h" |
31 | 31 |
32 #include <algorithm> | 32 #include <algorithm> |
33 #include <iterator> | 33 #include <iterator> |
34 #include <utility> | 34 #include <utility> |
35 | 35 |
36 #include "base/command_line.h" | 36 #include "base/command_line.h" |
37 #include "base/hash.h" | 37 #include "base/hash.h" |
38 #include "base/json/json_writer.h" | 38 #include "base/json/json_writer.h" |
39 #include "base/location.h" | 39 #include "base/location.h" |
40 #include "base/metrics/field_trial.h" | 40 #include "base/metrics/field_trial.h" |
41 #include "base/single_thread_task_runner.h" | 41 #include "base/single_thread_task_runner.h" |
42 #include "base/stl_util.h" | 42 #include "base/stl_util.h" |
43 #include "base/strings/string_number_conversions.h" | 43 #include "base/strings/string_number_conversions.h" |
44 #include "base/strings/stringprintf.h" | 44 #include "base/strings/stringprintf.h" |
45 #include "base/threading/thread_task_runner_handle.h" | 45 #include "base/threading/thread_task_runner_handle.h" |
46 #include "base/values.h" | 46 #include "base/values.h" |
47 #include "chrome/browser/spellchecker/word_trimmer.h" | |
48 #include "components/data_use_measurement/core/data_use_user_data.h" | 47 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 48 #include "components/spellcheck/browser/word_trimmer.h" |
49 #include "components/spellcheck/common/spellcheck_common.h" | 49 #include "components/spellcheck/common/spellcheck_common.h" |
50 #include "components/spellcheck/common/spellcheck_marker.h" | 50 #include "components/spellcheck/common/spellcheck_marker.h" |
51 #include "components/spellcheck/common/spellcheck_messages.h" | 51 #include "components/spellcheck/common/spellcheck_messages.h" |
52 #include "components/spellcheck/common/spellcheck_switches.h" | 52 #include "components/spellcheck/common/spellcheck_switches.h" |
53 #include "content/public/browser/render_process_host.h" | 53 #include "content/public/browser/render_process_host.h" |
54 #include "crypto/random.h" | 54 #include "crypto/random.h" |
55 #include "crypto/secure_hash.h" | 55 #include "crypto/secure_hash.h" |
56 #include "crypto/sha2.h" | 56 #include "crypto/sha2.h" |
57 #include "google_apis/google_api_keys.h" | 57 #include "google_apis/google_api_keys.h" |
58 #include "net/base/load_flags.h" | 58 #include "net/base/load_flags.h" |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 senders_.push_back(sender); | 452 senders_.push_back(sender); |
453 | 453 |
454 // Request context is nullptr in testing. | 454 // Request context is nullptr in testing. |
455 if (request_context_.get()) { | 455 if (request_context_.get()) { |
456 sender->SetRequestContext(request_context_.get()); | 456 sender->SetRequestContext(request_context_.get()); |
457 sender->Start(); | 457 sender->Start(); |
458 } | 458 } |
459 } | 459 } |
460 | 460 |
461 } // namespace spellcheck | 461 } // namespace spellcheck |
OLD | NEW |