| 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/browser/view_type_utils.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/chrome_view_type.h" | |
| 22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 23 #include "content/public/browser/resource_request_details.h" | 23 #include "content/public/browser/resource_request_details.h" |
| 24 #include "content/public/browser/navigation_details.h" | 24 #include "content/public/browser/navigation_details.h" |
| 25 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
| 26 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.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 using content::BrowserContext; | 31 using content::BrowserContext; |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 } | 440 } |
| 441 | 441 |
| 442 void WebNavigationEventRouter::Retargeting(const RetargetingDetails* details) { | 442 void WebNavigationEventRouter::Retargeting(const RetargetingDetails* details) { |
| 443 if (details->source_frame_id == 0) | 443 if (details->source_frame_id == 0) |
| 444 return; | 444 return; |
| 445 WebNavigationTabObserver* tab_observer = | 445 WebNavigationTabObserver* tab_observer = |
| 446 WebNavigationTabObserver::Get(details->source_web_contents); | 446 WebNavigationTabObserver::Get(details->source_web_contents); |
| 447 if (!tab_observer) { | 447 if (!tab_observer) { |
| 448 // If you hit this DCHECK(), please add reproduction steps to | 448 // If you hit this DCHECK(), please add reproduction steps to |
| 449 // http://crbug.com/109464. | 449 // http://crbug.com/109464. |
| 450 DCHECK(details->source_web_contents->GetViewType() != | 450 DCHECK(chrome::GetViewType(details->source_web_contents) != |
| 451 chrome::VIEW_TYPE_TAB_CONTENTS); | 451 chrome::VIEW_TYPE_TAB_CONTENTS); |
| 452 return; | 452 return; |
| 453 } | 453 } |
| 454 const FrameNavigationState& frame_navigation_state = | 454 const FrameNavigationState& frame_navigation_state = |
| 455 tab_observer->frame_navigation_state(); | 455 tab_observer->frame_navigation_state(); |
| 456 | 456 |
| 457 if (!frame_navigation_state.CanSendEvents(details->source_frame_id)) | 457 if (!frame_navigation_state.CanSendEvents(details->source_frame_id)) |
| 458 return; | 458 return; |
| 459 | 459 |
| 460 // If the WebContents was created as a response to an IPC from a renderer | 460 // If the WebContents was created as a response to an IPC from a renderer |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 frameDict->SetBoolean( | 803 frameDict->SetBoolean( |
| 804 keys::kErrorOccurredKey, | 804 keys::kErrorOccurredKey, |
| 805 navigation_state.GetErrorOccurredInFrame(*frame)); | 805 navigation_state.GetErrorOccurredInFrame(*frame)); |
| 806 resultList->Append(frameDict); | 806 resultList->Append(frameDict); |
| 807 } | 807 } |
| 808 result_.reset(resultList); | 808 result_.reset(resultList); |
| 809 return true; | 809 return true; |
| 810 } | 810 } |
| 811 | 811 |
| 812 } // namespace extensions | 812 } // namespace extensions |
| OLD | NEW |