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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 !is_panel; | 253 !is_panel; |
| 254 case windows::WINDOW_STATE_NORMAL: | 254 case windows::WINDOW_STATE_NORMAL: |
| 255 case windows::WINDOW_STATE_DOCKED: | 255 case windows::WINDOW_STATE_DOCKED: |
| 256 case windows::WINDOW_STATE_NONE: | 256 case windows::WINDOW_STATE_NONE: |
| 257 return true; | 257 return true; |
| 258 } | 258 } |
| 259 NOTREACHED(); | 259 NOTREACHED(); |
| 260 return true; | 260 return true; |
| 261 } | 261 } |
| 262 | 262 |
| 263 bool IsHangoutsExtensionId(const std::string& extension_id) { | |
| 264 for (const char* id : extension_misc::kHangoutsExtensionIds) { | |
| 265 if (extension_id == id) | |
| 266 return true; | |
| 267 } | |
| 268 return false; | |
| 269 } | |
| 270 | |
| 271 } // namespace | 263 } // namespace |
| 272 | 264 |
| 273 void ZoomModeToZoomSettings(ZoomController::ZoomMode zoom_mode, | 265 void ZoomModeToZoomSettings(ZoomController::ZoomMode zoom_mode, |
| 274 api::tabs::ZoomSettings* zoom_settings) { | 266 api::tabs::ZoomSettings* zoom_settings) { |
| 275 DCHECK(zoom_settings); | 267 DCHECK(zoom_settings); |
| 276 switch (zoom_mode) { | 268 switch (zoom_mode) { |
| 277 case ZoomController::ZOOM_MODE_DEFAULT: | 269 case ZoomController::ZOOM_MODE_DEFAULT: |
| 278 zoom_settings->mode = api::tabs::ZOOM_SETTINGS_MODE_AUTOMATIC; | 270 zoom_settings->mode = api::tabs::ZOOM_SETTINGS_MODE_AUTOMATIC; |
| 279 zoom_settings->scope = api::tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN; | 271 zoom_settings->scope = api::tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN; |
| 280 break; | 272 break; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 | 501 |
| 510 if (!IsValidStateForWindowsCreateFunction(create_data)) { | 502 if (!IsValidStateForWindowsCreateFunction(create_data)) { |
| 511 error_ = keys::kInvalidWindowStateError; | 503 error_ = keys::kInvalidWindowStateError; |
| 512 return false; | 504 return false; |
| 513 } | 505 } |
| 514 | 506 |
| 515 Browser::Type window_type = Browser::TYPE_TABBED; | 507 Browser::Type window_type = Browser::TYPE_TABBED; |
| 516 | 508 |
| 517 #if defined(USE_ASH) | 509 #if defined(USE_ASH) |
| 518 bool create_ash_panel = false; | 510 bool create_ash_panel = false; |
| 511 bool saw_focus_key = false; | |
| 519 #endif // defined(USE_ASH) | 512 #endif // defined(USE_ASH) |
| 520 | 513 |
| 521 gfx::Rect window_bounds; | 514 gfx::Rect window_bounds; |
| 522 bool focused = true; | 515 bool focused = true; |
| 523 bool saw_focus_key = false; | |
| 524 std::string extension_id; | 516 std::string extension_id; |
| 525 | 517 |
| 526 if (create_data) { | 518 if (create_data) { |
| 527 // Figure out window type before figuring out bounds so that default | 519 // Figure out window type before figuring out bounds so that default |
| 528 // bounds can be set according to the window type. | 520 // bounds can be set according to the window type. |
| 529 switch (create_data->type) { | 521 switch (create_data->type) { |
| 530 case windows::CREATE_TYPE_POPUP: | 522 case windows::CREATE_TYPE_POPUP: |
| 531 window_type = Browser::TYPE_POPUP; | 523 window_type = Browser::TYPE_POPUP; |
| 532 extension_id = extension()->id(); | 524 extension_id = extension()->id(); |
| 533 break; | 525 break; |
| 534 | 526 |
| 535 case windows::CREATE_TYPE_PANEL: | 527 case windows::CREATE_TYPE_PANEL: |
| 536 case windows::CREATE_TYPE_DETACHED_PANEL: { | 528 case windows::CREATE_TYPE_DETACHED_PANEL: { |
| 537 extension_id = extension()->id(); | 529 extension_id = extension()->id(); |
| 538 #if defined(USE_ASH) | 530 #if defined(USE_ASH) |
| 539 // Only ChromeOS' version of chrome.windows.create would create a panel | 531 // Only ChromeOS' version of chrome.windows.create would |
| 540 // window. It is whitelisted to Hangouts extension for limited time until | 532 // create a panel window. |
|
Devlin
2016/08/26 15:09:53
nit: comment wrapping was correct before.
Anton Obzhirov
2016/08/26 16:02:57
Ups, I thought I was fixing it :)
| |
| 541 // it transitioned to other types of windows. | 533 // It is whitelisted to Hangouts extension for limited time until |
| 542 if (IsHangoutsExtensionId(extension_id)) { | 534 // it transitioned to other types of windows. |
| 543 create_ash_panel = true; | 535 for (const char* id : extension_misc::kHangoutsExtensionIds) { |
| 544 break; | 536 if (extension_id == id) { |
| 537 create_ash_panel = true; | |
| 538 break; | |
| 539 } | |
| 545 } | 540 } |
| 546 #endif // defined(USE_ASH) | 541 #endif // defined(USE_ASH) |
| 547 // Everything else gets POPUP instead of PANEL. | 542 // Everything else gets POPUP instead of PANEL. |
| 548 // TODO(dimich): Eventually, remove the 'panel' values form valid | 543 // TODO(dimich): Eventually, remove the 'panel' values form valid |
| 549 // window.create parameters. However, this is a more breaking change, so | 544 // window.create parameters. However, this is a more breaking change, so |
| 550 // for now simply treat it as a POPUP. | 545 // for now simply treat it as a POPUP. |
| 551 window_type = Browser::TYPE_POPUP; | 546 window_type = Browser::TYPE_POPUP; |
| 552 break; | 547 break; |
| 553 } | 548 } |
| 554 | 549 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 window_bounds.set_y(*create_data->top); | 581 window_bounds.set_y(*create_data->top); |
| 587 | 582 |
| 588 if (create_data->width) | 583 if (create_data->width) |
| 589 window_bounds.set_width(*create_data->width); | 584 window_bounds.set_width(*create_data->width); |
| 590 | 585 |
| 591 if (create_data->height) | 586 if (create_data->height) |
| 592 window_bounds.set_height(*create_data->height); | 587 window_bounds.set_height(*create_data->height); |
| 593 | 588 |
| 594 if (create_data->focused) { | 589 if (create_data->focused) { |
| 595 focused = *create_data->focused; | 590 focused = *create_data->focused; |
| 591 #if defined(USE_ASH) | |
| 596 saw_focus_key = true; | 592 saw_focus_key = true; |
| 593 #endif | |
| 597 } | 594 } |
| 598 } | 595 } |
| 599 | 596 |
| 600 #if defined(USE_ASH) | 597 #if defined(USE_ASH) |
| 601 if (create_ash_panel) { | 598 if (create_ash_panel) { |
| 602 if (urls.empty()) | 599 if (urls.empty()) |
| 603 urls.push_back(GURL(chrome::kChromeUINewTabURL)); | 600 urls.push_back(GURL(chrome::kChromeUINewTabURL)); |
| 604 | 601 |
| 605 AppWindow::CreateParams create_params; | 602 AppWindow::CreateParams create_params; |
| 606 create_params.window_type = AppWindow::WINDOW_TYPE_V1_PANEL; | 603 create_params.window_type = AppWindow::WINDOW_TYPE_V1_PANEL; |
| (...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2187 params->tab_id | 2184 params->tab_id |
| 2188 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, | 2185 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, |
| 2189 base::IntToString(*params->tab_id)) | 2186 base::IntToString(*params->tab_id)) |
| 2190 : keys::kCannotFindTabToDiscard)); | 2187 : keys::kCannotFindTabToDiscard)); |
| 2191 } | 2188 } |
| 2192 | 2189 |
| 2193 TabsDiscardFunction::TabsDiscardFunction() {} | 2190 TabsDiscardFunction::TabsDiscardFunction() {} |
| 2194 TabsDiscardFunction::~TabsDiscardFunction() {} | 2191 TabsDiscardFunction::~TabsDiscardFunction() {} |
| 2195 | 2192 |
| 2196 } // namespace extensions | 2193 } // namespace extensions |
| OLD | NEW |