Chromium Code Reviews| 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/tabs/tabs_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 else | 753 else |
| 754 bounds = controller->window()->GetBounds(); | 754 bounds = controller->window()->GetBounds(); |
| 755 bool set_bounds = false; | 755 bool set_bounds = false; |
| 756 | 756 |
| 757 // Any part of the bounds can optionally be set by the caller. | 757 // Any part of the bounds can optionally be set by the caller. |
| 758 int bounds_val; | 758 int bounds_val; |
| 759 if (update_props->HasKey(keys::kLeftKey)) { | 759 if (update_props->HasKey(keys::kLeftKey)) { |
| 760 EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger( | 760 EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger( |
| 761 keys::kLeftKey, | 761 keys::kLeftKey, |
| 762 &bounds_val)); | 762 &bounds_val)); |
| 763 bounds.set_x(bounds_val); | 763 if (bounds.x() != bounds_val) { |
| 764 set_bounds = true; | 764 bounds.set_x(bounds_val); |
| 765 set_bounds = true; | |
| 766 } | |
| 765 } | 767 } |
| 766 | 768 |
| 767 if (update_props->HasKey(keys::kTopKey)) { | 769 if (update_props->HasKey(keys::kTopKey)) { |
| 768 EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger( | 770 EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger( |
| 769 keys::kTopKey, | 771 keys::kTopKey, |
| 770 &bounds_val)); | 772 &bounds_val)); |
| 771 bounds.set_y(bounds_val); | 773 if (bounds.y() != bounds_val) { |
| 772 set_bounds = true; | 774 bounds.set_y(bounds_val); |
| 775 set_bounds = true; | |
| 776 } | |
| 773 } | 777 } |
| 774 | 778 |
| 775 if (update_props->HasKey(keys::kWidthKey)) { | 779 if (update_props->HasKey(keys::kWidthKey)) { |
| 776 EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger( | 780 EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger( |
| 777 keys::kWidthKey, | 781 keys::kWidthKey, |
| 778 &bounds_val)); | 782 &bounds_val)); |
| 779 bounds.set_width(bounds_val); | 783 if (bounds.width() != bounds_val) { |
| 780 set_bounds = true; | 784 bounds.set_width(bounds_val); |
| 785 set_bounds = true; | |
| 786 } | |
| 781 } | 787 } |
| 782 | 788 |
| 783 if (update_props->HasKey(keys::kHeightKey)) { | 789 if (update_props->HasKey(keys::kHeightKey)) { |
| 784 EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger( | 790 EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger( |
| 785 keys::kHeightKey, | 791 keys::kHeightKey, |
| 786 &bounds_val)); | 792 &bounds_val)); |
| 787 bounds.set_height(bounds_val); | 793 if (bounds.height() != bounds_val) { |
| 788 set_bounds = true; | 794 bounds.set_height(bounds_val); |
| 795 set_bounds = true; | |
| 796 } | |
| 789 } | 797 } |
| 790 | 798 |
| 791 if (set_bounds) { | 799 if (set_bounds) { |
| 792 if (show_state == ui::SHOW_STATE_MINIMIZED || | 800 if (show_state == ui::SHOW_STATE_MINIMIZED || |
| 793 show_state == ui::SHOW_STATE_MAXIMIZED || | 801 show_state == ui::SHOW_STATE_MAXIMIZED || |
| 794 show_state == ui::SHOW_STATE_FULLSCREEN) { | 802 show_state == ui::SHOW_STATE_FULLSCREEN) { |
| 795 error_ = keys::kInvalidWindowStateError; | 803 error_ = keys::kInvalidWindowStateError; |
| 796 return false; | 804 return false; |
| 797 } | 805 } |
| 798 controller->window()->SetBounds(bounds); | 806 controller->window()->SetBounds(bounds); |
|
flackr
2013/06/19 15:26:46
Avoiding this SetBounds call if the values don't c
varkha
2013/06/19 15:49:22
True, but this has wider UX impact and probably no
flackr
2013/06/19 16:21:45
Since this should be fine for the simple case wher
varkha
2013/06/19 17:54:09
Done. See http://crbug.com/251813.
| |
| 799 } | 807 } |
| 800 | 808 |
| 801 bool active_val = false; | 809 bool active_val = false; |
| 802 if (update_props->HasKey(keys::kFocusedKey)) { | 810 if (update_props->HasKey(keys::kFocusedKey)) { |
| 803 EXTENSION_FUNCTION_VALIDATE(update_props->GetBoolean( | 811 EXTENSION_FUNCTION_VALIDATE(update_props->GetBoolean( |
| 804 keys::kFocusedKey, &active_val)); | 812 keys::kFocusedKey, &active_val)); |
| 805 if (active_val) { | 813 if (active_val) { |
| 806 if (show_state == ui::SHOW_STATE_MINIMIZED) { | 814 if (show_state == ui::SHOW_STATE_MINIMIZED) { |
| 807 error_ = keys::kInvalidWindowStateError; | 815 error_ = keys::kInvalidWindowStateError; |
| 808 return false; | 816 return false; |
| (...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2067 execute_tab_id_ = tab_id; | 2075 execute_tab_id_ = tab_id; |
| 2068 details_ = details.Pass(); | 2076 details_ = details.Pass(); |
| 2069 return true; | 2077 return true; |
| 2070 } | 2078 } |
| 2071 | 2079 |
| 2072 bool TabsInsertCSSFunction::ShouldInsertCSS() const { | 2080 bool TabsInsertCSSFunction::ShouldInsertCSS() const { |
| 2073 return true; | 2081 return true; |
| 2074 } | 2082 } |
| 2075 | 2083 |
| 2076 } // namespace extensions | 2084 } // namespace extensions |
| OLD | NEW |