// Copyright 2014 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_RENDERER_CONTEXT_MENU_SPELLING_MENU_OBSERVER_H_ #define CHROME_BROWSER_RENDERER_CONTEXT_MENU_SPELLING_MENU_OBSERVER_H_ #include <stddef.h> #include <stdint.h> #include <memory> #include <string> #include <vector> #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/timer/timer.h" #include "build/build_config.h" #include "components/prefs/pref_member.h" #include "components/renderer_context_menu/render_view_context_menu_observer.h" #include "components/spellcheck/browser/spelling_service_client.h" #include "components/spellcheck/common/spellcheck_common.h" #include "components/spellcheck/spellcheck_buildflags.h" class RenderViewContextMenuProxy; struct SpellCheckResult; // An observer that listens to events from the RenderViewContextMenu class and // shows suggestions from the Spelling ("do you mean") service to a context menu // while we show it. This class implements two interfaces: // * RenderViewContextMenuObserver // This interface is used for adding a menu item and update it while showing. // * net::URLFetcherDelegate // This interface is used for sending a JSON_RPC request to the Spelling // service and retrieving its response. // These interfaces allow this class to make a JSON-RPC call to the Spelling // service in the background and update the context menu while showing. The // following snippet describes how to add this class to the observer list of the // RenderViewContextMenu class. // // void RenderViewContextMenu::InitMenu() { // spelling_menu_observer_.reset(new SpellingMenuObserver(this)); // if (spelling_menu_observer_.get()) // observers_.AddObserver(spelling_menu_observer.get()); // } // class SpellingMenuObserver : public RenderViewContextMenuObserver { … }; #endif // CHROME_BROWSER_RENDERER_CONTEXT_MENU_SPELLING_MENU_OBSERVER_H_