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

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_event_router.h

Issue 1156043002: chrome.tabs.onUpdated doesn't called with 'loading' twice. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_TABS_TABS_EVENT_ROUTER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
14 #include "chrome/browser/extensions/api/tabs/tabs_api.h" 14 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
15 #include "chrome/browser/ui/browser_list_observer.h" 15 #include "chrome/browser/ui/browser_list_observer.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
17 #include "chrome/common/extensions/api/tabs.h"
17 #include "components/favicon/core/favicon_driver_observer.h" 18 #include "components/favicon/core/favicon_driver_observer.h"
18 #include "components/ui/zoom/zoom_observer.h" 19 #include "components/ui/zoom/zoom_observer.h"
19 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
20 #include "extensions/browser/event_router.h" 21 #include "extensions/browser/event_router.h"
21 22
22 namespace content { 23 namespace content {
23 class WebContents; 24 class WebContents;
24 } 25 }
25 26
26 namespace favicon { 27 namespace favicon {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void OnFaviconAvailable(const gfx::Image& image) override; 88 void OnFaviconAvailable(const gfx::Image& image) override;
88 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, 89 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver,
89 bool icon_url_changed) override; 90 bool icon_url_changed) override;
90 91
91 private: 92 private:
92 // "Synthetic" event. Called from TabInsertedAt if new tab is detected. 93 // "Synthetic" event. Called from TabInsertedAt if new tab is detected.
93 void TabCreatedAt(content::WebContents* contents, int index, bool active); 94 void TabCreatedAt(content::WebContents* contents, int index, bool active);
94 95
95 // Internal processing of tab updated events. Is called by both TabChangedAt 96 // Internal processing of tab updated events. Is called by both TabChangedAt
96 // and Observe/NAV_ENTRY_COMMITTED. 97 // and Observe/NAV_ENTRY_COMMITTED.
97 void TabUpdated(content::WebContents* contents, bool did_navigate); 98 void TabUpdated(content::WebContents* contents, api::tabs::TabStatus status);
98 99
99 // Triggers a tab updated event if the favicon URL changes. 100 // Triggers a tab updated event if the favicon URL changes.
100 void FaviconUrlUpdated(content::WebContents* contents); 101 void FaviconUrlUpdated(content::WebContents* contents);
101 102
102 // The DispatchEvent methods forward events to the |profile|'s event router. 103 // The DispatchEvent methods forward events to the |profile|'s event router.
103 // The TabsEventRouter listens to events for all profiles, 104 // The TabsEventRouter listens to events for all profiles,
104 // so we avoid duplication by dropping events destined for other profiles. 105 // so we avoid duplication by dropping events destined for other profiles.
105 void DispatchEvent(Profile* profile, 106 void DispatchEvent(Profile* profile,
106 const std::string& event_name, 107 const std::string& event_name,
107 scoped_ptr<base::ListValue> args, 108 scoped_ptr<base::ListValue> args,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // to "loading", until the DidNavigate() method which should always follow 156 // to "loading", until the DidNavigate() method which should always follow
156 // it. Returns NULL if no updates should be sent. 157 // it. Returns NULL if no updates should be sent.
157 base::DictionaryValue* UpdateLoadState( 158 base::DictionaryValue* UpdateLoadState(
158 const content::WebContents* contents); 159 const content::WebContents* contents);
159 160
160 // Indicates that a tab load has resulted in a navigation and the 161 // Indicates that a tab load has resulted in a navigation and the
161 // destination url is available for inspection. Returns NULL if no updates 162 // destination url is available for inspection. Returns NULL if no updates
162 // should be sent. 163 // should be sent.
163 base::DictionaryValue* DidNavigate(const content::WebContents* contents); 164 base::DictionaryValue* DidNavigate(const content::WebContents* contents);
164 165
166 // Update URL without a state-change. Returns NULL if the URL of |contents|
167 // is same with current URL.
168 base::DictionaryValue* UpdateUrl(const content::WebContents* contents);
169
165 private: 170 private:
166 // Whether we are waiting to fire the 'complete' status change. This will 171 // Whether we are waiting to fire the 'complete' status change. This will
167 // occur the first time the WebContents stops loading after the 172 // occur the first time the WebContents stops loading after the
168 // NAV_ENTRY_COMMITTED was fired. The tab may go back into and out of the 173 // NAV_ENTRY_COMMITTED was fired. The tab may go back into and out of the
169 // loading state subsequently, but we will ignore those changes. 174 // loading state subsequently, but we will ignore those changes.
170 bool complete_waiting_on_load_; 175 bool complete_waiting_on_load_;
171 176
172 GURL url_; 177 GURL url_;
173 }; 178 };
174 179
175 // Gets the TabEntry for the given |contents|. Returns TabEntry* if 180 // Gets the TabEntry for the given |contents|. Returns TabEntry* if
176 // found, NULL if not. 181 // found, NULL if not.
177 TabEntry* GetTabEntry(content::WebContents* contents); 182 TabEntry* GetTabEntry(content::WebContents* contents);
178 183
179 std::map<int, TabEntry> tab_entries_; 184 std::map<int, TabEntry> tab_entries_;
180 185
181 // The main profile that owns this event router. 186 // The main profile that owns this event router.
182 Profile* profile_; 187 Profile* profile_;
183 188
184 ScopedObserver<favicon::FaviconDriver, TabsEventRouter> 189 ScopedObserver<favicon::FaviconDriver, TabsEventRouter>
185 favicon_scoped_observer_; 190 favicon_scoped_observer_;
186 191
187 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter); 192 DISALLOW_COPY_AND_ASSIGN(TabsEventRouter);
188 }; 193 };
189 194
190 } // namespace extensions 195 } // namespace extensions
191 196
192 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_ 197 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_TABS_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698