Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(631)

Side by Side Diff: chrome/browser/extensions/api/web_navigation/frame_navigation_state.h

Issue 10808097: Revert 148074 - Pass the render process id to the FrameNavigationState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/web_navigation/frame_navigation_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_EXTENSIONS_API_WEB_NAVIGATION_FRAME_NAVIGATION_STATE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_FRAME_NAVIGATION_STATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_FRAME_NAVIGATION_STATE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_FRAME_NAVIGATION_STATE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 // Tracks the navigation state of all frames in a given tab currently known to 16 // Tracks the navigation state of all frames in a given tab currently known to
17 // the webNavigation API. It is mainly used to track in which frames an error 17 // the webNavigation API. It is mainly used to track in which frames an error
18 // occurred so no further events for this frame are being sent. 18 // occurred so no further events for this frame are being sent.
19 class FrameNavigationState { 19 class FrameNavigationState {
20 public: 20 public:
21 // A frame is uniquely identified by its frame ID and the render process ID. 21 typedef std::set<int64>::const_iterator const_iterator;
22 // We use the render process ID instead of e.g. a pointer to the RVH so we
23 // don't depend on the lifetime of the RVH.
24 struct FrameID {
25 FrameID();
26 FrameID(int64 frame_num, int render_process_id);
27 ~FrameID();
28
29 bool operator<(const FrameID& other) const;
30 bool operator==(const FrameID& other) const;
31 bool operator!=(const FrameID& other) const;
32
33 int64 frame_num;
34 int render_process_id;
35 };
36 typedef std::set<FrameID>::const_iterator const_iterator;
37
38 static FrameID kInvalidFrameID;
39 22
40 FrameNavigationState(); 23 FrameNavigationState();
41 ~FrameNavigationState(); 24 ~FrameNavigationState();
42 25
43 // Use these to iterate over all frame IDs known by this object. 26 // Use these to iterate over all frame IDs known by this object.
44 const_iterator begin() const { return frame_ids_.begin(); } 27 const_iterator begin() const { return frame_ids_.begin(); }
45 const_iterator end() const { return frame_ids_.end(); } 28 const_iterator end() const { return frame_ids_.end(); }
46 29
47 // True if navigation events for the given frame can be sent. 30 // True if navigation events for the given frame can be sent.
48 bool CanSendEvents(FrameID frame_id) const; 31 bool CanSendEvents(int64 frame_id) const;
49 32
50 // True if in general webNavigation events may be sent for the given URL. 33 // True if in general webNavigation events may be sent for the given URL.
51 bool IsValidUrl(const GURL& url) const; 34 bool IsValidUrl(const GURL& url) const;
52 35
53 // Starts to track a frame identified by its |frame_id| showing the URL |url|. 36 // Starts to track a frame identified by its |frame_id| showing the URL |url|.
54 void TrackFrame(FrameID frame_id, 37 void TrackFrame(int64 frame_id,
55 const GURL& url, 38 const GURL& url,
56 bool is_main_frame, 39 bool is_main_frame,
57 bool is_error_page); 40 bool is_error_page);
58 41
59 // Update the URL associated with a given frame. 42 // Update the URL associated with a given frame.
60 void UpdateFrame(FrameID frame_id, const GURL& url); 43 void UpdateFrame(int64 frame_id, const GURL& url);
61 44
62 // Returns true if |frame_id| is a known frame. 45 // Returns true if |frame_id| is a known frame.
63 bool IsValidFrame(FrameID frame_id) const; 46 bool IsValidFrame(int64 frame_id) const;
64 47
65 // Returns the URL corresponding to a tracked frame given by its |frame_id|. 48 // Returns the URL corresponding to a tracked frame given by its |frame_id|.
66 GURL GetUrl(FrameID frame_id) const; 49 GURL GetUrl(int64 frame_id) const;
67 50
68 // True if the frame given by its |frame_id| is the main frame of its tab. 51 // True if the frame given by its |frame_id| is the main frame of its tab.
69 bool IsMainFrame(FrameID frame_id) const; 52 bool IsMainFrame(int64 frame_id) const;
70 53
71 // Returns the frame ID of the main frame, or -1 if the frame ID is not 54 // Returns the frame ID of the main frame, or -1 if the frame ID is not
72 // known. 55 // known.
73 FrameID GetMainFrameID() const; 56 int64 GetMainFrameID() const;
74 57
75 // Marks a frame as in an error state, i.e. the onErrorOccurred event was 58 // Marks a frame as in an error state, i.e. the onErrorOccurred event was
76 // fired for this frame, and no further events should be sent for it. 59 // fired for this frame, and no further events should be sent for it.
77 void SetErrorOccurredInFrame(FrameID frame_id); 60 void SetErrorOccurredInFrame(int64 frame_id);
78 61
79 // True if the frame is marked as being in an error state. 62 // True if the frame is marked as being in an error state.
80 bool GetErrorOccurredInFrame(FrameID frame_id) const; 63 bool GetErrorOccurredInFrame(int64 frame_id) const;
81 64
82 // Marks a frame as having finished its last navigation, i.e. the onCompleted 65 // Marks a frame as having finished its last navigation, i.e. the onCompleted
83 // event was fired for this frame. 66 // event was fired for this frame.
84 void SetNavigationCompleted(FrameID frame_id); 67 void SetNavigationCompleted(int64 frame_id);
85 68
86 // True if the frame is currently not navigating. 69 // True if the frame is currently not navigating.
87 bool GetNavigationCompleted(FrameID frame_id) const; 70 bool GetNavigationCompleted(int64 frame_id) const;
88 71
89 // Marks a frame as having committed its navigation, i.e. the onCommitted 72 // Marks a frame as having committed its navigation, i.e. the onCommitted
90 // event was fired for this frame. 73 // event was fired for this frame.
91 void SetNavigationCommitted(FrameID frame_id); 74 void SetNavigationCommitted(int64 frame_id);
92 75
93 // True if the frame has committed its navigation. 76 // True if the frame has committed its navigation.
94 bool GetNavigationCommitted(FrameID frame_id) const; 77 bool GetNavigationCommitted(int64 frame_id) const;
95 78
96 // Marks a frame as redirected by the server. 79 // Marks a frame as redirected by the server.
97 void SetIsServerRedirected(FrameID frame_id); 80 void SetIsServerRedirected(int64 frame_id);
98 81
99 // True if the frame was redirected by the server. 82 // True if the frame was redirected by the server.
100 bool GetIsServerRedirected(FrameID frame_id) const; 83 bool GetIsServerRedirected(int64 frame_id) const;
101 84
102 #ifdef UNIT_TEST 85 #ifdef UNIT_TEST
103 static void set_allow_extension_scheme(bool allow_extension_scheme) { 86 static void set_allow_extension_scheme(bool allow_extension_scheme) {
104 allow_extension_scheme_ = allow_extension_scheme; 87 allow_extension_scheme_ = allow_extension_scheme;
105 } 88 }
106 #endif 89 #endif
107 90
108 private: 91 private:
109 struct FrameState { 92 struct FrameState {
110 bool error_occurred; // True if an error has occurred in this frame. 93 bool error_occurred; // True if an error has occurred in this frame.
111 bool is_main_frame; // True if this is a main frame. 94 bool is_main_frame; // True if this is a main frame.
112 bool is_navigating; // True if there is a navigation going on. 95 bool is_navigating; // True if there is a navigation going on.
113 bool is_committed; // True if the navigation is already committed. 96 bool is_committed; // True if the navigation is already committed.
114 bool is_server_redirected; // True if a server redirect happened. 97 bool is_server_redirected; // True if a server redirect happened.
115 GURL url; // URL of this frame. 98 GURL url; // URL of this frame.
116 }; 99 };
117 typedef std::map<FrameID, FrameState> FrameIdToStateMap; 100 typedef std::map<int64, FrameState> FrameIdToStateMap;
118 101
119 // Tracks the state of known frames. 102 // Tracks the state of known frames.
120 FrameIdToStateMap frame_state_map_; 103 FrameIdToStateMap frame_state_map_;
121 104
122 // Set of all known frames. 105 // Set of all known frames.
123 std::set<FrameID> frame_ids_; 106 std::set<int64> frame_ids_;
124 107
125 // The current main frame. 108 // The current main frame.
126 FrameID main_frame_id_; 109 int64 main_frame_id_;
127 110
128 // If true, also allow events from chrome-extension:// URLs. 111 // If true, also allow events from chrome-extension:// URLs.
129 static bool allow_extension_scheme_; 112 static bool allow_extension_scheme_;
130 113
131 DISALLOW_COPY_AND_ASSIGN(FrameNavigationState); 114 DISALLOW_COPY_AND_ASSIGN(FrameNavigationState);
132 }; 115 };
133 116
134 } // namespace extensions 117 } // namespace extensions
135 118
136 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_FRAME_NAVIGATION_STATE_H _ 119 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_NAVIGATION_FRAME_NAVIGATION_STATE_H _
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/web_navigation/frame_navigation_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698