OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_TAB_CONTENTS_SPELLING_MENU_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_SPELLING_MENU_OBSERVER_H_ |
6 #define CHROME_BROWSER_TAB_CONTENTS_SPELLING_MENU_OBSERVER_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_SPELLING_MENU_OBSERVER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
10 | 11 |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/string16.h" | 13 #include "base/string16.h" |
13 #include "base/timer.h" | 14 #include "base/timer.h" |
14 #include "chrome/browser/tab_contents/render_view_context_menu_observer.h" | 15 #include "chrome/browser/tab_contents/render_view_context_menu_observer.h" |
15 #include "content/public/common/url_fetcher_delegate.h" | 16 #include "content/public/common/url_fetcher_delegate.h" |
16 | 17 |
17 class GURL; | 18 class GURL; |
18 class RenderViewContextMenuProxy; | 19 class RenderViewContextMenuProxy; |
19 | 20 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 bool ParseResponse(int code, const std::string& data); | 68 bool ParseResponse(int code, const std::string& data); |
68 | 69 |
69 // The callback function for base::RepeatingTimer<SpellingMenuClient>. This | 70 // The callback function for base::RepeatingTimer<SpellingMenuClient>. This |
70 // function updates the "loading..." animation in the context-menu item. | 71 // function updates the "loading..." animation in the context-menu item. |
71 void OnAnimationTimerExpired(); | 72 void OnAnimationTimerExpired(); |
72 | 73 |
73 // The interface to add a context-menu item and update it. This class uses | 74 // The interface to add a context-menu item and update it. This class uses |
74 // this interface to avoid accesing context-menu items directly. | 75 // this interface to avoid accesing context-menu items directly. |
75 RenderViewContextMenuProxy* proxy_; | 76 RenderViewContextMenuProxy* proxy_; |
76 | 77 |
| 78 // Suggested words from the local spellchecker. If the spelling service |
| 79 // returns a word in this list, we hide the context-menu item to prevent |
| 80 // showing the same word twice. |
| 81 std::vector<string16> suggestions_; |
| 82 |
77 // The string used for animation until we receive a response from the Spelling | 83 // The string used for animation until we receive a response from the Spelling |
78 // service. The current animation just adds periods at the end of this string: | 84 // service. The current animation just adds periods at the end of this string: |
79 // 'Loading' -> 'Loading.' -> 'Loading..' -> 'Loading...' (-> 'Loading') | 85 // 'Loading' -> 'Loading.' -> 'Loading..' -> 'Loading...' (-> 'Loading') |
80 string16 loading_message_; | 86 string16 loading_message_; |
81 int loading_frame_; | 87 int loading_frame_; |
82 | 88 |
83 // A flag represending whether this call finished successfully. This means we | 89 // A flag represending whether this call finished successfully. This means we |
84 // receive an empty JSON string or a JSON string that consists of misspelled | 90 // receive an empty JSON string or a JSON string that consists of misspelled |
85 // words. ('spelling_menu_observer.cc' describes its format.) | 91 // words. ('spelling_menu_observer.cc' describes its format.) |
86 bool succeeded_; | 92 bool succeeded_; |
87 | 93 |
88 // The string representing the result of this call. This string is a | 94 // The string representing the result of this call. This string is a |
89 // suggestion when this call finished successfully. Otherwise it is error | 95 // suggestion when this call finished successfully. Otherwise it is error |
90 // text. Until we receive a response from the Spelling service, this string | 96 // text. Until we receive a response from the Spelling service, this string |
91 // stores the input string. (Since the Spelling service sends only misspelled | 97 // stores the input string. (Since the Spelling service sends only misspelled |
92 // words, we replace these misspelled words in the input text with the | 98 // words, we replace these misspelled words in the input text with the |
93 // suggested words to create suggestion text. | 99 // suggested words to create suggestion text. |
94 string16 result_; | 100 string16 result_; |
95 | 101 |
96 // The URLFetcher object used for sending a JSON-RPC request. | 102 // The URLFetcher object used for sending a JSON-RPC request. |
97 scoped_ptr<content::URLFetcher> fetcher_; | 103 scoped_ptr<content::URLFetcher> fetcher_; |
98 | 104 |
99 // A timer used for loading animation. | 105 // A timer used for loading animation. |
100 base::RepeatingTimer<SpellingMenuObserver> animation_timer_; | 106 base::RepeatingTimer<SpellingMenuObserver> animation_timer_; |
101 | 107 |
102 DISALLOW_COPY_AND_ASSIGN(SpellingMenuObserver); | 108 DISALLOW_COPY_AND_ASSIGN(SpellingMenuObserver); |
103 }; | 109 }; |
104 | 110 |
105 #endif // CHROME_BROWSER_TAB_CONTENTS_SPELLING_MENU_OBSERVER_H_ | 111 #endif // CHROME_BROWSER_TAB_CONTENTS_SPELLING_MENU_OBSERVER_H_ |
OLD | NEW |