| 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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 return existing_url.ReplaceComponents(replacements) == | 717 return existing_url.ReplaceComponents(replacements) == |
| 718 url.ReplaceComponents(replacements); | 718 url.ReplaceComponents(replacements); |
| 719 } | 719 } |
| 720 | 720 |
| 721 bool GetFrameFunction::RunImpl() { | 721 bool GetFrameFunction::RunImpl() { |
| 722 scoped_ptr<GetFrame::Params> params(GetFrame::Params::Create(*args_)); | 722 scoped_ptr<GetFrame::Params> params(GetFrame::Params::Create(*args_)); |
| 723 EXTENSION_FUNCTION_VALIDATE(params.get()); | 723 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 724 int tab_id = params->details.tab_id; | 724 int tab_id = params->details.tab_id; |
| 725 int frame_id = params->details.frame_id; | 725 int frame_id = params->details.frame_id; |
| 726 | 726 |
| 727 result_.reset(Value::CreateNullValue()); | 727 SetSingleResult(Value::CreateNullValue()); |
| 728 | 728 |
| 729 TabContents* tab_contents; | 729 TabContents* tab_contents; |
| 730 if (!ExtensionTabUtil::GetTabById(tab_id, | 730 if (!ExtensionTabUtil::GetTabById(tab_id, |
| 731 profile(), | 731 profile(), |
| 732 include_incognito(), | 732 include_incognito(), |
| 733 NULL, NULL, | 733 NULL, NULL, |
| 734 &tab_contents, | 734 &tab_contents, |
| 735 NULL) || | 735 NULL) || |
| 736 !tab_contents) { | 736 !tab_contents) { |
| 737 return true; | 737 return true; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 751 return true; | 751 return true; |
| 752 | 752 |
| 753 GURL frame_url = frame_navigation_state.GetUrl(frame_id); | 753 GURL frame_url = frame_navigation_state.GetUrl(frame_id); |
| 754 if (!frame_navigation_state.IsValidUrl(frame_url)) | 754 if (!frame_navigation_state.IsValidUrl(frame_url)) |
| 755 return true; | 755 return true; |
| 756 | 756 |
| 757 GetFrame::Result::Details frame_details; | 757 GetFrame::Result::Details frame_details; |
| 758 frame_details.url = frame_url.spec(); | 758 frame_details.url = frame_url.spec(); |
| 759 frame_details.error_occurred = | 759 frame_details.error_occurred = |
| 760 frame_navigation_state.GetErrorOccurredInFrame(frame_id); | 760 frame_navigation_state.GetErrorOccurredInFrame(frame_id); |
| 761 result_.reset(GetFrame::Result::Create(frame_details)); | 761 SetSingleResult(GetFrame::Result::Create(frame_details)); |
| 762 return true; | 762 return true; |
| 763 } | 763 } |
| 764 | 764 |
| 765 bool GetAllFramesFunction::RunImpl() { | 765 bool GetAllFramesFunction::RunImpl() { |
| 766 scoped_ptr<GetAllFrames::Params> params(GetAllFrames::Params::Create(*args_)); | 766 scoped_ptr<GetAllFrames::Params> params(GetAllFrames::Params::Create(*args_)); |
| 767 EXTENSION_FUNCTION_VALIDATE(params.get()); | 767 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 768 int tab_id = params->details.tab_id; | 768 int tab_id = params->details.tab_id; |
| 769 | 769 |
| 770 result_.reset(Value::CreateNullValue()); | 770 SetSingleResult(Value::CreateNullValue()); |
| 771 | 771 |
| 772 TabContents* tab_contents; | 772 TabContents* tab_contents; |
| 773 if (!ExtensionTabUtil::GetTabById(tab_id, | 773 if (!ExtensionTabUtil::GetTabById(tab_id, |
| 774 profile(), | 774 profile(), |
| 775 include_incognito(), | 775 include_incognito(), |
| 776 NULL, NULL, | 776 NULL, NULL, |
| 777 &tab_contents, | 777 &tab_contents, |
| 778 NULL) || | 778 NULL) || |
| 779 !tab_contents) { | 779 !tab_contents) { |
| 780 return true; | 780 return true; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 796 if (!navigation_state.IsValidUrl(frame_url)) | 796 if (!navigation_state.IsValidUrl(frame_url)) |
| 797 continue; | 797 continue; |
| 798 linked_ptr<GetAllFrames::Result::DetailsElement> frame( | 798 linked_ptr<GetAllFrames::Result::DetailsElement> frame( |
| 799 new GetAllFrames::Result::DetailsElement()); | 799 new GetAllFrames::Result::DetailsElement()); |
| 800 frame->url = frame_url.spec(); | 800 frame->url = frame_url.spec(); |
| 801 frame->frame_id = GetFrameId(navigation_state.IsMainFrame(frame_id), | 801 frame->frame_id = GetFrameId(navigation_state.IsMainFrame(frame_id), |
| 802 frame_id); | 802 frame_id); |
| 803 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); | 803 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); |
| 804 result_list.push_back(frame); | 804 result_list.push_back(frame); |
| 805 } | 805 } |
| 806 result_.reset(GetAllFrames::Result::Create(result_list)); | 806 SetSingleResult(GetAllFrames::Result::Create(result_list)); |
| 807 return true; | 807 return true; |
| 808 } | 808 } |
| 809 | 809 |
| 810 } // namespace extensions | 810 } // namespace extensions |
| OLD | NEW |