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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 #include "extensions/common/message_bundle.h" | 88 #include "extensions/common/message_bundle.h" |
89 #include "extensions/common/permissions/permissions_data.h" | 89 #include "extensions/common/permissions/permissions_data.h" |
90 #include "extensions/common/user_script.h" | 90 #include "extensions/common/user_script.h" |
91 #include "net/base/escape.h" | 91 #include "net/base/escape.h" |
92 #include "skia/ext/image_operations.h" | 92 #include "skia/ext/image_operations.h" |
93 #include "skia/ext/platform_canvas.h" | 93 #include "skia/ext/platform_canvas.h" |
94 #include "third_party/skia/include/core/SkBitmap.h" | 94 #include "third_party/skia/include/core/SkBitmap.h" |
95 #include "ui/base/models/list_selection_model.h" | 95 #include "ui/base/models/list_selection_model.h" |
96 #include "ui/base/ui_base_types.h" | 96 #include "ui/base/ui_base_types.h" |
97 | 97 |
| 98 #if defined(USE_ASH) |
| 99 #include "chrome/browser/extensions/api/tabs/ash_panel_contents.h" // nogncheck |
| 100 #include "extensions/browser/app_window/app_window_registry.h" // nogncheck |
| 101 #endif |
| 102 |
98 using content::BrowserThread; | 103 using content::BrowserThread; |
99 using content::NavigationController; | 104 using content::NavigationController; |
100 using content::NavigationEntry; | 105 using content::NavigationEntry; |
101 using content::OpenURLParams; | 106 using content::OpenURLParams; |
102 using content::Referrer; | 107 using content::Referrer; |
103 using content::WebContents; | 108 using content::WebContents; |
104 using zoom::ZoomController; | 109 using zoom::ZoomController; |
105 | 110 |
106 namespace extensions { | 111 namespace extensions { |
107 | 112 |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 if (source_browser->profile() != window_profile) | 479 if (source_browser->profile() != window_profile) |
475 return RespondNow(Error(keys::kCanOnlyMoveTabsWithinSameProfileError)); | 480 return RespondNow(Error(keys::kCanOnlyMoveTabsWithinSameProfileError)); |
476 } | 481 } |
477 | 482 |
478 if (!IsValidStateForWindowsCreateFunction(create_data)) | 483 if (!IsValidStateForWindowsCreateFunction(create_data)) |
479 return RespondNow(Error(keys::kInvalidWindowStateError)); | 484 return RespondNow(Error(keys::kInvalidWindowStateError)); |
480 | 485 |
481 Browser::Type window_type = Browser::TYPE_TABBED; | 486 Browser::Type window_type = Browser::TYPE_TABBED; |
482 | 487 |
483 #if defined(USE_ASH) | 488 #if defined(USE_ASH) |
| 489 bool create_ash_panel = false; |
484 bool saw_focus_key = false; | 490 bool saw_focus_key = false; |
485 #endif // defined(USE_ASH) | 491 #endif // defined(USE_ASH) |
486 | 492 |
487 gfx::Rect window_bounds; | 493 gfx::Rect window_bounds; |
488 bool focused = true; | 494 bool focused = true; |
489 std::string extension_id; | 495 std::string extension_id; |
490 | 496 |
491 if (create_data) { | 497 if (create_data) { |
492 // Report UMA stats to decide when to remove the deprecated "docked" windows | 498 // Report UMA stats to decide when to remove the deprecated "docked" windows |
493 // state (crbug.com/703733). | 499 // state (crbug.com/703733). |
494 ReportRequestedWindowState(create_data->state); | 500 ReportRequestedWindowState(create_data->state); |
495 | 501 |
496 // Figure out window type before figuring out bounds so that default | 502 // Figure out window type before figuring out bounds so that default |
497 // bounds can be set according to the window type. | 503 // bounds can be set according to the window type. |
498 switch (create_data->type) { | 504 switch (create_data->type) { |
499 case windows::CREATE_TYPE_POPUP: | 505 case windows::CREATE_TYPE_POPUP: |
500 window_type = Browser::TYPE_POPUP; | 506 window_type = Browser::TYPE_POPUP; |
501 extension_id = extension()->id(); | 507 extension_id = extension()->id(); |
502 break; | 508 break; |
503 | 509 |
504 case windows::CREATE_TYPE_PANEL: { | 510 case windows::CREATE_TYPE_PANEL: { |
505 extension_id = extension()->id(); | 511 extension_id = extension()->id(); |
| 512 #if defined(USE_ASH) |
| 513 // Only ChromeOS' version of chrome.windows.create would create a panel |
| 514 // window. It is whitelisted to Hangouts extension for limited time until |
| 515 // it transitioned to other types of windows. |
| 516 for (const char* id : extension_misc::kHangoutsExtensionIds) { |
| 517 if (extension_id == id) { |
| 518 create_ash_panel = true; |
| 519 break; |
| 520 } |
| 521 } |
| 522 #endif // defined(USE_ASH) |
| 523 // Everything else gets POPUP instead of PANEL. |
506 // TODO(dimich): Eventually, remove the 'panel' values form valid | 524 // TODO(dimich): Eventually, remove the 'panel' values form valid |
507 // window.create parameters. However, this is a more breaking change, so | 525 // window.create parameters. However, this is a more breaking change, so |
508 // for now simply treat it as a POPUP. | 526 // for now simply treat it as a POPUP. |
509 window_type = Browser::TYPE_POPUP; | 527 window_type = Browser::TYPE_POPUP; |
510 break; | 528 break; |
511 } | 529 } |
512 | 530 |
513 case windows::CREATE_TYPE_NONE: | 531 case windows::CREATE_TYPE_NONE: |
514 case windows::CREATE_TYPE_NORMAL: | 532 case windows::CREATE_TYPE_NORMAL: |
515 break; | 533 break; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 window_bounds.set_height(*create_data->height); | 566 window_bounds.set_height(*create_data->height); |
549 | 567 |
550 if (create_data->focused) { | 568 if (create_data->focused) { |
551 focused = *create_data->focused; | 569 focused = *create_data->focused; |
552 #if defined(USE_ASH) | 570 #if defined(USE_ASH) |
553 saw_focus_key = true; | 571 saw_focus_key = true; |
554 #endif | 572 #endif |
555 } | 573 } |
556 } | 574 } |
557 | 575 |
| 576 #if defined(USE_ASH) |
| 577 if (create_ash_panel) { |
| 578 if (urls.empty()) |
| 579 urls.push_back(GURL(chrome::kChromeUINewTabURL)); |
| 580 |
| 581 AppWindow::CreateParams create_params; |
| 582 create_params.window_type = AppWindow::WINDOW_TYPE_V1_PANEL; |
| 583 create_params.window_key = extension_id; |
| 584 create_params.window_spec.bounds = window_bounds; |
| 585 create_params.focused = saw_focus_key && focused; |
| 586 AppWindow* app_window = |
| 587 new AppWindow(window_profile, new ChromeAppDelegate(true), extension()); |
| 588 AshPanelContents* ash_panel_contents = new AshPanelContents(app_window); |
| 589 app_window->Init(urls[0], ash_panel_contents, render_frame_host(), |
| 590 create_params); |
| 591 WindowController* window_controller = |
| 592 WindowControllerList::GetInstance()->FindWindowById( |
| 593 app_window->session_id().id()); |
| 594 if (!window_controller) |
| 595 return RespondNow(Error(kUnknownErrorDoNotUse)); |
| 596 return RespondNow( |
| 597 OneArgument(window_controller->CreateWindowValueWithTabs(extension()))); |
| 598 } |
| 599 #endif // defined(USE_ASH) |
| 600 |
558 // Create a new BrowserWindow. | 601 // Create a new BrowserWindow. |
559 Browser::CreateParams create_params(window_type, window_profile, | 602 Browser::CreateParams create_params(window_type, window_profile, |
560 user_gesture()); | 603 user_gesture()); |
561 if (extension_id.empty()) { | 604 if (extension_id.empty()) { |
562 create_params.initial_bounds = window_bounds; | 605 create_params.initial_bounds = window_bounds; |
563 } else { | 606 } else { |
564 create_params = Browser::CreateParams::CreateForApp( | 607 create_params = Browser::CreateParams::CreateForApp( |
565 web_app::GenerateApplicationNameFromExtensionId(extension_id), | 608 web_app::GenerateApplicationNameFromExtensionId(extension_id), |
566 false /* trusted_source */, window_bounds, window_profile, | 609 false /* trusted_source */, window_bounds, window_profile, |
567 user_gesture()); | 610 user_gesture()); |
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2106 params->tab_id | 2149 params->tab_id |
2107 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, | 2150 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, |
2108 base::IntToString(*params->tab_id)) | 2151 base::IntToString(*params->tab_id)) |
2109 : keys::kCannotFindTabToDiscard)); | 2152 : keys::kCannotFindTabToDiscard)); |
2110 } | 2153 } |
2111 | 2154 |
2112 TabsDiscardFunction::TabsDiscardFunction() {} | 2155 TabsDiscardFunction::TabsDiscardFunction() {} |
2113 TabsDiscardFunction::~TabsDiscardFunction() {} | 2156 TabsDiscardFunction::~TabsDiscardFunction() {} |
2114 | 2157 |
2115 } // namespace extensions | 2158 } // namespace extensions |
OLD | NEW |