| OLD | NEW |
| 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 #include "chrome/browser/extensions/extension_browser_event_router.h" | 5 #include "chrome/browser/extensions/extension_browser_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/extensions/api/extension_action/extension_page_actions_
api_constants.h" | 9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" |
| 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 if (initialized_) | 78 if (initialized_) |
| 79 return; | 79 return; |
| 80 BrowserList::AddObserver(this); | 80 BrowserList::AddObserver(this); |
| 81 #if defined(TOOLKIT_VIEWS) | 81 #if defined(TOOLKIT_VIEWS) |
| 82 views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this); | 82 views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this); |
| 83 #elif defined(TOOLKIT_GTK) | 83 #elif defined(TOOLKIT_GTK) |
| 84 ui::ActiveWindowWatcherX::AddObserver(this); | 84 ui::ActiveWindowWatcherX::AddObserver(this); |
| 85 #elif defined(OS_MACOSX) | 85 #elif defined(OS_MACOSX) |
| 86 // Needed for when no suitable window can be passed to an extension as the | 86 // Needed for when no suitable window can be passed to an extension as the |
| 87 // currently focused window. | 87 // currently focused window. |
| 88 registrar_.Add(this, content::NOTIFICATION_NO_KEY_WINDOW, | 88 registrar_.Add(this, chrome::NOTIFICATION_NO_KEY_WINDOW, |
| 89 content::NotificationService::AllSources()); | 89 content::NotificationService::AllSources()); |
| 90 #endif | 90 #endif |
| 91 | 91 |
| 92 // Init() can happen after the browser is running, so catch up with any | 92 // Init() can happen after the browser is running, so catch up with any |
| 93 // windows that already exist. | 93 // windows that already exist. |
| 94 for (BrowserList::const_iterator iter = BrowserList::begin(); | 94 for (BrowserList::const_iterator iter = BrowserList::begin(); |
| 95 iter != BrowserList::end(); ++iter) { | 95 iter != BrowserList::end(); ++iter) { |
| 96 RegisterForBrowserNotifications(*iter); | 96 RegisterForBrowserNotifications(*iter); |
| 97 | 97 |
| 98 // Also catch up our internal bookkeeping of tab entries. | 98 // Also catch up our internal bookkeeping of tab entries. |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 // Tab was destroyed after being detached (without being re-attached). | 562 // Tab was destroyed after being detached (without being re-attached). |
| 563 WebContents* contents = content::Source<WebContents>(source).ptr(); | 563 WebContents* contents = content::Source<WebContents>(source).ptr(); |
| 564 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 564 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 565 content::Source<NavigationController>(&contents->GetController())); | 565 content::Source<NavigationController>(&contents->GetController())); |
| 566 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 566 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 567 content::Source<WebContents>(contents)); | 567 content::Source<WebContents>(contents)); |
| 568 } else if (type == chrome::NOTIFICATION_BROWSER_WINDOW_READY) { | 568 } else if (type == chrome::NOTIFICATION_BROWSER_WINDOW_READY) { |
| 569 Browser* browser = content::Source<Browser>(source).ptr(); | 569 Browser* browser = content::Source<Browser>(source).ptr(); |
| 570 OnBrowserWindowReady(browser); | 570 OnBrowserWindowReady(browser); |
| 571 #if defined(OS_MACOSX) | 571 #if defined(OS_MACOSX) |
| 572 } else if (type == content::NOTIFICATION_NO_KEY_WINDOW) { | 572 } else if (type == chrome::NOTIFICATION_NO_KEY_WINDOW) { |
| 573 OnBrowserSetLastActive(NULL); | 573 OnBrowserSetLastActive(NULL); |
| 574 #endif | 574 #endif |
| 575 } else { | 575 } else { |
| 576 NOTREACHED(); | 576 NOTREACHED(); |
| 577 } | 577 } |
| 578 } | 578 } |
| 579 | 579 |
| 580 void ExtensionBrowserEventRouter::TabChangedAt(TabContents* contents, | 580 void ExtensionBrowserEventRouter::TabChangedAt(TabContents* contents, |
| 581 int index, | 581 int index, |
| 582 TabChangeType change_type) { | 582 TabChangeType change_type) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 } | 703 } |
| 704 | 704 |
| 705 if (event_name) { | 705 if (event_name) { |
| 706 DispatchEventWithTab(profile, | 706 DispatchEventWithTab(profile, |
| 707 extension_action.extension_id(), | 707 extension_action.extension_id(), |
| 708 event_name, | 708 event_name, |
| 709 tab_contents->web_contents(), | 709 tab_contents->web_contents(), |
| 710 true); | 710 true); |
| 711 } | 711 } |
| 712 } | 712 } |
| OLD | NEW |