| 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/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta
nts.h" | 14 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_consta
nts.h" |
| 15 #include "chrome/browser/extensions/extension_event_router.h" | 15 #include "chrome/browser/extensions/extension_event_router.h" |
| 16 #include "chrome/browser/extensions/extension_tab_util.h" | 16 #include "chrome/browser/extensions/extension_tab_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/tab_contents/retargeting_details.h" | 18 #include "chrome/browser/tab_contents/retargeting_details.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/chrome_view_type.h" |
| 21 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 22 #include "content/public/browser/resource_request_details.h" | 23 #include "content/public/browser/resource_request_details.h" |
| 23 #include "content/public/browser/navigation_details.h" | 24 #include "content/public/browser/navigation_details.h" |
| 24 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.h" |
| 26 #include "content/public/browser/render_view_host.h" | 27 #include "content/public/browser/render_view_host.h" |
| 27 #include "content/public/browser/render_view_host_delegate.h" | 28 #include "content/public/browser/render_view_host_delegate.h" |
| 28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 29 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
| 30 | 31 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 442 |
| 442 void WebNavigationEventRouter::Retargeting(const RetargetingDetails* details) { | 443 void WebNavigationEventRouter::Retargeting(const RetargetingDetails* details) { |
| 443 if (details->source_frame_id == 0) | 444 if (details->source_frame_id == 0) |
| 444 return; | 445 return; |
| 445 WebNavigationTabObserver* tab_observer = | 446 WebNavigationTabObserver* tab_observer = |
| 446 WebNavigationTabObserver::Get(details->source_web_contents); | 447 WebNavigationTabObserver::Get(details->source_web_contents); |
| 447 if (!tab_observer) { | 448 if (!tab_observer) { |
| 448 // If you hit this DCHECK(), please add reproduction steps to | 449 // If you hit this DCHECK(), please add reproduction steps to |
| 449 // http://crbug.com/109464. | 450 // http://crbug.com/109464. |
| 450 DCHECK(details->source_web_contents->GetViewType() != | 451 DCHECK(details->source_web_contents->GetViewType() != |
| 451 content::VIEW_TYPE_WEB_CONTENTS); | 452 chrome::VIEW_TYPE_TAB_CONTENTS); |
| 452 return; | 453 return; |
| 453 } | 454 } |
| 454 const FrameNavigationState& frame_navigation_state = | 455 const FrameNavigationState& frame_navigation_state = |
| 455 tab_observer->frame_navigation_state(); | 456 tab_observer->frame_navigation_state(); |
| 456 | 457 |
| 457 if (!frame_navigation_state.CanSendEvents(details->source_frame_id)) | 458 if (!frame_navigation_state.CanSendEvents(details->source_frame_id)) |
| 458 return; | 459 return; |
| 459 | 460 |
| 460 // If the WebContents was created as a response to an IPC from a renderer | 461 // If the WebContents was created as a response to an IPC from a renderer |
| 461 // (and therefore doesn't yet have a wrapper), or if it isn't yet inserted | 462 // (and therefore doesn't yet have a wrapper), or if it isn't yet inserted |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 frameDict->SetBoolean( | 802 frameDict->SetBoolean( |
| 802 keys::kErrorOccurredKey, | 803 keys::kErrorOccurredKey, |
| 803 navigation_state.GetErrorOccurredInFrame(*frame)); | 804 navigation_state.GetErrorOccurredInFrame(*frame)); |
| 804 resultList->Append(frameDict); | 805 resultList->Append(frameDict); |
| 805 } | 806 } |
| 806 result_.reset(resultList); | 807 result_.reset(resultList); |
| 807 return true; | 808 return true; |
| 808 } | 809 } |
| 809 | 810 |
| 810 } // namespace extensions | 811 } // namespace extensions |
| OLD | NEW |