| Index: chrome/browser/extensions/api/web_navigation/frame_navigation_state.h
|
| diff --git a/chrome/browser/extensions/api/web_navigation/frame_navigation_state.h b/chrome/browser/extensions/api/web_navigation/frame_navigation_state.h
|
| index 0f2823ce182ff29acdc6172c706f992d62dc181e..ffa0df04bf313f8ce7d2d63efec928fe015bc0c4 100644
|
| --- a/chrome/browser/extensions/api/web_navigation/frame_navigation_state.h
|
| +++ b/chrome/browser/extensions/api/web_navigation/frame_navigation_state.h
|
| @@ -12,111 +12,93 @@
|
| #include "url/gurl.h"
|
|
|
| namespace content {
|
| +class RenderFrameHost;
|
| class RenderViewHost;
|
| }
|
|
|
| namespace extensions {
|
|
|
| -// Tracks the navigation state of all frames in a given tab currently known to
|
| -// the webNavigation API. It is mainly used to track in which frames an error
|
| +// Tracks the navigation state of all frame hosts in a given tab currently known
|
| +// to the webNavigation API. It is mainly used to track in which frames an error
|
| // occurred so no further events for this frame are being sent.
|
| class FrameNavigationState {
|
| public:
|
| - // A frame is uniquely identified by its frame ID and the RVH it's in.
|
| - struct FrameID {
|
| - FrameID();
|
| - FrameID(int64 frame_num, content::RenderViewHost* render_view_host);
|
| -
|
| - bool operator<(const FrameID& other) const;
|
| - bool operator==(const FrameID& other) const;
|
| - bool operator!=(const FrameID& other) const;
|
| -
|
| - int64 frame_num;
|
| - content::RenderViewHost* render_view_host;
|
| - };
|
| - typedef std::set<FrameID>::const_iterator const_iterator;
|
| + typedef std::set<content::RenderFrameHost*>::const_iterator const_iterator;
|
|
|
| FrameNavigationState();
|
| ~FrameNavigationState();
|
|
|
| - // Use these to iterate over all frame IDs known by this object.
|
| - const_iterator begin() const { return frame_ids_.begin(); }
|
| - const_iterator end() const { return frame_ids_.end(); }
|
| + // Use these to iterate over all frame hosts known by this object.
|
| + const_iterator begin() const { return frame_hosts_.begin(); }
|
| + const_iterator end() const { return frame_hosts_.end(); }
|
|
|
| // True if navigation events for the given frame can be sent.
|
| - bool CanSendEvents(FrameID frame_id) const;
|
| + bool CanSendEvents(content::RenderFrameHost* frame_host) const;
|
|
|
| + // TODO(dcheng): This should be static.
|
| // True if in general webNavigation events may be sent for the given URL.
|
| bool IsValidUrl(const GURL& url) const;
|
|
|
| - // Starts to track a frame identified by its |frame_id| showing the URL |url|.
|
| - void TrackFrame(FrameID frame_id,
|
| - FrameID parent_frame_id,
|
| + // Starts to track a |frame_host| showing the URL |url|.
|
| + void TrackFrame(content::RenderFrameHost* frame_host,
|
| const GURL& url,
|
| - bool is_main_frame,
|
| bool is_error_page,
|
| bool is_iframe_srcdoc);
|
|
|
| - // Marks the frame as detached and stops tracking it.
|
| - void FrameDetached(FrameID frame_id);
|
| + // Marks |frame_host| as detached and stops tracking it.
|
| + void FrameDetached(content::RenderFrameHost* frame_host);
|
|
|
| - // Stops tracking all frames but the frame with |id_to_skip| for a given
|
| - // RenderViewHost.
|
| + // Stops tracking all frame hosts but |frame_host_to_skip| in
|
| + // |render_view_host|.
|
| void StopTrackingFramesInRVH(content::RenderViewHost* render_view_host,
|
| - FrameID id_to_skip);
|
| + content::RenderFrameHost* frame_host_to_skip);
|
|
|
| - // Update the URL associated with a given frame.
|
| - void UpdateFrame(FrameID frame_id, const GURL& url);
|
| + // Update the URL associated with |frame_host|.
|
| + void UpdateFrame(content::RenderFrameHost* frame_host, const GURL& url);
|
|
|
| - // Returns true if |frame_id| is a known frame.
|
| - bool IsValidFrame(FrameID frame_id) const;
|
| + // Returns true if |frame_host| is a known frame host.
|
| + bool IsValidFrame(content::RenderFrameHost* frame_host) const;
|
|
|
| - // Returns the URL corresponding to a tracked frame given by its |frame_id|.
|
| - GURL GetUrl(FrameID frame_id) const;
|
| + // Returns the URL corresponding to a tracked |frame_host|.
|
| + // TODO(dcheng): Why is this needed? Can't this information be extracted from
|
| + // RenderFrameHost?
|
| + GURL GetUrl(content::RenderFrameHost* frame_host) const;
|
|
|
| - // True if the frame given by its |frame_id| is a main frame of its tab.
|
| - // There might be multiple uncomitted main frames.
|
| - bool IsMainFrame(FrameID frame_id) const;
|
| + // Returns a pointer to the last comitted main frame host.
|
| + content::RenderFrameHost* GetLastCommittedMainFrameHost() const;
|
|
|
| - // Returns the frame ID of the last comitted main frame, or -1 if the frame
|
| - // ID is not known.
|
| - FrameID GetMainFrameID() const;
|
| + // Marks |frame_host| as in an error state, i.e. the onErrorOccurred event was
|
| + // fired for it, and no further events should be sent for it.
|
| + void SetErrorOccurredInFrame(content::RenderFrameHost* frame_host);
|
|
|
| - // Get the parent frame ID (or an invalid ID, if |frame_id| is a main frame).
|
| - FrameID GetParentFrameID(FrameID frame_id) const;
|
| + // True if |frame_host| is marked as being in an error state.
|
| + bool GetErrorOccurredInFrame(content::RenderFrameHost* frame_host) const;
|
|
|
| - // Marks a frame as in an error state, i.e. the onErrorOccurred event was
|
| - // fired for this frame, and no further events should be sent for it.
|
| - void SetErrorOccurredInFrame(FrameID frame_id);
|
| -
|
| - // True if the frame is marked as being in an error state.
|
| - bool GetErrorOccurredInFrame(FrameID frame_id) const;
|
| -
|
| - // Marks a frame as having finished its last navigation, i.e. the onCompleted
|
| - // event was fired for this frame.
|
| - void SetNavigationCompleted(FrameID frame_id);
|
| + // Marks |frame_host| as having finished its last navigation, i.e. the
|
| + // onCompleted event was fired for this frame.
|
| + void SetNavigationCompleted(content::RenderFrameHost* frame_host);
|
|
|
| - // True if the frame is currently not navigating.
|
| - bool GetNavigationCompleted(FrameID frame_id) const;
|
| + // True if |frame_host| is currently not navigating.
|
| + bool GetNavigationCompleted(content::RenderFrameHost* frame_host) const;
|
|
|
| - // Marks a frame as having finished parsing.
|
| - void SetParsingFinished(FrameID frame_id);
|
| + // Marks |frame_host| as having finished parsing.
|
| + void SetParsingFinished(content::RenderFrameHost* frame_host);
|
|
|
| - // True if the frame has finished parsing.
|
| - bool GetParsingFinished(FrameID frame_id) const;
|
| + // True if |frame_host| has finished parsing.
|
| + bool GetParsingFinished(content::RenderFrameHost* frame_host) const;
|
|
|
| - // Marks a frame as having committed its navigation, i.e. the onCommitted
|
| + // Marks |frame_host| as having committed its navigation, i.e. the onCommitted
|
| // event was fired for this frame.
|
| - void SetNavigationCommitted(FrameID frame_id);
|
| + void SetNavigationCommitted(content::RenderFrameHost* frame_host);
|
|
|
| - // True if the frame has committed its navigation.
|
| - bool GetNavigationCommitted(FrameID frame_id) const;
|
| + // True if |frame_host| has committed its navigation.
|
| + bool GetNavigationCommitted(content::RenderFrameHost* frame_host) const;
|
|
|
| - // Marks a frame as redirected by the server.
|
| - void SetIsServerRedirected(FrameID frame_id);
|
| + // Marks |frame_host| as redirected by the server.
|
| + void SetIsServerRedirected(content::RenderFrameHost* frame_host);
|
|
|
| - // True if the frame was redirected by the server.
|
| - bool GetIsServerRedirected(FrameID frame_id) const;
|
| + // True if |frame_host| was redirected by the server.
|
| + bool GetIsServerRedirected(content::RenderFrameHost* frame_host) const;
|
|
|
| #ifdef UNIT_TEST
|
| static void set_allow_extension_scheme(bool allow_extension_scheme) {
|
| @@ -129,25 +111,23 @@ class FrameNavigationState {
|
| FrameState();
|
|
|
| bool error_occurred; // True if an error has occurred in this frame.
|
| - bool is_main_frame; // True if this is a main frame.
|
| bool is_iframe_srcdoc; // True if the frame is displaying its srcdoc.
|
| bool is_navigating; // True if there is a navigation going on.
|
| bool is_committed; // True if the navigation is already committed.
|
| bool is_server_redirected; // True if a server redirect happened.
|
| bool is_parsing; // True if the frame is still parsing.
|
| - int64 parent_frame_num;
|
| GURL url; // URL of this frame.
|
| };
|
| - typedef std::map<FrameID, FrameState> FrameIdToStateMap;
|
| + typedef std::map<content::RenderFrameHost*, FrameState> FrameHostToStateMap;
|
|
|
| - // Tracks the state of known frames.
|
| - FrameIdToStateMap frame_state_map_;
|
| + // Tracks the state of known frame hosts.
|
| + FrameHostToStateMap frame_host_state_map_;
|
|
|
| - // Set of all known frames.
|
| - std::set<FrameID> frame_ids_;
|
| + // Set of all known frame hosts.
|
| + std::set<content::RenderFrameHost*> frame_hosts_;
|
|
|
| - // The id of the last comitted main frame.
|
| - FrameID main_frame_id_;
|
| + // The last comitted main frame.
|
| + content::RenderFrameHost* main_frame_host_;
|
|
|
| // If true, also allow events from chrome-extension:// URLs.
|
| static bool allow_extension_scheme_;
|
|
|