Chromium Code Reviews| 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/extensions/api/web_navigation/web_navigation_api_consta nts.h" | 10 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta nts.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 void WebNavigationEventRouter::TabReplacedAt( | 112 void WebNavigationEventRouter::TabReplacedAt( |
| 113 TabStripModel* tab_strip_model, | 113 TabStripModel* tab_strip_model, |
| 114 content::WebContents* old_contents, | 114 content::WebContents* old_contents, |
| 115 content::WebContents* new_contents, | 115 content::WebContents* new_contents, |
| 116 int index) { | 116 int index) { |
| 117 WebNavigationTabObserver* tab_observer = | 117 WebNavigationTabObserver* tab_observer = |
| 118 WebNavigationTabObserver::Get(old_contents); | 118 WebNavigationTabObserver::Get(old_contents); |
| 119 if (!tab_observer) { | 119 if (!tab_observer) { |
| 120 // If you hit this DCHECK(), please add reproduction steps to | 120 // If you hit this DCHECK(), please add reproduction steps to |
| 121 // http://crbug.com/109464. | 121 // http://crbug.com/109464. |
| 122 DCHECK(chrome::GetViewType(old_contents) != chrome::VIEW_TYPE_TAB_CONTENTS); | 122 DCHECK(chrome::GetViewType(old_contents) != |
| 123 extensions::VIEW_TYPE_TAB_CONTENTS); | |
|
Yoyo Zhou
2013/04/01 17:36:51
''
| |
| 123 return; | 124 return; |
| 124 } | 125 } |
| 125 const FrameNavigationState& frame_navigation_state = | 126 const FrameNavigationState& frame_navigation_state = |
| 126 tab_observer->frame_navigation_state(); | 127 tab_observer->frame_navigation_state(); |
| 127 | 128 |
| 128 if (!frame_navigation_state.IsValidUrl(old_contents->GetURL()) || | 129 if (!frame_navigation_state.IsValidUrl(old_contents->GetURL()) || |
| 129 !frame_navigation_state.IsValidUrl(new_contents->GetURL())) | 130 !frame_navigation_state.IsValidUrl(new_contents->GetURL())) |
| 130 return; | 131 return; |
| 131 | 132 |
| 132 helpers::DispatchOnTabReplaced(old_contents, profile_, new_contents); | 133 helpers::DispatchOnTabReplaced(old_contents, profile_, new_contents); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 161 | 162 |
| 162 void WebNavigationEventRouter::Retargeting(const RetargetingDetails* details) { | 163 void WebNavigationEventRouter::Retargeting(const RetargetingDetails* details) { |
| 163 if (details->source_frame_id == 0) | 164 if (details->source_frame_id == 0) |
| 164 return; | 165 return; |
| 165 WebNavigationTabObserver* tab_observer = | 166 WebNavigationTabObserver* tab_observer = |
| 166 WebNavigationTabObserver::Get(details->source_web_contents); | 167 WebNavigationTabObserver::Get(details->source_web_contents); |
| 167 if (!tab_observer) { | 168 if (!tab_observer) { |
| 168 // If you hit this DCHECK(), please add reproduction steps to | 169 // If you hit this DCHECK(), please add reproduction steps to |
| 169 // http://crbug.com/109464. | 170 // http://crbug.com/109464. |
| 170 DCHECK(chrome::GetViewType(details->source_web_contents) != | 171 DCHECK(chrome::GetViewType(details->source_web_contents) != |
| 171 chrome::VIEW_TYPE_TAB_CONTENTS); | 172 extensions::VIEW_TYPE_TAB_CONTENTS); |
| 172 return; | 173 return; |
| 173 } | 174 } |
| 174 const FrameNavigationState& frame_navigation_state = | 175 const FrameNavigationState& frame_navigation_state = |
| 175 tab_observer->frame_navigation_state(); | 176 tab_observer->frame_navigation_state(); |
| 176 | 177 |
| 177 FrameNavigationState::FrameID frame_id( | 178 FrameNavigationState::FrameID frame_id( |
| 178 details->source_frame_id, | 179 details->source_frame_id, |
| 179 details->source_web_contents->GetRenderViewHost()); | 180 details->source_web_contents->GetRenderViewHost()); |
| 180 if (!frame_navigation_state.CanSendEvents(frame_id)) | 181 if (!frame_navigation_state.CanSendEvents(frame_id)) |
| 181 return; | 182 return; |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 return &g_factory.Get(); | 823 return &g_factory.Get(); |
| 823 } | 824 } |
| 824 | 825 |
| 825 void WebNavigationAPI::OnListenerAdded( | 826 void WebNavigationAPI::OnListenerAdded( |
| 826 const extensions::EventListenerInfo& details) { | 827 const extensions::EventListenerInfo& details) { |
| 827 web_navigation_event_router_.reset(new WebNavigationEventRouter(profile_)); | 828 web_navigation_event_router_.reset(new WebNavigationEventRouter(profile_)); |
| 828 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 829 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
| 829 } | 830 } |
| 830 | 831 |
| 831 } // namespace extensions | 832 } // namespace extensions |
| OLD | NEW |