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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
792 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &offscreen_tab_id)); | 792 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &offscreen_tab_id)); |
793 | 793 |
794 OffscreenTab* offscreen_tab = NULL; | 794 OffscreenTab* offscreen_tab = NULL; |
795 if (!GetMap()->GetOffscreenTab( | 795 if (!GetMap()->GetOffscreenTab( |
796 offscreen_tab_id, this, &offscreen_tab, &error_)) | 796 offscreen_tab_id, this, &offscreen_tab, &error_)) |
797 return false; | 797 return false; |
798 | 798 |
799 DictionaryValue* update_props; | 799 DictionaryValue* update_props; |
800 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props)); | 800 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props)); |
801 | 801 |
802 web_contents_ = offscreen_tab->web_contents(); | 802 tab_contents_ = offscreen_tab->tab_contents(); |
803 bool is_async = false; | 803 bool is_async = false; |
804 if (!UpdateURLIfPresent(update_props, &is_async)) | 804 if (!UpdateURLIfPresent(update_props, &is_async)) |
805 return false; | 805 return false; |
806 | 806 |
807 // Update the width and height, if specified. | 807 // Update the width and height, if specified. |
808 if (update_props->HasKey(tabs_keys::kWidthKey) || | 808 if (update_props->HasKey(tabs_keys::kWidthKey) || |
809 update_props->HasKey(tabs_keys::kHeightKey)) { | 809 update_props->HasKey(tabs_keys::kHeightKey)) { |
810 const gfx::Size& size = | |
811 tab_contents_->web_contents()->GetView()->GetContainerSize(); | |
812 | |
810 int width; | 813 int width; |
811 if (update_props->HasKey(tabs_keys::kWidthKey)) | 814 if (update_props->HasKey(tabs_keys::kWidthKey)) |
812 EXTENSION_FUNCTION_VALIDATE( | 815 EXTENSION_FUNCTION_VALIDATE( |
813 update_props->GetInteger(tabs_keys::kWidthKey, &width)); | 816 update_props->GetInteger(tabs_keys::kWidthKey, &width)); |
814 else | 817 else |
815 web_contents_->GetView()->GetContainerSize().width(); | 818 width = size.width(); |
koz (OOO until 15th September)
2012/05/11 01:09:16
Good spot!
| |
816 | 819 |
817 int height; | 820 int height; |
818 if (update_props->HasKey(tabs_keys::kHeightKey)) | 821 if (update_props->HasKey(tabs_keys::kHeightKey)) |
819 EXTENSION_FUNCTION_VALIDATE( | 822 EXTENSION_FUNCTION_VALIDATE( |
820 update_props->GetInteger(tabs_keys::kHeightKey, &height)); | 823 update_props->GetInteger(tabs_keys::kHeightKey, &height)); |
821 else | 824 else |
822 web_contents_->GetView()->GetContainerSize().height(); | 825 height = size.height(); |
823 | 826 |
824 offscreen_tab->SetSize(width, height); | 827 offscreen_tab->SetSize(width, height); |
825 } | 828 } |
826 | 829 |
827 // The response is sent from UpdateTabFunction::OnExecuteCodeFinish in the | 830 // The response is sent from UpdateTabFunction::OnExecuteCodeFinish in the |
828 // async case (when a "javascript": URL is sent to a tab). | 831 // async case (when a "javascript": URL is sent to a tab). |
829 if (!is_async) | 832 if (!is_async) |
830 SendResponse(true); | 833 SendResponse(true); |
831 | 834 |
832 return true; | 835 return true; |
833 } | 836 } |
834 | 837 |
835 void UpdateOffscreenTabFunction::PopulateResult() { | 838 void UpdateOffscreenTabFunction::PopulateResult() { |
836 // There's no result associated with this callback. | 839 // There's no result associated with this callback. |
837 } | 840 } |
OLD | NEW |