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