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" |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 return existing_url.ReplaceComponents(replacements) == | 784 return existing_url.ReplaceComponents(replacements) == |
785 url.ReplaceComponents(replacements); | 785 url.ReplaceComponents(replacements); |
786 } | 786 } |
787 | 787 |
788 bool GetFrameFunction::RunImpl() { | 788 bool GetFrameFunction::RunImpl() { |
789 scoped_ptr<GetFrame::Params> params(GetFrame::Params::Create(*args_)); | 789 scoped_ptr<GetFrame::Params> params(GetFrame::Params::Create(*args_)); |
790 EXTENSION_FUNCTION_VALIDATE(params.get()); | 790 EXTENSION_FUNCTION_VALIDATE(params.get()); |
791 int tab_id = params->details.tab_id; | 791 int tab_id = params->details.tab_id; |
792 int frame_id = params->details.frame_id; | 792 int frame_id = params->details.frame_id; |
793 | 793 |
794 result_.reset(Value::CreateNullValue()); | 794 SetResult(Value::CreateNullValue()); |
795 | 795 |
796 TabContents* tab_contents; | 796 TabContents* tab_contents; |
797 if (!ExtensionTabUtil::GetTabById(tab_id, | 797 if (!ExtensionTabUtil::GetTabById(tab_id, |
798 profile(), | 798 profile(), |
799 include_incognito(), | 799 include_incognito(), |
800 NULL, NULL, | 800 NULL, NULL, |
801 &tab_contents, | 801 &tab_contents, |
802 NULL) || | 802 NULL) || |
803 !tab_contents) { | 803 !tab_contents) { |
804 return true; | 804 return true; |
(...skipping 13 matching lines...) Expand all Loading... |
818 return true; | 818 return true; |
819 | 819 |
820 GURL frame_url = frame_navigation_state.GetUrl(frame_id); | 820 GURL frame_url = frame_navigation_state.GetUrl(frame_id); |
821 if (!frame_navigation_state.IsValidUrl(frame_url)) | 821 if (!frame_navigation_state.IsValidUrl(frame_url)) |
822 return true; | 822 return true; |
823 | 823 |
824 GetFrame::Result::Details frame_details; | 824 GetFrame::Result::Details frame_details; |
825 frame_details.url = frame_url.spec(); | 825 frame_details.url = frame_url.spec(); |
826 frame_details.error_occurred = | 826 frame_details.error_occurred = |
827 frame_navigation_state.GetErrorOccurredInFrame(frame_id); | 827 frame_navigation_state.GetErrorOccurredInFrame(frame_id); |
828 result_.reset(GetFrame::Result::Create(frame_details)); | 828 SetResult(GetFrame::Result::Create(frame_details)); |
829 return true; | 829 return true; |
830 } | 830 } |
831 | 831 |
832 bool GetAllFramesFunction::RunImpl() { | 832 bool GetAllFramesFunction::RunImpl() { |
833 scoped_ptr<GetAllFrames::Params> params(GetAllFrames::Params::Create(*args_)); | 833 scoped_ptr<GetAllFrames::Params> params(GetAllFrames::Params::Create(*args_)); |
834 EXTENSION_FUNCTION_VALIDATE(params.get()); | 834 EXTENSION_FUNCTION_VALIDATE(params.get()); |
835 int tab_id = params->details.tab_id; | 835 int tab_id = params->details.tab_id; |
836 | 836 |
837 result_.reset(Value::CreateNullValue()); | 837 SetResult(Value::CreateNullValue()); |
838 | 838 |
839 TabContents* tab_contents; | 839 TabContents* tab_contents; |
840 if (!ExtensionTabUtil::GetTabById(tab_id, | 840 if (!ExtensionTabUtil::GetTabById(tab_id, |
841 profile(), | 841 profile(), |
842 include_incognito(), | 842 include_incognito(), |
843 NULL, NULL, | 843 NULL, NULL, |
844 &tab_contents, | 844 &tab_contents, |
845 NULL) || | 845 NULL) || |
846 !tab_contents) { | 846 !tab_contents) { |
847 return true; | 847 return true; |
(...skipping 15 matching lines...) Expand all Loading... |
863 if (!navigation_state.IsValidUrl(frame_url)) | 863 if (!navigation_state.IsValidUrl(frame_url)) |
864 continue; | 864 continue; |
865 linked_ptr<GetAllFrames::Result::DetailsElement> frame( | 865 linked_ptr<GetAllFrames::Result::DetailsElement> frame( |
866 new GetAllFrames::Result::DetailsElement()); | 866 new GetAllFrames::Result::DetailsElement()); |
867 frame->url = frame_url.spec(); | 867 frame->url = frame_url.spec(); |
868 frame->frame_id = GetFrameId(navigation_state.IsMainFrame(frame_id), | 868 frame->frame_id = GetFrameId(navigation_state.IsMainFrame(frame_id), |
869 frame_id); | 869 frame_id); |
870 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); | 870 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); |
871 result_list.push_back(frame); | 871 result_list.push_back(frame); |
872 } | 872 } |
873 result_.reset(GetAllFrames::Result::Create(result_list)); | 873 SetResult(GetAllFrames::Result::Create(result_list)); |
874 return true; | 874 return true; |
875 } | 875 } |
876 | 876 |
877 } // namespace extensions | 877 } // namespace extensions |
OLD | NEW |