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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 break; | 457 break; |
458 case windows::Create::Params::CreateData::TYPE_PANEL: | 458 case windows::Create::Params::CreateData::TYPE_PANEL: |
459 case windows::Create::Params::CreateData::TYPE_DETACHED_PANEL: { | 459 case windows::Create::Params::CreateData::TYPE_DETACHED_PANEL: { |
460 extension_id = GetExtension()->id(); | 460 extension_id = GetExtension()->id(); |
461 bool use_panels = false; | 461 bool use_panels = false; |
462 #if !defined(OS_ANDROID) | 462 #if !defined(OS_ANDROID) |
463 use_panels = PanelManager::ShouldUsePanels(extension_id); | 463 use_panels = PanelManager::ShouldUsePanels(extension_id); |
464 #endif | 464 #endif |
465 if (use_panels) { | 465 if (use_panels) { |
466 create_panel = true; | 466 create_panel = true; |
467 #if !defined(OS_CHROMEOS) | 467 // Non-ash supports both docked and detached panel types. |
468 // Non-ChromeOS has both docked and detached panel types. | 468 if (chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH && |
469 if (create_data->type == | 469 create_data->type == |
470 windows::Create::Params::CreateData::TYPE_DETACHED_PANEL) { | 470 windows::Create::Params::CreateData::TYPE_DETACHED_PANEL) { |
471 panel_create_mode = PanelManager::CREATE_AS_DETACHED; | 471 panel_create_mode = PanelManager::CREATE_AS_DETACHED; |
472 } | 472 } |
473 #endif | |
474 } else { | 473 } else { |
475 window_type = Browser::TYPE_POPUP; | 474 window_type = Browser::TYPE_POPUP; |
476 } | 475 } |
477 break; | 476 break; |
478 } | 477 } |
479 case windows::Create::Params::CreateData::TYPE_NONE: | 478 case windows::Create::Params::CreateData::TYPE_NONE: |
480 case windows::Create::Params::CreateData::TYPE_NORMAL: | 479 case windows::Create::Params::CreateData::TYPE_NORMAL: |
481 break; | 480 break; |
482 default: | 481 default: |
483 error_ = keys::kInvalidWindowTypeError; | 482 error_ = keys::kInvalidWindowTypeError; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 if (create_data->focused) { | 523 if (create_data->focused) { |
525 focused = *create_data->focused; | 524 focused = *create_data->focused; |
526 saw_focus_key = true; | 525 saw_focus_key = true; |
527 } | 526 } |
528 } | 527 } |
529 | 528 |
530 if (create_panel) { | 529 if (create_panel) { |
531 if (urls.empty()) | 530 if (urls.empty()) |
532 urls.push_back(GURL(chrome::kChromeUINewTabURL)); | 531 urls.push_back(GURL(chrome::kChromeUINewTabURL)); |
533 | 532 |
534 #if defined(OS_CHROMEOS) | 533 #if defined(USE_ASH) |
535 if (PanelManager::ShouldUsePanels(extension_id)) { | 534 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) { |
536 ShellWindow::CreateParams create_params; | 535 ShellWindow::CreateParams create_params; |
537 create_params.window_type = ShellWindow::WINDOW_TYPE_V1_PANEL; | 536 create_params.window_type = ShellWindow::WINDOW_TYPE_V1_PANEL; |
538 create_params.bounds = window_bounds; | 537 create_params.bounds = window_bounds; |
539 create_params.focused = saw_focus_key && focused; | 538 create_params.focused = saw_focus_key && focused; |
540 ShellWindow* shell_window = new ShellWindow( | 539 ShellWindow* shell_window = new ShellWindow( |
541 window_profile, new ChromeShellWindowDelegate(), | 540 window_profile, new ChromeShellWindowDelegate(), |
542 GetExtension()); | 541 GetExtension()); |
543 AshPanelContents* ash_panel_contents = new AshPanelContents(shell_window); | 542 AshPanelContents* ash_panel_contents = new AshPanelContents(shell_window); |
544 shell_window->Init(urls[0], ash_panel_contents, create_params); | 543 shell_window->Init(urls[0], ash_panel_contents, create_params); |
545 SetResult(ash_panel_contents->GetExtensionWindowController()-> | 544 SetResult(ash_panel_contents->GetExtensionWindowController()-> |
546 CreateWindowValueWithTabs(GetExtension())); | 545 CreateWindowValueWithTabs(GetExtension())); |
547 return true; | 546 return true; |
548 } | 547 } |
549 #else | 548 #endif |
550 std::string title = | 549 std::string title = |
551 web_app::GenerateApplicationNameFromExtensionId(extension_id); | 550 web_app::GenerateApplicationNameFromExtensionId(extension_id); |
552 // Note: Panels ignore all but the first url provided. | 551 // Note: Panels ignore all but the first url provided. |
553 Panel* panel = PanelManager::GetInstance()->CreatePanel( | 552 Panel* panel = PanelManager::GetInstance()->CreatePanel( |
554 title, window_profile, urls[0], window_bounds, panel_create_mode); | 553 title, window_profile, urls[0], window_bounds, panel_create_mode); |
555 | 554 |
556 // Unlike other window types, Panels do not take focus by default. | 555 // Unlike other window types, Panels do not take focus by default. |
557 if (!saw_focus_key || !focused) | 556 if (!saw_focus_key || !focused) |
558 panel->ShowInactive(); | 557 panel->ShowInactive(); |
559 else | 558 else |
560 panel->Show(); | 559 panel->Show(); |
561 | 560 |
562 SetResult( | 561 SetResult( |
563 panel->extension_window_controller()->CreateWindowValueWithTabs( | 562 panel->extension_window_controller()->CreateWindowValueWithTabs( |
564 GetExtension())); | 563 GetExtension())); |
565 return true; | 564 return true; |
566 #endif | |
567 } | 565 } |
568 | 566 |
569 // Create a new BrowserWindow. | 567 // Create a new BrowserWindow. |
570 chrome::HostDesktopType host_desktop_type = chrome::GetActiveDesktop(); | 568 chrome::HostDesktopType host_desktop_type = chrome::GetActiveDesktop(); |
571 if (create_panel) | 569 if (create_panel) |
572 window_type = Browser::TYPE_POPUP; | 570 window_type = Browser::TYPE_POPUP; |
573 Browser::CreateParams create_params(window_type, window_profile, | 571 Browser::CreateParams create_params(window_type, window_profile, |
574 host_desktop_type); | 572 host_desktop_type); |
575 if (extension_id.empty()) { | 573 if (extension_id.empty()) { |
576 create_params.initial_bounds = window_bounds; | 574 create_params.initial_bounds = window_bounds; |
(...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2067 execute_tab_id_ = tab_id; | 2065 execute_tab_id_ = tab_id; |
2068 details_ = details.Pass(); | 2066 details_ = details.Pass(); |
2069 return true; | 2067 return true; |
2070 } | 2068 } |
2071 | 2069 |
2072 bool TabsInsertCSSFunction::ShouldInsertCSS() const { | 2070 bool TabsInsertCSSFunction::ShouldInsertCSS() const { |
2073 return true; | 2071 return true; |
2074 } | 2072 } |
2075 | 2073 |
2076 } // namespace extensions | 2074 } // namespace extensions |
OLD | NEW |