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

Unified Diff: chrome/browser/extensions/extension_webnavigation_api.h

Issue 4136004: Track in which frames navigation errors occurred and don't send further navigation events for them (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/extensions
Patch Set: Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_webnavigation_api.h
diff --git a/chrome/browser/extensions/extension_webnavigation_api.h b/chrome/browser/extensions/extension_webnavigation_api.h
index 21cfb1606a8101372b058dbea8c7d55eb3bef1d8..0e75c2ff74f609cf02b7ffd3cf9b1637ed473089 100644
--- a/chrome/browser/extensions/extension_webnavigation_api.h
+++ b/chrome/browser/extensions/extension_webnavigation_api.h
@@ -22,6 +22,51 @@ class NavigationController;
class ProvisionalLoadDetails;
class TabContents;
+// Tracks which frames are in an error state, and no navigation events should
+// be sent for.
+class FrameNavigationState : public NotificationObserver {
yzshen 2010/10/27 17:43:38 1) The design says: For a specific *navigation*, t
jochen (gone - plz use gerrit) 2010/10/27 18:01:14 I think it works for that case :) I'll add a unit
+ public:
+ FrameNavigationState();
+ ~FrameNavigationState();
yzshen 2010/10/27 17:43:38 Please consider to add "virtual" for the destructo
jochen (gone - plz use gerrit) 2010/10/27 18:01:14 why? It'll just make the destructor call more expe
yzshen 2010/10/27 18:52:29 Since ~NotificationObserver is declared as "virtua
+
+ // True if navigation events for the given frame can be sent.
+ bool CanSendEvents(long long frame_id) const;
+
+ // Starts the track a frame given by its |frame_id| showing the URL |url| in
yzshen 2010/10/27 17:43:38 Do you mean "Starts to track"?
+ // a |tab_contents|.
+ void TrackFrame(long long frame_id,
+ const GURL& url,
+ bool is_main_frame,
+ const TabContents* tab_contents);
+
+ // Marks a frame as in an error state.
+ void ErrorOccurredInFrame(long long frame_id);
+
+ private:
+ typedef std::multimap<const TabContents*, long long> TabContentsToFrameIdMap;
+ typedef std::map<long long, bool> FrameIdToErrorStateMap;
+
+ // NotificationObserver implementation.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ // Remove state associated with this tab contents and all of its frames.
yzshen 2010/10/27 17:43:38 Remove -> Removes
+ void RemoveTabContentsState(const TabContents* tab_contents);
+
+ // Tracks which frames belong to a given tab contents object.
+ TabContentsToFrameIdMap tab_contents_map_;
+
+ // Tracks which frames are in an error state. Maps to true, if an error has
+ // occurred in a given frame.
+ FrameIdToErrorStateMap frame_state_map_;
+
+ // Used for tracking registrations to tab contents notifications.
+ NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(FrameNavigationState);
+};
+
// Observes navigation notifications and routes them as events to the extension
// system.
class ExtensionWebNavigationEventRouter : public NotificationObserver {
@@ -65,6 +110,9 @@ class ExtensionWebNavigationEventRouter : public NotificationObserver {
const char* event_name,
const std::string& json_args);
+ // Tracks the state of the frames we are sending events for.
+ FrameNavigationState navigation_state_;
+
// Used for tracking registrations to navigation notifications.
NotificationRegistrar registrar_;

Powered by Google App Engine
This is Rietveld 408576698