| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 103 } |
| 104 | 104 |
| 105 void WebNavigationEventRouter::OnBrowserRemoved(Browser* browser) { | 105 void WebNavigationEventRouter::OnBrowserRemoved(Browser* browser) { |
| 106 if (!profile_->IsSameProfile(browser->profile())) | 106 if (!profile_->IsSameProfile(browser->profile())) |
| 107 return; | 107 return; |
| 108 browser->tab_strip_model()->RemoveObserver(this); | 108 browser->tab_strip_model()->RemoveObserver(this); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void WebNavigationEventRouter::TabReplacedAt( | 111 void WebNavigationEventRouter::TabReplacedAt( |
| 112 TabStripModel* tab_strip_model, | 112 TabStripModel* tab_strip_model, |
| 113 TabContents* old_contents, | 113 content::WebContents* old_contents, |
| 114 TabContents* new_contents, | 114 content::WebContents* new_contents, |
| 115 int index) { | 115 int index) { |
| 116 WebNavigationTabObserver* tab_observer = | 116 WebNavigationTabObserver* tab_observer = |
| 117 WebNavigationTabObserver::Get(old_contents->web_contents()); | 117 WebNavigationTabObserver::Get(old_contents); |
| 118 if (!tab_observer) { | 118 if (!tab_observer) { |
| 119 // If you hit this DCHECK(), please add reproduction steps to | 119 // If you hit this DCHECK(), please add reproduction steps to |
| 120 // http://crbug.com/109464. | 120 // http://crbug.com/109464. |
| 121 DCHECK(chrome::GetViewType(old_contents->web_contents()) != | 121 DCHECK(chrome::GetViewType(old_contents) != chrome::VIEW_TYPE_TAB_CONTENTS); |
| 122 chrome::VIEW_TYPE_TAB_CONTENTS); | |
| 123 return; | 122 return; |
| 124 } | 123 } |
| 125 const FrameNavigationState& frame_navigation_state = | 124 const FrameNavigationState& frame_navigation_state = |
| 126 tab_observer->frame_navigation_state(); | 125 tab_observer->frame_navigation_state(); |
| 127 | 126 |
| 128 if (!frame_navigation_state.IsValidUrl( | 127 if (!frame_navigation_state.IsValidUrl(old_contents->GetURL()) || |
| 129 old_contents->web_contents()->GetURL()) || | 128 !frame_navigation_state.IsValidUrl(new_contents->GetURL())) |
| 130 !frame_navigation_state.IsValidUrl( | |
| 131 new_contents->web_contents()->GetURL())) | |
| 132 return; | 129 return; |
| 133 | 130 |
| 134 helpers::DispatchOnTabReplaced( | 131 helpers::DispatchOnTabReplaced(old_contents, profile_, new_contents); |
| 135 old_contents->web_contents(), | |
| 136 profile_, | |
| 137 new_contents->web_contents()); | |
| 138 } | 132 } |
| 139 | 133 |
| 140 void WebNavigationEventRouter::Observe( | 134 void WebNavigationEventRouter::Observe( |
| 141 int type, | 135 int type, |
| 142 const content::NotificationSource& source, | 136 const content::NotificationSource& source, |
| 143 const content::NotificationDetails& details) { | 137 const content::NotificationDetails& details) { |
| 144 switch (type) { | 138 switch (type) { |
| 145 case chrome::NOTIFICATION_RETARGETING: { | 139 case chrome::NOTIFICATION_RETARGETING: { |
| 146 Profile* profile = content::Source<Profile>(source).ptr(); | 140 Profile* profile = content::Source<Profile>(source).ptr(); |
| 147 if (profile->GetOriginalProfile() == profile_) { | 141 if (profile->GetOriginalProfile() == profile_) { |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 parent_frame_id.frame_num); | 730 parent_frame_id.frame_num); |
| 737 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); | 731 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); |
| 738 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); | 732 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); |
| 739 result_list.push_back(frame); | 733 result_list.push_back(frame); |
| 740 } | 734 } |
| 741 results_ = GetAllFrames::Results::Create(result_list); | 735 results_ = GetAllFrames::Results::Create(result_list); |
| 742 return true; | 736 return true; |
| 743 } | 737 } |
| 744 | 738 |
| 745 } // namespace extensions | 739 } // namespace extensions |
| OLD | NEW |