| 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.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 std::string type_str; | 547 std::string type_str; |
| 548 if (args->HasKey(keys::kWindowTypeKey)) { | 548 if (args->HasKey(keys::kWindowTypeKey)) { |
| 549 EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kWindowTypeKey, | 549 EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kWindowTypeKey, |
| 550 &type_str)); | 550 &type_str)); |
| 551 if (type_str == keys::kWindowTypeValuePopup) { | 551 if (type_str == keys::kWindowTypeValuePopup) { |
| 552 window_type = Browser::TYPE_POPUP; | 552 window_type = Browser::TYPE_POPUP; |
| 553 extension_id = GetExtension()->id(); | 553 extension_id = GetExtension()->id(); |
| 554 } else if (type_str == keys::kWindowTypeValuePanel) { | 554 } else if (type_str == keys::kWindowTypeValuePanel) { |
| 555 extension_id = GetExtension()->id(); | 555 extension_id = GetExtension()->id(); |
| 556 bool use_panels = false; | 556 bool use_panels = false; |
| 557 #if !defined(OS_ANDROID) | 557 #if !defined(OS_ANDROID) && !defined(USE_ASH) |
| 558 use_panels = PanelManager::ShouldUsePanels(extension_id); | 558 use_panels = PanelManager::ShouldUsePanels(extension_id); |
| 559 #endif | 559 #endif |
| 560 #if defined(USE_ASH) | |
| 561 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 562 ash::switches::kAuraPanelManager)) | |
| 563 use_panels = true; | |
| 564 #endif | |
| 565 if (use_panels) | 560 if (use_panels) |
| 566 window_type = Browser::TYPE_PANEL; | 561 window_type = Browser::TYPE_PANEL; |
| 567 else | 562 else |
| 568 window_type = Browser::TYPE_POPUP; | 563 window_type = Browser::TYPE_POPUP; |
| 569 } else if (type_str != keys::kWindowTypeValueNormal) { | 564 } else if (type_str != keys::kWindowTypeValueNormal) { |
| 570 error_ = keys::kInvalidWindowTypeError; | 565 error_ = keys::kInvalidWindowTypeError; |
| 571 return false; | 566 return false; |
| 572 } | 567 } |
| 573 } | 568 } |
| 574 } | 569 } |
| 575 | 570 |
| 576 if (window_type == Browser::TYPE_PANEL) { | 571 if (window_type == Browser::TYPE_PANEL) { |
| 577 std::string title = | 572 std::string title = |
| 578 web_app::GenerateApplicationNameFromExtensionId(extension_id); | 573 web_app::GenerateApplicationNameFromExtensionId(extension_id); |
| 579 #if defined(USE_ASH) | 574 #if !defined(USE_ASH) |
| 580 // Aura Panels create a new PanelViewAura. | |
| 581 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 582 ash::switches::kAuraPanelManager)) { | |
| 583 // Note: Panels ignore all but the first url provided. | |
| 584 PanelViewAura* panel_view = new PanelViewAura(title); | |
| 585 panel_view->Init(window_profile, urls[0], panel_bounds); | |
| 586 result_.reset(panel_view->extension_window_controller()-> | |
| 587 CreateWindowValueWithTabs()); | |
| 588 return true; | |
| 589 } | |
| 590 #else | |
| 591 if (CommandLine::ForCurrentProcess()->HasSwitch( | 575 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 592 switches::kBrowserlessPanels)) { | 576 switches::kBrowserlessPanels)) { |
| 593 // Note: Panels ignore all but the first url provided. | 577 // Note: Panels ignore all but the first url provided. |
| 594 Panel* panel = PanelManager::GetInstance()->CreatePanel( | 578 Panel* panel = PanelManager::GetInstance()->CreatePanel( |
| 595 title, window_profile, urls[0], panel_bounds.size()); | 579 title, window_profile, urls[0], panel_bounds.size()); |
| 596 | 580 |
| 597 // Unlike other window types, Panels do not take focus by default. | 581 // Unlike other window types, Panels do not take focus by default. |
| 598 if (!saw_focus_key || !focused) | 582 if (!saw_focus_key || !focused) |
| 599 panel->ShowInactive(); | 583 panel->ShowInactive(); |
| 600 else | 584 else |
| (...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 // called for every API call the extension made. | 1810 // called for every API call the extension made. |
| 1827 GotLanguage(language); | 1811 GotLanguage(language); |
| 1828 } | 1812 } |
| 1829 | 1813 |
| 1830 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1814 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
| 1831 result_.reset(Value::CreateStringValue(language.c_str())); | 1815 result_.reset(Value::CreateStringValue(language.c_str())); |
| 1832 SendResponse(true); | 1816 SendResponse(true); |
| 1833 | 1817 |
| 1834 Release(); // Balanced in Run() | 1818 Release(); // Balanced in Run() |
| 1835 } | 1819 } |
| OLD | NEW |