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

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

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, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/extensions/api/tabs/tabs_event_router.h" 5 #include "chrome/browser/extensions/api/tabs/tabs_event_router.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
11 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" 11 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h"
12 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" 12 #include "chrome/browser/extensions/api/tabs/windows_event_router.h"
13 #include "chrome/browser/extensions/extension_tab_util.h" 13 #include "chrome/browser/extensions/extension_tab_util.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_iterator.h" 16 #include "chrome/browser/ui/browser_iterator.h"
17 #include "chrome/browser/ui/browser_list.h" 17 #include "chrome/browser/ui/browser_list.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
19 #include "chrome/common/extensions/extension_constants.h" 19 #include "chrome/common/extensions/extension_constants.h"
20 #include "components/favicon/content/content_favicon_driver.h" 20 #include "components/favicon/content/content_favicon_driver.h"
21 #include "content/public/browser/favicon_status.h" 21 #include "content/public/browser/favicon_status.h"
22 #include "content/public/browser/navigation_controller.h" 22 #include "content/public/browser/navigation_controller.h"
23 #include "content/public/browser/navigation_details.h"
23 #include "content/public/browser/navigation_entry.h" 24 #include "content/public/browser/navigation_entry.h"
24 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/notification_types.h" 26 #include "content/public/browser/notification_types.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
27 28
28 using base::DictionaryValue; 29 using base::DictionaryValue;
29 using base::ListValue; 30 using base::ListValue;
30 using base::FundamentalValue; 31 using base::FundamentalValue;
31 using content::NavigationController; 32 using content::NavigationController;
32 using content::WebContents; 33 using content::WebContents;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 TabStripModel* tab_strip = browser->tab_strip_model(); 134 TabStripModel* tab_strip = browser->tab_strip_model();
134 tab_strip->AddObserver(this); 135 tab_strip->AddObserver(this);
135 136
136 for (int i = 0; i < tab_strip->count(); ++i) { 137 for (int i = 0; i < tab_strip->count(); ++i) {
137 RegisterForTabNotifications(tab_strip->GetWebContentsAt(i)); 138 RegisterForTabNotifications(tab_strip->GetWebContentsAt(i));
138 } 139 }
139 } 140 }
140 141
141 void TabsEventRouter::RegisterForTabNotifications(WebContents* contents) { 142 void TabsEventRouter::RegisterForTabNotifications(WebContents* contents) {
142 registrar_.Add( 143 registrar_.Add(
143 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 144 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
not at google - send to devlin 2015/05/27 15:59:15 Could you add: TODO(limasdf): Attach WebContentsO
limasdf 2015/07/01 12:37:54 Done.
144 content::Source<NavigationController>(&contents->GetController())); 145 content::Source<NavigationController>(&contents->GetController()));
145 146
146 // Observing NOTIFICATION_WEB_CONTENTS_DESTROYED is necessary because it's 147 // Observing NOTIFICATION_WEB_CONTENTS_DESTROYED is necessary because it's
147 // possible for tabs to be created, detached and then destroyed without 148 // possible for tabs to be created, detached and then destroyed without
148 // ever having been re-attached and closed. This happens in the case of 149 // ever having been re-attached and closed. This happens in the case of
149 // a devtools WebContents that is opened in window, docked, then closed. 150 // a devtools WebContents that is opened in window, docked, then closed.
150 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 151 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
151 content::Source<WebContents>(contents)); 152 content::Source<WebContents>(contents));
152 153
153 favicon_scoped_observer_.Add( 154 favicon_scoped_observer_.Add(
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 int tab_id = ExtensionTabUtil::GetTabId(contents); 486 int tab_id = ExtensionTabUtil::GetTabId(contents);
486 std::map<int, TabEntry>::iterator i = tab_entries_.find(tab_id); 487 std::map<int, TabEntry>::iterator i = tab_entries_.find(tab_id);
487 if (tab_entries_.end() == i) 488 if (tab_entries_.end() == i)
488 return NULL; 489 return NULL;
489 return &i->second; 490 return &i->second;
490 } 491 }
491 492
492 void TabsEventRouter::Observe(int type, 493 void TabsEventRouter::Observe(int type,
493 const content::NotificationSource& source, 494 const content::NotificationSource& source,
494 const content::NotificationDetails& details) { 495 const content::NotificationDetails& details) {
495 if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { 496 if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) {
not at google - send to devlin 2015/05/27 15:59:15 can you update this to be a switch?
limasdf 2015/07/01 12:37:54 Done.
497 content::LoadCommittedDetails* commit =
498 content::Details<content::LoadCommittedDetails>(details).ptr();
499 if (commit->is_in_page)
500 return;
501
496 NavigationController* source_controller = 502 NavigationController* source_controller =
497 content::Source<NavigationController>(source).ptr(); 503 content::Source<NavigationController>(source).ptr();
498 TabUpdated(source_controller->GetWebContents(), true); 504 TabUpdated(source_controller->GetWebContents(), true);
499 } else if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 505 } else if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
500 // Tab was destroyed after being detached (without being re-attached). 506 // Tab was destroyed after being detached (without being re-attached).
501 WebContents* contents = content::Source<WebContents>(source).ptr(); 507 WebContents* contents = content::Source<WebContents>(source).ptr();
502 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 508 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
503 content::Source<NavigationController>(&contents->GetController())); 509 content::Source<NavigationController>(&contents->GetController()));
504 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 510 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
505 content::Source<WebContents>(contents)); 511 content::Source<WebContents>(contents));
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 void TabsEventRouter::OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, 595 void TabsEventRouter::OnFaviconUpdated(favicon::FaviconDriver* favicon_driver,
590 bool icon_url_changed) { 596 bool icon_url_changed) {
591 if (icon_url_changed) { 597 if (icon_url_changed) {
592 favicon::ContentFaviconDriver* content_favicon_driver = 598 favicon::ContentFaviconDriver* content_favicon_driver =
593 static_cast<favicon::ContentFaviconDriver*>(favicon_driver); 599 static_cast<favicon::ContentFaviconDriver*>(favicon_driver);
594 FaviconUrlUpdated(content_favicon_driver->web_contents()); 600 FaviconUrlUpdated(content_favicon_driver->web_contents());
595 } 601 }
596 } 602 }
597 603
598 } // namespace extensions 604 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698