| 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" |
| 11 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper
s.h" | 11 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api_helper
s.h" |
| 12 #include "chrome/browser/extensions/event_router.h" | 12 #include "chrome/browser/extensions/event_router.h" |
| 13 #include "chrome/browser/extensions/extension_system.h" | 13 #include "chrome/browser/extensions/extension_system.h" |
| 14 #include "chrome/browser/extensions/extension_tab_util.h" | 14 #include "chrome/browser/extensions/extension_tab_util.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/tab_contents/retargeting_details.h" | 16 #include "chrome/browser/tab_contents/retargeting_details.h" |
| 17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_list.h" | 18 #include "chrome/browser/ui/browser_list.h" |
| 19 #include "chrome/browser/view_type_utils.h" | 19 #include "chrome/browser/view_type_utils.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/extensions/api/web_navigation.h" | 21 #include "chrome/common/extensions/api/web_navigation.h" |
| 22 #include "content/public/browser/resource_request_details.h" | |
| 23 #include "content/public/browser/navigation_details.h" | 22 #include "content/public/browser/navigation_details.h" |
| 24 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
| 26 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
| 27 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
| 27 #include "content/public/browser/resource_request_details.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) | 34 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::WebNavigationTabObserver) |
| 35 | 35 |
| 36 namespace extensions { | 36 namespace extensions { |
| 37 | 37 |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 GURL existing_url = navigation_state_.GetUrl(frame_id); | 620 GURL existing_url = navigation_state_.GetUrl(frame_id); |
| 621 if (existing_url == url) | 621 if (existing_url == url) |
| 622 return false; | 622 return false; |
| 623 | 623 |
| 624 url_canon::Replacements<char> replacements; | 624 url_canon::Replacements<char> replacements; |
| 625 replacements.ClearRef(); | 625 replacements.ClearRef(); |
| 626 return existing_url.ReplaceComponents(replacements) == | 626 return existing_url.ReplaceComponents(replacements) == |
| 627 url.ReplaceComponents(replacements); | 627 url.ReplaceComponents(replacements); |
| 628 } | 628 } |
| 629 | 629 |
| 630 bool GetFrameFunction::RunImpl() { | 630 bool WebNavigationGetFrameFunction::RunImpl() { |
| 631 scoped_ptr<GetFrame::Params> params(GetFrame::Params::Create(*args_)); | 631 scoped_ptr<GetFrame::Params> params(GetFrame::Params::Create(*args_)); |
| 632 EXTENSION_FUNCTION_VALIDATE(params.get()); | 632 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 633 int tab_id = params->details.tab_id; | 633 int tab_id = params->details.tab_id; |
| 634 int frame_id = params->details.frame_id; | 634 int frame_id = params->details.frame_id; |
| 635 int process_id = params->details.process_id; | 635 int process_id = params->details.process_id; |
| 636 | 636 |
| 637 SetResult(Value::CreateNullValue()); | 637 SetResult(Value::CreateNullValue()); |
| 638 | 638 |
| 639 content::WebContents* web_contents; | 639 content::WebContents* web_contents; |
| 640 if (!ExtensionTabUtil::GetTabById(tab_id, | 640 if (!ExtensionTabUtil::GetTabById(tab_id, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 frame_navigation_state.GetErrorOccurredInFrame(internal_frame_id); | 676 frame_navigation_state.GetErrorOccurredInFrame(internal_frame_id); |
| 677 FrameNavigationState::FrameID parent_frame_id = | 677 FrameNavigationState::FrameID parent_frame_id = |
| 678 frame_navigation_state.GetParentFrameID(internal_frame_id); | 678 frame_navigation_state.GetParentFrameID(internal_frame_id); |
| 679 frame_details.parent_frame_id = helpers::GetFrameId( | 679 frame_details.parent_frame_id = helpers::GetFrameId( |
| 680 frame_navigation_state.IsMainFrame(parent_frame_id), | 680 frame_navigation_state.IsMainFrame(parent_frame_id), |
| 681 parent_frame_id.frame_num); | 681 parent_frame_id.frame_num); |
| 682 results_ = GetFrame::Results::Create(frame_details); | 682 results_ = GetFrame::Results::Create(frame_details); |
| 683 return true; | 683 return true; |
| 684 } | 684 } |
| 685 | 685 |
| 686 bool GetAllFramesFunction::RunImpl() { | 686 bool WebNavigationGetAllFramesFunction::RunImpl() { |
| 687 scoped_ptr<GetAllFrames::Params> params(GetAllFrames::Params::Create(*args_)); | 687 scoped_ptr<GetAllFrames::Params> params(GetAllFrames::Params::Create(*args_)); |
| 688 EXTENSION_FUNCTION_VALIDATE(params.get()); | 688 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 689 int tab_id = params->details.tab_id; | 689 int tab_id = params->details.tab_id; |
| 690 | 690 |
| 691 SetResult(Value::CreateNullValue()); | 691 SetResult(Value::CreateNullValue()); |
| 692 | 692 |
| 693 content::WebContents* web_contents; | 693 content::WebContents* web_contents; |
| 694 if (!ExtensionTabUtil::GetTabById(tab_id, | 694 if (!ExtensionTabUtil::GetTabById(tab_id, |
| 695 profile(), | 695 profile(), |
| 696 include_incognito(), | 696 include_incognito(), |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 static base::LazyInstance<ProfileKeyedAPIFactory<WebNavigationAPI> > | 771 static base::LazyInstance<ProfileKeyedAPIFactory<WebNavigationAPI> > |
| 772 g_factory = LAZY_INSTANCE_INITIALIZER; | 772 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 773 | 773 |
| 774 template <> | 774 template <> |
| 775 ProfileKeyedAPIFactory<WebNavigationAPI>* | 775 ProfileKeyedAPIFactory<WebNavigationAPI>* |
| 776 ProfileKeyedAPIFactory<WebNavigationAPI>::GetInstance() { | 776 ProfileKeyedAPIFactory<WebNavigationAPI>::GetInstance() { |
| 777 return &g_factory.Get(); | 777 return &g_factory.Get(); |
| 778 } | 778 } |
| 779 | 779 |
| 780 } // namespace extensions | 780 } // namespace extensions |
| OLD | NEW |