| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_webnavigation_api.h" | 7 #include "chrome/browser/extensions/extension_webnavigation_api.h" |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 for (FrameIdIterator frame_id = frame_ids.first; frame_id != frame_ids.second; | 240 for (FrameIdIterator frame_id = frame_ids.first; frame_id != frame_ids.second; |
| 241 ++frame_id) { | 241 ++frame_id) { |
| 242 frame_state_map_.erase(frame_id->second); | 242 frame_state_map_.erase(frame_id->second); |
| 243 } | 243 } |
| 244 tab_contents_map_.erase(tab_contents); | 244 tab_contents_map_.erase(tab_contents); |
| 245 } | 245 } |
| 246 | 246 |
| 247 | 247 |
| 248 // ExtensionWebNavigtionEventRouter ------------------------------------------- | 248 // ExtensionWebNavigtionEventRouter ------------------------------------------- |
| 249 | 249 |
| 250 ExtensionWebNavigationEventRouter::ExtensionWebNavigationEventRouter() {} | 250 ExtensionWebNavigationEventRouter::ExtensionWebNavigationEventRouter( |
| 251 Profile* profile) : profile_(profile) {} |
| 251 | 252 |
| 252 ExtensionWebNavigationEventRouter::~ExtensionWebNavigationEventRouter() {} | 253 ExtensionWebNavigationEventRouter::~ExtensionWebNavigationEventRouter() {} |
| 253 | 254 |
| 254 // static | |
| 255 ExtensionWebNavigationEventRouter* | |
| 256 ExtensionWebNavigationEventRouter::GetInstance() { | |
| 257 return Singleton<ExtensionWebNavigationEventRouter>::get(); | |
| 258 } | |
| 259 | |
| 260 void ExtensionWebNavigationEventRouter::Init() { | 255 void ExtensionWebNavigationEventRouter::Init() { |
| 261 if (registrar_.IsEmpty()) { | 256 if (registrar_.IsEmpty()) { |
| 262 registrar_.Add(this, | 257 registrar_.Add(this, |
| 263 NotificationType::CREATING_NEW_WINDOW, | 258 NotificationType::CREATING_NEW_WINDOW, |
| 264 NotificationService::AllSources()); | 259 NotificationService::AllSources()); |
| 265 } | 260 } |
| 266 } | 261 } |
| 267 | 262 |
| 268 void ExtensionWebNavigationEventRouter::Observe( | 263 void ExtensionWebNavigationEventRouter::Observe( |
| 269 NotificationType type, | 264 NotificationType type, |
| 270 const NotificationSource& source, | 265 const NotificationSource& source, |
| 271 const NotificationDetails& details) { | 266 const NotificationDetails& details) { |
| 272 switch (type.value) { | 267 switch (type.value) { |
| 273 case NotificationType::CREATING_NEW_WINDOW: | 268 case NotificationType::CREATING_NEW_WINDOW: |
| 274 CreatingNewWindow( | 269 CreatingNewWindow( |
| 275 Source<TabContents>(source).ptr(), | 270 Source<TabContents>(source).ptr(), |
| 276 Details<const ViewHostMsg_CreateWindow_Params>(details).ptr()); | 271 Details<const ViewHostMsg_CreateWindow_Params>(details).ptr()); |
| 277 break; | 272 break; |
| 278 | 273 |
| 279 default: | 274 default: |
| 280 NOTREACHED(); | 275 NOTREACHED(); |
| 281 } | 276 } |
| 282 } | 277 } |
| 283 | 278 |
| 284 void ExtensionWebNavigationEventRouter::CreatingNewWindow( | 279 void ExtensionWebNavigationEventRouter::CreatingNewWindow( |
| 285 TabContents* tab_contents, | 280 TabContents* tab_contents, |
| 286 const ViewHostMsg_CreateWindow_Params* details) { | 281 const ViewHostMsg_CreateWindow_Params* details) { |
| 287 DispatchOnBeforeRetarget(tab_contents, | 282 if (profile_->IsSameProfile(tab_contents->profile())) { |
| 288 tab_contents->profile(), | 283 DispatchOnBeforeRetarget(tab_contents, |
| 289 details->opener_url, | 284 tab_contents->profile(), |
| 290 details->target_url); | 285 details->opener_url, |
| 286 details->target_url); |
| 287 } |
| 291 } | 288 } |
| 292 | 289 |
| 293 | 290 |
| 294 // ExtensionWebNavigationTabObserver ------------------------------------------ | 291 // ExtensionWebNavigationTabObserver ------------------------------------------ |
| 295 | 292 |
| 296 ExtensionWebNavigationTabObserver::ExtensionWebNavigationTabObserver( | 293 ExtensionWebNavigationTabObserver::ExtensionWebNavigationTabObserver( |
| 297 TabContents* tab_contents) | 294 TabContents* tab_contents) |
| 298 : TabContentsObserver(tab_contents) {} | 295 : TabContentsObserver(tab_contents) {} |
| 299 | 296 |
| 300 ExtensionWebNavigationTabObserver::~ExtensionWebNavigationTabObserver() {} | 297 ExtensionWebNavigationTabObserver::~ExtensionWebNavigationTabObserver() {} |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 transition_type); | 442 transition_type); |
| 446 DispatchOnDOMContentLoaded(tab_contents(), | 443 DispatchOnDOMContentLoaded(tab_contents(), |
| 447 url, | 444 url, |
| 448 is_main_frame, | 445 is_main_frame, |
| 449 frame_id); | 446 frame_id); |
| 450 DispatchOnCompleted(tab_contents(), | 447 DispatchOnCompleted(tab_contents(), |
| 451 url, | 448 url, |
| 452 is_main_frame, | 449 is_main_frame, |
| 453 frame_id); | 450 frame_id); |
| 454 } | 451 } |
| OLD | NEW |