| 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" |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 | 641 |
| 642 bool GetFrameFunction::RunImpl() { | 642 bool GetFrameFunction::RunImpl() { |
| 643 scoped_ptr<GetFrame::Params> params(GetFrame::Params::Create(*args_)); | 643 scoped_ptr<GetFrame::Params> params(GetFrame::Params::Create(*args_)); |
| 644 EXTENSION_FUNCTION_VALIDATE(params.get()); | 644 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 645 int tab_id = params->details.tab_id; | 645 int tab_id = params->details.tab_id; |
| 646 int frame_id = params->details.frame_id; | 646 int frame_id = params->details.frame_id; |
| 647 int process_id = params->details.process_id; | 647 int process_id = params->details.process_id; |
| 648 | 648 |
| 649 SetResult(Value::CreateNullValue()); | 649 SetResult(Value::CreateNullValue()); |
| 650 | 650 |
| 651 TabContents* tab_contents; | 651 content::WebContents* web_contents; |
| 652 if (!ExtensionTabUtil::GetTabById(tab_id, | 652 if (!ExtensionTabUtil::GetTabById(tab_id, |
| 653 profile(), | 653 profile(), |
| 654 include_incognito(), | 654 include_incognito(), |
| 655 NULL, NULL, | 655 NULL, NULL, |
| 656 &tab_contents, | 656 &web_contents, |
| 657 NULL) || | 657 NULL) || |
| 658 !tab_contents) { | 658 !web_contents) { |
| 659 return true; | 659 return true; |
| 660 } | 660 } |
| 661 | 661 |
| 662 content::WebContents* web_contents = tab_contents->web_contents(); | |
| 663 WebNavigationTabObserver* observer = | 662 WebNavigationTabObserver* observer = |
| 664 WebNavigationTabObserver::Get(web_contents); | 663 WebNavigationTabObserver::Get(web_contents); |
| 665 DCHECK(observer); | 664 DCHECK(observer); |
| 666 | 665 |
| 667 const FrameNavigationState& frame_navigation_state = | 666 const FrameNavigationState& frame_navigation_state = |
| 668 observer->frame_navigation_state(); | 667 observer->frame_navigation_state(); |
| 669 | 668 |
| 670 if (frame_id == 0) | 669 if (frame_id == 0) |
| 671 frame_id = frame_navigation_state.GetMainFrameID().frame_num; | 670 frame_id = frame_navigation_state.GetMainFrameID().frame_num; |
| 672 | 671 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 696 return true; | 695 return true; |
| 697 } | 696 } |
| 698 | 697 |
| 699 bool GetAllFramesFunction::RunImpl() { | 698 bool GetAllFramesFunction::RunImpl() { |
| 700 scoped_ptr<GetAllFrames::Params> params(GetAllFrames::Params::Create(*args_)); | 699 scoped_ptr<GetAllFrames::Params> params(GetAllFrames::Params::Create(*args_)); |
| 701 EXTENSION_FUNCTION_VALIDATE(params.get()); | 700 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 702 int tab_id = params->details.tab_id; | 701 int tab_id = params->details.tab_id; |
| 703 | 702 |
| 704 SetResult(Value::CreateNullValue()); | 703 SetResult(Value::CreateNullValue()); |
| 705 | 704 |
| 706 TabContents* tab_contents; | 705 content::WebContents* web_contents; |
| 707 if (!ExtensionTabUtil::GetTabById(tab_id, | 706 if (!ExtensionTabUtil::GetTabById(tab_id, |
| 708 profile(), | 707 profile(), |
| 709 include_incognito(), | 708 include_incognito(), |
| 710 NULL, NULL, | 709 NULL, NULL, |
| 711 &tab_contents, | 710 &web_contents, |
| 712 NULL) || | 711 NULL) || |
| 713 !tab_contents) { | 712 !web_contents) { |
| 714 return true; | 713 return true; |
| 715 } | 714 } |
| 716 | 715 |
| 717 content::WebContents* web_contents = tab_contents->web_contents(); | |
| 718 WebNavigationTabObserver* observer = | 716 WebNavigationTabObserver* observer = |
| 719 WebNavigationTabObserver::Get(web_contents); | 717 WebNavigationTabObserver::Get(web_contents); |
| 720 DCHECK(observer); | 718 DCHECK(observer); |
| 721 | 719 |
| 722 const FrameNavigationState& navigation_state = | 720 const FrameNavigationState& navigation_state = |
| 723 observer->frame_navigation_state(); | 721 observer->frame_navigation_state(); |
| 724 | 722 |
| 725 std::vector<linked_ptr<GetAllFrames::Results::DetailsElement> > result_list; | 723 std::vector<linked_ptr<GetAllFrames::Results::DetailsElement> > result_list; |
| 726 for (FrameNavigationState::const_iterator it = navigation_state.begin(); | 724 for (FrameNavigationState::const_iterator it = navigation_state.begin(); |
| 727 it != navigation_state.end(); ++it) { | 725 it != navigation_state.end(); ++it) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 741 parent_frame_id.frame_num); | 739 parent_frame_id.frame_num); |
| 742 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); | 740 frame->process_id = frame_id.render_view_host->GetProcess()->GetID(); |
| 743 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); | 741 frame->error_occurred = navigation_state.GetErrorOccurredInFrame(frame_id); |
| 744 result_list.push_back(frame); | 742 result_list.push_back(frame); |
| 745 } | 743 } |
| 746 results_ = GetAllFrames::Results::Create(result_list); | 744 results_ = GetAllFrames::Results::Create(result_list); |
| 747 return true; | 745 return true; |
| 748 } | 746 } |
| 749 | 747 |
| 750 } // namespace extensions | 748 } // namespace extensions |
| OLD | NEW |