| 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 // Figure out window type before figuring out bounds so that default | 390 // Figure out window type before figuring out bounds so that default |
| 391 // bounds can be set according to the window type. | 391 // bounds can be set according to the window type. |
| 392 switch (create_data->type) { | 392 switch (create_data->type) { |
| 393 case windows::Create::Params::CreateData::TYPE_POPUP: | 393 case windows::Create::Params::CreateData::TYPE_POPUP: |
| 394 window_type = Browser::TYPE_POPUP; | 394 window_type = Browser::TYPE_POPUP; |
| 395 extension_id = GetExtension()->id(); | 395 extension_id = GetExtension()->id(); |
| 396 break; | 396 break; |
| 397 case windows::Create::Params::CreateData::TYPE_PANEL: | 397 case windows::Create::Params::CreateData::TYPE_PANEL: |
| 398 case windows::Create::Params::CreateData::TYPE_DETACHED_PANEL: { | 398 case windows::Create::Params::CreateData::TYPE_DETACHED_PANEL: { |
| 399 extension_id = GetExtension()->id(); | 399 extension_id = GetExtension()->id(); |
| 400 bool use_panels = false; | 400 bool use_panels = PanelManager::ShouldUsePanels(extension_id); |
| 401 #if !defined(OS_ANDROID) | |
| 402 use_panels = PanelManager::ShouldUsePanels(extension_id); | |
| 403 #endif | |
| 404 if (use_panels) { | 401 if (use_panels) { |
| 405 create_panel = true; | 402 create_panel = true; |
| 406 // Non-ash supports both docked and detached panel types. | 403 // Non-ash supports both docked and detached panel types. |
| 407 if (chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH && | 404 if (chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH && |
| 408 create_data->type == | 405 create_data->type == |
| 409 windows::Create::Params::CreateData::TYPE_DETACHED_PANEL) { | 406 windows::Create::Params::CreateData::TYPE_DETACHED_PANEL) { |
| 410 panel_create_mode = PanelManager::CREATE_AS_DETACHED; | 407 panel_create_mode = PanelManager::CREATE_AS_DETACHED; |
| 411 } | 408 } |
| 412 } else { | 409 } else { |
| 413 window_type = Browser::TYPE_POPUP; | 410 window_type = Browser::TYPE_POPUP; |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 selection.set_active(active_index); | 1025 selection.set_active(active_index); |
| 1029 browser->tab_strip_model()->SetSelectionFromModel(selection); | 1026 browser->tab_strip_model()->SetSelectionFromModel(selection); |
| 1030 SetResult( | 1027 SetResult( |
| 1031 browser->extension_window_controller()->CreateWindowValueWithTabs( | 1028 browser->extension_window_controller()->CreateWindowValueWithTabs( |
| 1032 GetExtension())); | 1029 GetExtension())); |
| 1033 return true; | 1030 return true; |
| 1034 } | 1031 } |
| 1035 | 1032 |
| 1036 bool TabsHighlightFunction::HighlightTab(TabStripModel* tabstrip, | 1033 bool TabsHighlightFunction::HighlightTab(TabStripModel* tabstrip, |
| 1037 ui::ListSelectionModel* selection, | 1034 ui::ListSelectionModel* selection, |
| 1038 int *active_index, | 1035 int* active_index, |
| 1039 int index) { | 1036 int index) { |
| 1040 // Make sure the index is in range. | 1037 // Make sure the index is in range. |
| 1041 if (!tabstrip->ContainsIndex(index)) { | 1038 if (!tabstrip->ContainsIndex(index)) { |
| 1042 error_ = ErrorUtils::FormatErrorMessage( | 1039 error_ = ErrorUtils::FormatErrorMessage( |
| 1043 keys::kTabIndexNotFoundError, base::IntToString(index)); | 1040 keys::kTabIndexNotFoundError, base::IntToString(index)); |
| 1044 return false; | 1041 return false; |
| 1045 } | 1042 } |
| 1046 | 1043 |
| 1047 // By default, we make the first tab in the list active. | 1044 // By default, we make the first tab in the list active. |
| 1048 if (*active_index == -1) | 1045 if (*active_index == -1) |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 SetResult(value.release()); | 1275 SetResult(value.release()); |
| 1279 } else { | 1276 } else { |
| 1280 // Only return the results as an array if there are multiple tabs. | 1277 // Only return the results as an array if there are multiple tabs. |
| 1281 SetResult(tab_values.release()); | 1278 SetResult(tab_values.release()); |
| 1282 } | 1279 } |
| 1283 | 1280 |
| 1284 return true; | 1281 return true; |
| 1285 } | 1282 } |
| 1286 | 1283 |
| 1287 bool TabsMoveFunction::MoveTab(int tab_id, | 1284 bool TabsMoveFunction::MoveTab(int tab_id, |
| 1288 int *new_index, | 1285 int* new_index, |
| 1289 int iteration, | 1286 int iteration, |
| 1290 base::ListValue* tab_values, | 1287 base::ListValue* tab_values, |
| 1291 int* window_id) { | 1288 int* window_id) { |
| 1292 Browser* source_browser = NULL; | 1289 Browser* source_browser = NULL; |
| 1293 TabStripModel* source_tab_strip = NULL; | 1290 TabStripModel* source_tab_strip = NULL; |
| 1294 WebContents* contents = NULL; | 1291 WebContents* contents = NULL; |
| 1295 int tab_index = -1; | 1292 int tab_index = -1; |
| 1296 if (!GetTabById(tab_id, | 1293 if (!GetTabById(tab_id, |
| 1297 GetProfile(), | 1294 GetProfile(), |
| 1298 include_incognito(), | 1295 include_incognito(), |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 execute_tab_id_ = tab_id; | 1740 execute_tab_id_ = tab_id; |
| 1744 details_ = details.Pass(); | 1741 details_ = details.Pass(); |
| 1745 return true; | 1742 return true; |
| 1746 } | 1743 } |
| 1747 | 1744 |
| 1748 bool TabsInsertCSSFunction::ShouldInsertCSS() const { | 1745 bool TabsInsertCSSFunction::ShouldInsertCSS() const { |
| 1749 return true; | 1746 return true; |
| 1750 } | 1747 } |
| 1751 | 1748 |
| 1752 } // namespace extensions | 1749 } // namespace extensions |
| OLD | NEW |