| 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 13 matching lines...) Expand all Loading... |
| 24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
| 26 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
| 27 #include "content/public/browser/render_view_host.h" | 27 #include "content/public/browser/render_view_host.h" |
| 28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 29 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
| 30 | 30 |
| 31 namespace GetFrame = extensions::api::web_navigation::GetFrame; | 31 namespace GetFrame = extensions::api::web_navigation::GetFrame; |
| 32 namespace GetAllFrames = extensions::api::web_navigation::GetAllFrames; | 32 namespace GetAllFrames = extensions::api::web_navigation::GetAllFrames; |
| 33 | 33 |
| 34 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::WebNavigationTabObserver) |
| 35 |
| 34 namespace extensions { | 36 namespace extensions { |
| 35 | 37 |
| 36 namespace helpers = web_navigation_api_helpers; | 38 namespace helpers = web_navigation_api_helpers; |
| 37 namespace keys = web_navigation_api_constants; | 39 namespace keys = web_navigation_api_constants; |
| 38 | 40 |
| 39 namespace { | 41 namespace { |
| 40 | 42 |
| 41 typedef std::map<content::WebContents*, WebNavigationTabObserver*> | 43 typedef std::map<content::WebContents*, WebNavigationTabObserver*> |
| 42 TabObserverMap; | 44 TabObserverMap; |
| 43 static base::LazyInstance<TabObserverMap> g_tab_observer = | 45 static base::LazyInstance<TabObserverMap> g_tab_observer = |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 pending_web_contents_.begin(); i != pending_web_contents_.end(); ) { | 248 pending_web_contents_.begin(); i != pending_web_contents_.end(); ) { |
| 247 if (i->second.source_web_contents == tab) | 249 if (i->second.source_web_contents == tab) |
| 248 pending_web_contents_.erase(i++); | 250 pending_web_contents_.erase(i++); |
| 249 else | 251 else |
| 250 ++i; | 252 ++i; |
| 251 } | 253 } |
| 252 } | 254 } |
| 253 | 255 |
| 254 // WebNavigationTabObserver ------------------------------------------ | 256 // WebNavigationTabObserver ------------------------------------------ |
| 255 | 257 |
| 256 int WebNavigationTabObserver::kUserDataKey; | |
| 257 | |
| 258 WebNavigationTabObserver::WebNavigationTabObserver( | 258 WebNavigationTabObserver::WebNavigationTabObserver( |
| 259 content::WebContents* web_contents) | 259 content::WebContents* web_contents) |
| 260 : WebContentsObserver(web_contents), | 260 : WebContentsObserver(web_contents), |
| 261 render_view_host_(NULL), | 261 render_view_host_(NULL), |
| 262 pending_render_view_host_(NULL) { | 262 pending_render_view_host_(NULL) { |
| 263 g_tab_observer.Get().insert(TabObserverMap::value_type(web_contents, this)); | 263 g_tab_observer.Get().insert(TabObserverMap::value_type(web_contents, this)); |
| 264 registrar_.Add(this, | 264 registrar_.Add(this, |
| 265 content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 265 content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
| 266 content::Source<content::WebContents>(web_contents)); | 266 content::Source<content::WebContents>(web_contents)); |
| 267 registrar_.Add(this, | 267 registrar_.Add(this, |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 navigation_state.IsMainFrame(frame_id), frame_id.frame_num); | 722 navigation_state.IsMainFrame(frame_id), frame_id.frame_num); |
| 723 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); | 723 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); |
| 724 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); | 724 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); |
| 725 result_list.push_back(frame); | 725 result_list.push_back(frame); |
| 726 } | 726 } |
| 727 results_ = GetAllFrames::Results::Create(result_list); | 727 results_ = GetAllFrames::Results::Create(result_list); |
| 728 return true; | 728 return true; |
| 729 } | 729 } |
| 730 | 730 |
| 731 } // namespace extensions | 731 } // namespace extensions |
| OLD | NEW |