Chromium Code Reviews| Index: chrome/renderer/render_view.h |
| =================================================================== |
| --- chrome/renderer/render_view.h (revision 71253) |
| +++ chrome/renderer/render_view.h (working copy) |
| @@ -35,7 +35,6 @@ |
| #include "chrome/renderer/renderer_webcookiejar_impl.h" |
| #include "chrome/renderer/searchbox.h" |
| #include "chrome/renderer/translate_helper.h" |
| -#include "third_party/WebKit/WebKit/chromium/public/WebAutoFillClient.h" |
| #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" |
| #include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h" |
| #include "third_party/WebKit/WebKit/chromium/public/WebFrameClient.h" |
| @@ -55,7 +54,6 @@ |
| #endif |
| class AudioMessageFilter; |
| -class AutoFillHelper; |
| class BlockedPlugin; |
| class CustomMenuListener; |
| class DictionaryValue; |
| @@ -73,8 +71,6 @@ |
| class LoadProgressTracker; |
| class NavigationState; |
| class NotificationProvider; |
| -class PageClickTracker; |
| -class PasswordAutocompleteManager; |
| class PepperDeviceTest; |
| class PrintWebViewHelper; |
| class RenderViewVisitor; |
| @@ -174,13 +170,54 @@ |
| // communication interface with an embedding application process |
| // |
| class RenderView : public RenderWidget, |
| - public WebKit::WebAutoFillClient, |
| public WebKit::WebViewClient, |
| public WebKit::WebFrameClient, |
| public WebKit::WebPageSerializerClient, |
| public webkit::npapi::WebPluginPageDelegate, |
| public base::SupportsWeakPtr<RenderView> { |
| public: |
| + // Base class for objects that want to filter incoming IPCs, and also get |
| + // notified of changes to the frame. |
| + class Observer : public IPC::Channel::Listener, |
|
brettw
2011/01/14 02:20:05
Personally, I would split this out into a separate
|
| + public IPC::Message::Sender { |
| + public: |
| + // By default, observers will be deleted when the RenderView goes away. If |
| + // they want to outlive it, they can override this function. |
| + virtual void OnDestruct(); |
| + |
| + // These match the WebKit API notifications. |
| + virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) {} |
| + virtual void DidFinishLoad(WebKit::WebFrame* frame) {} |
| + virtual void FrameDetached(WebKit::WebFrame* frame) {} |
| + virtual void FrameWillClose(WebKit::WebFrame* frame) {} |
| + |
| + // These match the RenderView methods below. |
| + virtual void FrameTranslated(WebKit::WebFrame* frame) {} |
| + virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event) {} |
| + |
| + protected: |
| + Observer(RenderView* render_view); |
| + virtual ~Observer(); |
| + |
| + // IPC::Channel::Listener implementation. |
| + virtual bool OnMessageReceived(const IPC::Message& message); |
| + |
| + // IPC::Message::Sender implementation. |
| + virtual bool Send(IPC::Message* message); |
| + |
| + RenderView* render_view() { return render_view_; } |
| + int routing_id() { return routing_id_; } |
| + |
| + private: |
| + friend class RenderView; |
| + |
| + void set_render_view(RenderView* rv) { render_view_ = rv; } |
| + |
| + RenderView* render_view_; |
| + // The routing ID of the associated RenderView. |
| + int routing_id_; |
| + }; |
| + |
| // Creates a new RenderView. The parent_hwnd specifies a HWND to use as the |
| // parent of the WebView HWND that will be created. If this is a constrained |
| // popup or as a new tab, opener_id is the routing ID of the RenderView |
| @@ -239,10 +276,6 @@ |
| send_content_state_immediately_ = value; |
| } |
| - PageClickTracker* page_click_tracker() const { |
| - return page_click_tracker_.get(); |
| - } |
| - |
| // May be NULL if client-side phishing detection is disabled. |
| safe_browsing::PhishingClassifierDelegate* |
| phishing_classifier_delegate() const { |
| @@ -261,6 +294,10 @@ |
| return search_box_; |
| } |
| + // Functions to add and remove observers for this object. |
| + void AddObserver(Observer* observer); |
| + void RemoveObserver(Observer* observer); |
| + |
| // Called from JavaScript window.external.AddSearchProvider() to add a |
| // keyword for a provider described in the given OpenSearch document. |
| void AddSearchProvider(const std::string& url, |
| @@ -397,30 +434,6 @@ |
| virtual bool OnMessageReceived(const IPC::Message& msg); |
| - // WebKit::WebAutoFillClient implementation ---------------------------------- |
| - virtual void didAcceptAutoFillSuggestion(const WebKit::WebNode& node, |
| - const WebKit::WebString& value, |
| - const WebKit::WebString& label, |
| - int unique_id, |
| - unsigned index); |
| - virtual void didSelectAutoFillSuggestion(const WebKit::WebNode& node, |
| - const WebKit::WebString& value, |
| - const WebKit::WebString& label, |
| - int unique_id); |
| - virtual void didClearAutoFillSelection(const WebKit::WebNode& node); |
| - virtual void didAcceptAutocompleteSuggestion( |
| - const WebKit::WebInputElement& element); |
| - virtual void removeAutocompleteSuggestion(const WebKit::WebString& name, |
| - const WebKit::WebString& value); |
| - // TODO(jam): remove this function after WebKit roll |
| - virtual void removeAutofillSuggestions(const WebKit::WebString& name, |
| - const WebKit::WebString& value); |
| - virtual void textFieldDidEndEditing(const WebKit::WebInputElement& element); |
| - virtual void textFieldDidChange(const WebKit::WebInputElement& element); |
| - virtual void textFieldDidReceiveKeyDown( |
| - const WebKit::WebInputElement& element, |
| - const WebKit::WebKeyboardEvent& event); |
| - |
| // WebKit::WebWidgetClient implementation ------------------------------------ |
| // Most methods are handled by RenderWidget. |
| @@ -753,22 +766,18 @@ |
| }; |
| RenderView(RenderThreadBase* render_thread, |
| - const WebPreferences& webkit_preferences, |
| - int64 session_storage_namespace_id); |
| + gfx::NativeViewId parent_hwnd, |
| + int32 opener_id, |
| + const RendererPreferences& renderer_prefs, |
| + const WebPreferences& webkit_prefs, |
| + SharedRenderViewCounter* counter, |
| + int32 routing_id, |
| + int64 session_storage_namespace_id, |
| + const string16& frame_name); |
| // Do not delete directly. This class is reference counted. |
| virtual ~RenderView(); |
| - // Initializes this view with the given parent and ID. The |routing_id| can be |
| - // set to 'MSG_ROUTING_NONE' if the true ID is not yet known. In this case, |
| - // CompleteInit must be called later with the true ID. |
| - void Init(gfx::NativeViewId parent, |
| - int32 opener_id, |
| - const RendererPreferences& renderer_prefs, |
| - SharedRenderViewCounter* counter, |
| - int32 routing_id, |
| - const string16& frame_name); |
| - |
| void UpdateURL(WebKit::WebFrame* frame); |
| void UpdateTitle(WebKit::WebFrame* frame, const string16& title); |
| void UpdateSessionHistory(WebKit::WebFrame* frame); |
| @@ -826,10 +835,6 @@ |
| void AddGURLSearchProvider(const GURL& osd_url, |
| const ViewHostMsg_PageHasOSDD_Type& provider_type); |
| - // Called in a posted task by textFieldDidChange() to work-around a WebKit bug |
| - // http://bugs.webkit.org/show_bug.cgi?id=16976 |
| - void TextFieldDidChangeImpl(const WebKit::WebInputElement& element); |
| - |
| // Send queued accessibility notifications from the renderer to the browser. |
| void SendPendingAccessibilityNotifications(); |
| @@ -849,18 +854,6 @@ |
| void OnAsyncFileOpened(base::PlatformFileError error_code, |
| IPC::PlatformFileForTransit file_for_transit, |
| int message_id); |
| - void OnAutocompleteSuggestionsReturned( |
| - int query_id, |
| - const std::vector<string16>& suggestions, |
| - int default_suggestions_index); |
| - void OnAutoFillFormDataFilled(int query_id, |
| - const webkit_glue::FormData& form); |
| - void OnAutoFillSuggestionsReturned( |
| - int query_id, |
| - const std::vector<string16>& values, |
| - const std::vector<string16>& labels, |
| - const std::vector<string16>& icons, |
| - const std::vector<int>& unique_ids); |
| void OnCancelDownload(int32 download_id); |
| void OnClearFocusedNode(); |
| void OnClosePage(const ViewMsg_ClosePage_Params& params); |
| @@ -939,8 +932,6 @@ |
| void OnMoveOrResizeStarted(); |
| void OnNavigate(const ViewMsg_Navigate_Params& params); |
| void OnNotifyRendererViewType(ViewType::Type view_type); |
| - void OnFillPasswordForm( |
| - const webkit_glue::PasswordFormFillData& form_data); |
| void OnPaste(); |
| #if defined(OS_MACOSX) |
| void OnPluginImeCompositionConfirmed(const string16& text, int plugin_id); |
| @@ -1376,46 +1367,41 @@ |
| // Helper objects ------------------------------------------------------------ |
| ScopedRunnableMethodFactory<RenderView> page_info_method_factory_; |
| - ScopedRunnableMethodFactory<RenderView> autofill_method_factory_; |
| ScopedRunnableMethodFactory<RenderView> accessibility_method_factory_; |
| // Responsible for translating the page contents to other languages. |
| TranslateHelper translate_helper_; |
| - // Responsible for automatically filling login and password textfields. |
| - scoped_ptr<PasswordAutocompleteManager> password_autocomplete_manager_; |
| - |
| - // Responsible for filling forms (AutoFill) and single text entries |
| - // (Autocomplete). |
| - scoped_ptr<AutoFillHelper> autofill_helper_; |
| - |
| - // Tracks when text input controls get clicked. |
| - // IMPORTANT: this should be declared after autofill_helper_ and |
| - // password_autocomplete_manager_ so the tracker is deleted first (so we won't |
| - // run the risk of notifying deleted objects). |
| - scoped_ptr<PageClickTracker> page_click_tracker_; |
| - |
| RendererWebCookieJarImpl cookie_jar_; |
| + // The next group of objects all implement Observer, so are deleted along with |
| + // the RenderView automatically. This is why we just store weak references. |
| + |
| // Provides access to this renderer from the remote Inspector UI. |
| - scoped_ptr<DevToolsAgent> devtools_agent_; |
| + DevToolsAgent* devtools_agent_; |
| // DevToolsClient for renderer hosting developer tools UI. It's NULL for other |
| // render views. |
| - scoped_ptr<DevToolsClient> devtools_client_; |
| + DevToolsClient* devtools_client_; |
| // Holds a reference to the service which provides desktop notifications. |
| - scoped_ptr<NotificationProvider> notification_provider_; |
| + NotificationProvider* notification_provider_; |
| + // The geolocation dispatcher attached to this view, lazily initialized. |
| + GeolocationDispatcher* geolocation_dispatcher_; |
| + |
| + // The speech dispatcher attached to this view, lazily initialized. |
| + SpeechInputDispatcher* speech_input_dispatcher_; |
| + |
| + // Device orientation dispatcher attached to this view; lazily initialized. |
| + DeviceOrientationDispatcher* device_orientation_dispatcher_; |
| + |
| // PrintWebViewHelper handles printing. Note that this object is constructed |
| // when printing for the first time but only destroyed with the RenderView. |
| scoped_ptr<PrintWebViewHelper> print_helper_; |
| scoped_refptr<AudioMessageFilter> audio_message_filter_; |
| - // The geolocation dispatcher attached to this view, lazily initialized. |
| - scoped_ptr<GeolocationDispatcher> geolocation_dispatcher_; |
| - |
| // Handles accessibility requests into the renderer side, as well as |
| // maintains the cache and other features of the accessibility tree. |
| scoped_ptr<WebKit::WebAccessibilityCache> accessibility_; |
| @@ -1428,12 +1414,6 @@ |
| // Set if we are waiting for a accessibility notification ack. |
| bool accessibility_ack_pending_; |
| - // The speech dispatcher attached to this view, lazily initialized. |
| - scoped_ptr<SpeechInputDispatcher> speech_input_dispatcher_; |
| - |
| - // Device orientation dispatcher attached to this view; lazily initialized. |
| - scoped_ptr<DeviceOrientationDispatcher> device_orientation_dispatcher_; |
| - |
| // Responsible for sending page load related histograms. |
| PageLoadHistograms page_load_histograms_; |
| @@ -1519,11 +1499,17 @@ |
| // Reports load progress to the browser. |
| scoped_ptr<LoadProgressTracker> load_progress_tracker_; |
| + // All the registered observers. We expect this list to be small, so vector |
| + // is fine. |
| + std::vector<Observer*> observers_; |
| + |
| // --------------------------------------------------------------------------- |
| // ADDING NEW DATA? Please see if it fits appropriately in one of the above |
| // sections rather than throwing it randomly at the end. If you're adding a |
| // bunch of stuff, you should probably create a helper class and put your |
| - // data and methods on that to avoid bloating RenderView more. |
| + // data and methods on that to avoid bloating RenderView more. You can use |
| + // the Observer interface to filter IPC messages and receive frame change |
| + // notifications. |
| // --------------------------------------------------------------------------- |
| DISALLOW_COPY_AND_ASSIGN(RenderView); |