| 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 #include "chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.h" | 5 #include "chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 } | 768 } |
| 769 } | 769 } |
| 770 | 770 |
| 771 return true; | 771 return true; |
| 772 } | 772 } |
| 773 | 773 |
| 774 ToDataUrlOffscreenTabFunction::ToDataUrlOffscreenTabFunction() {} | 774 ToDataUrlOffscreenTabFunction::ToDataUrlOffscreenTabFunction() {} |
| 775 ToDataUrlOffscreenTabFunction::~ToDataUrlOffscreenTabFunction() {} | 775 ToDataUrlOffscreenTabFunction::~ToDataUrlOffscreenTabFunction() {} |
| 776 | 776 |
| 777 bool ToDataUrlOffscreenTabFunction::GetTabToCapture( | 777 bool ToDataUrlOffscreenTabFunction::GetTabToCapture( |
| 778 WebContents** web_contents, TabContents** tab_contents) { | 778 WebContents** web_contents) { |
| 779 int offscreen_tab_id; | 779 int offscreen_tab_id; |
| 780 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &offscreen_tab_id)); | 780 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &offscreen_tab_id)); |
| 781 | 781 |
| 782 // TODO(alexbost): We want to optimize this function in order to get more | 782 // TODO(alexbost): We want to optimize this function in order to get more |
| 783 // image updates on the browser side. One improvement would be to implement | 783 // image updates on the browser side. One improvement would be to implement |
| 784 // another hash map in order to get offscreen tabs in O(1). | 784 // another hash map in order to get offscreen tabs in O(1). |
| 785 OffscreenTab* offscreen_tab = NULL; | 785 OffscreenTab* offscreen_tab = NULL; |
| 786 if (!GetMap()->GetOffscreenTab( | 786 if (!GetMap()->GetOffscreenTab( |
| 787 offscreen_tab_id, this, &offscreen_tab, &error_)) | 787 offscreen_tab_id, this, &offscreen_tab, &error_)) |
| 788 return false; | 788 return false; |
| 789 | 789 |
| 790 *web_contents = offscreen_tab->web_contents(); | 790 *web_contents = offscreen_tab->web_contents(); |
| 791 *tab_contents = offscreen_tab->tab_contents(); | |
| 792 return true; | 791 return true; |
| 793 } | 792 } |
| 794 | 793 |
| 795 UpdateOffscreenTabFunction::UpdateOffscreenTabFunction() {} | 794 UpdateOffscreenTabFunction::UpdateOffscreenTabFunction() {} |
| 796 UpdateOffscreenTabFunction::~UpdateOffscreenTabFunction() {} | 795 UpdateOffscreenTabFunction::~UpdateOffscreenTabFunction() {} |
| 797 | 796 |
| 798 bool UpdateOffscreenTabFunction::RunImpl() { | 797 bool UpdateOffscreenTabFunction::RunImpl() { |
| 799 int offscreen_tab_id; | 798 int offscreen_tab_id; |
| 800 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &offscreen_tab_id)); | 799 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &offscreen_tab_id)); |
| 801 | 800 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 // async case (when a "javascript": URL is sent to a tab). | 838 // async case (when a "javascript": URL is sent to a tab). |
| 840 if (!is_async) | 839 if (!is_async) |
| 841 SendResponse(true); | 840 SendResponse(true); |
| 842 | 841 |
| 843 return true; | 842 return true; |
| 844 } | 843 } |
| 845 | 844 |
| 846 void UpdateOffscreenTabFunction::PopulateResult() { | 845 void UpdateOffscreenTabFunction::PopulateResult() { |
| 847 // There's no result associated with this callback. | 846 // There's no result associated with this callback. |
| 848 } | 847 } |
| OLD | NEW |