Chromium Code Reviews| 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 #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 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/prefs/public/pref_member.h" | 12 #include "base/prefs/public/pref_member.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/timer.h" | 14 #include "base/timer.h" |
| 15 #include "chrome/browser/spellchecker/spelling_service_client.h" | |
|
groby-ooo-7-16
2012/12/21 22:18:13
Prebinding of type would allow us to get rid of th
rpetterson
2013/01/04 00:05:34
Unfortunately not since we still need to include t
| |
| 15 #include "chrome/browser/tab_contents/render_view_context_menu_observer.h" | 16 #include "chrome/browser/tab_contents/render_view_context_menu_observer.h" |
| 16 | 17 |
| 17 class RenderViewContextMenuProxy; | 18 class RenderViewContextMenuProxy; |
| 18 struct SpellCheckResult; | 19 struct SpellCheckResult; |
| 19 class SpellingServiceClient; | |
| 20 | 20 |
| 21 // An observer that listens to events from the RenderViewContextMenu class and | 21 // An observer that listens to events from the RenderViewContextMenu class and |
| 22 // shows suggestions from the Spelling ("do you mean") service to a context menu | 22 // shows suggestions from the Spelling ("do you mean") service to a context menu |
| 23 // while we show it. This class implements two interfaces: | 23 // while we show it. This class implements two interfaces: |
| 24 // * RenderViewContextMenuObserver | 24 // * RenderViewContextMenuObserver |
| 25 // This interface is used for adding a menu item and update it while showing. | 25 // This interface is used for adding a menu item and update it while showing. |
| 26 // * net::URLFetcherDelegate | 26 // * net::URLFetcherDelegate |
| 27 // This interface is used for sending a JSON_RPC request to the Spelling | 27 // This interface is used for sending a JSON_RPC request to the Spelling |
| 28 // service and retrieving its response. | 28 // service and retrieving its response. |
| 29 // These interfaces allow this class to make a JSON-RPC call to the Spelling | 29 // These interfaces allow this class to make a JSON-RPC call to the Spelling |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 47 virtual bool IsCommandIdSupported(int command_id) OVERRIDE; | 47 virtual bool IsCommandIdSupported(int command_id) OVERRIDE; |
| 48 virtual bool IsCommandIdChecked(int command_id) OVERRIDE; | 48 virtual bool IsCommandIdChecked(int command_id) OVERRIDE; |
| 49 virtual bool IsCommandIdEnabled(int command_id) OVERRIDE; | 49 virtual bool IsCommandIdEnabled(int command_id) OVERRIDE; |
| 50 virtual void ExecuteCommand(int command_id) OVERRIDE; | 50 virtual void ExecuteCommand(int command_id) OVERRIDE; |
| 51 | 51 |
| 52 // A callback function called when the Spelling service finishes checking a | 52 // A callback function called when the Spelling service finishes checking a |
| 53 // misspelled word. | 53 // misspelled word. |
| 54 void OnTextCheckComplete( | 54 void OnTextCheckComplete( |
| 55 int tag, | 55 int tag, |
| 56 bool success, | 56 bool success, |
| 57 SpellingServiceClient::ServiceType type, | |
| 57 const string16& text, | 58 const string16& text, |
| 58 const std::vector<SpellCheckResult>& results); | 59 const std::vector<SpellCheckResult>& results); |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 // The callback function for base::RepeatingTimer<SpellingMenuClient>. This | 62 // The callback function for base::RepeatingTimer<SpellingMenuClient>. This |
| 62 // function updates the "loading..." animation in the context-menu item. | 63 // function updates the "loading..." animation in the context-menu item. |
| 63 void OnAnimationTimerExpired(); | 64 void OnAnimationTimerExpired(); |
| 64 | 65 |
| 65 // The interface to add a context-menu item and update it. This class uses | 66 // The interface to add a context-menu item and update it. This class uses |
| 66 // this interface to avoid accesing context-menu items directly. | 67 // this interface to avoid accesing context-menu items directly. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 | 104 |
| 104 // Flag indicating whether online spelling correction service is enabled. When | 105 // Flag indicating whether online spelling correction service is enabled. When |
| 105 // this variable is true and we right-click a misspelled word, we send a | 106 // this variable is true and we right-click a misspelled word, we send a |
| 106 // JSON-RPC request to the service and retrieve suggestions. | 107 // JSON-RPC request to the service and retrieve suggestions. |
| 107 BooleanPrefMember integrate_spelling_service_; | 108 BooleanPrefMember integrate_spelling_service_; |
| 108 | 109 |
| 109 DISALLOW_COPY_AND_ASSIGN(SpellingMenuObserver); | 110 DISALLOW_COPY_AND_ASSIGN(SpellingMenuObserver); |
| 110 }; | 111 }; |
| 111 | 112 |
| 112 #endif // CHROME_BROWSER_TAB_CONTENTS_SPELLING_MENU_OBSERVER_H_ | 113 #endif // CHROME_BROWSER_TAB_CONTENTS_SPELLING_MENU_OBSERVER_H_ |
| OLD | NEW |