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 // Implements the Chrome Extensions WebNavigation API. | 5 // Implements the Chrome Extensions WebNavigation API. |
6 | 6 |
7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 7 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 namespace extensions { | 37 namespace extensions { |
38 | 38 |
39 namespace helpers = web_navigation_api_helpers; | 39 namespace helpers = web_navigation_api_helpers; |
40 namespace keys = web_navigation_api_constants; | 40 namespace keys = web_navigation_api_constants; |
41 namespace web_navigation = api::web_navigation; | 41 namespace web_navigation = api::web_navigation; |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 typedef std::map<content::WebContents*, WebNavigationTabObserver*> | 45 typedef std::map<content::WebContents*, WebNavigationTabObserver*> |
46 TabObserverMap; | 46 TabObserverMap; |
47 static base::LazyInstance<TabObserverMap> g_tab_observer = | 47 static base::LazyInstance<TabObserverMap>::DestructorAtExit g_tab_observer = |
48 LAZY_INSTANCE_INITIALIZER; | 48 LAZY_INSTANCE_INITIALIZER; |
49 | 49 |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 // WebNavigtionEventRouter ------------------------------------------- | 52 // WebNavigtionEventRouter ------------------------------------------- |
53 | 53 |
54 WebNavigationEventRouter::PendingWebContents::PendingWebContents() | 54 WebNavigationEventRouter::PendingWebContents::PendingWebContents() |
55 : source_web_contents(NULL), | 55 : source_web_contents(NULL), |
56 source_frame_host(NULL), | 56 source_frame_host(NULL), |
57 target_web_contents(NULL), | 57 target_web_contents(NULL), |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 web_navigation::OnTabReplaced::kEventName); | 566 web_navigation::OnTabReplaced::kEventName); |
567 } | 567 } |
568 | 568 |
569 WebNavigationAPI::~WebNavigationAPI() { | 569 WebNavigationAPI::~WebNavigationAPI() { |
570 } | 570 } |
571 | 571 |
572 void WebNavigationAPI::Shutdown() { | 572 void WebNavigationAPI::Shutdown() { |
573 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 573 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
574 } | 574 } |
575 | 575 |
576 static base::LazyInstance<BrowserContextKeyedAPIFactory<WebNavigationAPI> > | 576 static base::LazyInstance<BrowserContextKeyedAPIFactory<WebNavigationAPI>>:: |
577 g_factory = LAZY_INSTANCE_INITIALIZER; | 577 DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER; |
578 | 578 |
579 // static | 579 // static |
580 BrowserContextKeyedAPIFactory<WebNavigationAPI>* | 580 BrowserContextKeyedAPIFactory<WebNavigationAPI>* |
581 WebNavigationAPI::GetFactoryInstance() { | 581 WebNavigationAPI::GetFactoryInstance() { |
582 return g_factory.Pointer(); | 582 return g_factory.Pointer(); |
583 } | 583 } |
584 | 584 |
585 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { | 585 void WebNavigationAPI::OnListenerAdded(const EventListenerInfo& details) { |
586 web_navigation_event_router_.reset(new WebNavigationEventRouter( | 586 web_navigation_event_router_.reset(new WebNavigationEventRouter( |
587 Profile::FromBrowserContext(browser_context_))); | 587 Profile::FromBrowserContext(browser_context_))); |
588 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 588 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
589 } | 589 } |
590 | 590 |
591 } // namespace extensions | 591 } // namespace extensions |
OLD | NEW |