diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc index d11727433a7aaf..928175910b0f15 100644 --- a/chrome/browser/extensions/api/tabs/tabs_api.cc +++ b/chrome/browser/extensions/api/tabs/tabs_api.cc @@ -95,6 +95,11 @@ #include "ui/base/models/list_selection_model.h" #include "ui/base/ui_base_types.h" +#if defined(USE_ASH) +#include "chrome/browser/extensions/api/tabs/ash_panel_contents.h" // nogncheck +#include "extensions/browser/app_window/app_window_registry.h" // nogncheck +#endif + using content::BrowserThread; using content::NavigationController; using content::NavigationEntry; @@ -481,6 +486,7 @@ ExtensionFunction::ResponseAction WindowsCreateFunction::Run() { Browser::Type window_type = Browser::TYPE_TABBED; #if defined(USE_ASH) + bool create_ash_panel = false; bool saw_focus_key = false; #endif // defined(USE_ASH) @@ -503,6 +509,18 @@ ExtensionFunction::ResponseAction WindowsCreateFunction::Run() { case windows::CREATE_TYPE_PANEL: { extension_id = extension()->id(); +#if defined(USE_ASH) + // Only ChromeOS' version of chrome.windows.create would create a panel + // window. It is whitelisted to Hangouts extension for limited time until + // it transitioned to other types of windows. + for (const char* id : extension_misc::kHangoutsExtensionIds) { + if (extension_id == id) { + create_ash_panel = true; + break; + } + } +#endif // defined(USE_ASH) + // Everything else gets POPUP instead of PANEL. // TODO(dimich): Eventually, remove the 'panel' values form valid // window.create parameters. However, this is a more breaking change, so // for now simply treat it as a POPUP. @@ -555,6 +573,31 @@ ExtensionFunction::ResponseAction WindowsCreateFunction::Run() { } } +#if defined(USE_ASH) + if (create_ash_panel) { + if (urls.empty()) + urls.push_back(GURL(chrome::kChromeUINewTabURL)); + + AppWindow::CreateParams create_params; + create_params.window_type = AppWindow::WINDOW_TYPE_V1_PANEL; + create_params.window_key = extension_id; + create_params.window_spec.bounds = window_bounds; + create_params.focused = saw_focus_key && focused; + AppWindow* app_window = + new AppWindow(window_profile, new ChromeAppDelegate(true), extension()); + AshPanelContents* ash_panel_contents = new AshPanelContents(app_window); + app_window->Init(urls[0], ash_panel_contents, render_frame_host(), + create_params); + WindowController* window_controller = + WindowControllerList::GetInstance()->FindWindowById( + app_window->session_id().id()); + if (!window_controller) + return RespondNow(Error(kUnknownErrorDoNotUse)); + return RespondNow( + OneArgument(window_controller->CreateWindowValueWithTabs(extension()))); + } +#endif // defined(USE_ASH) + // Create a new BrowserWindow. Browser::CreateParams create_params(window_type, window_profile, user_gesture()); diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc index df2cbdf263b613..c3c8d51c35b5d5 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc +++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc @@ -88,7 +88,9 @@ void RecordUMAForTransferredWindowType(aura::Window* window) { } if (app_window) { if (app_window->window_type() == - extensions::AppWindow::WINDOW_TYPE_PANEL) { + extensions::AppWindow::WINDOW_TYPE_PANEL || + app_window->window_type() == + extensions::AppWindow::WINDOW_TYPE_V1_PANEL) { window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_PANEL; } else { window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_V2_APP; diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc index b710598e5247d6..a3d48e9b5f50bb 100644 --- a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc +++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc @@ -360,7 +360,8 @@ void ChromeNativeAppWindowViews::InitializeWindow( has_frame_color_ = create_params.has_frame_color; active_frame_color_ = create_params.active_frame_color; inactive_frame_color_ = create_params.inactive_frame_color; - if (create_params.window_type == AppWindow::WINDOW_TYPE_PANEL) { + if (create_params.window_type == AppWindow::WINDOW_TYPE_PANEL || + create_params.window_type == AppWindow::WINDOW_TYPE_V1_PANEL) { InitializePanelWindow(create_params); } else { InitializeDefaultWindow(create_params); diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc index 3f241347710922..ef0430f6ed48a8 100644 --- a/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc +++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc @@ -166,6 +166,7 @@ void ChromeNativeAppWindowViewsAuraAsh::OnBeforeWidgetInit( } } DCHECK_NE(AppWindow::WINDOW_TYPE_PANEL, create_params.window_type); + DCHECK_NE(AppWindow::WINDOW_TYPE_V1_PANEL, create_params.window_type); init_params->mus_properties [ui::mojom::WindowManager::kRemoveStandardFrame_InitProperty] = mojo::ConvertTo>(init_params->remove_standard_frame); diff --git a/extensions/browser/app_window/app_window.h b/extensions/browser/app_window/app_window.h index a850d7137c0ff2..72d3090fdef64c 100644 --- a/extensions/browser/app_window/app_window.h +++ b/extensions/browser/app_window/app_window.h @@ -94,6 +94,8 @@ class AppWindow : public content::WebContentsDelegate, enum WindowType { WINDOW_TYPE_DEFAULT = 1 << 0, // Default app window. WINDOW_TYPE_PANEL = 1 << 1, // OS controlled panel window (Ash only). + WINDOW_TYPE_V1_PANEL = 1 << 2, // For apps v1 support in Ash; deprecate + // with v1 apps. }; enum Frame { @@ -233,7 +235,8 @@ class AppWindow : public content::WebContentsDelegate, content::WebContents* web_contents() const; WindowType window_type() const { return window_type_; } bool window_type_is_panel() const { - return window_type_ == WINDOW_TYPE_PANEL; + return (window_type_ == WINDOW_TYPE_PANEL || + window_type_ == WINDOW_TYPE_V1_PANEL); } content::BrowserContext* browser_context() const { return browser_context_; } const gfx::Image& app_icon() const { return app_icon_; } diff --git a/extensions/components/native_app_window/native_app_window_views.cc b/extensions/components/native_app_window/native_app_window_views.cc index ba2d185f894704..e2818e20f10719 100644 --- a/extensions/components/native_app_window/native_app_window_views.cc +++ b/extensions/components/native_app_window/native_app_window_views.cc @@ -227,7 +227,11 @@ base::string16 NativeAppWindowViews::GetWindowTitle() const { } bool NativeAppWindowViews::ShouldShowWindowTitle() const { - return false; + return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL; +} + +bool NativeAppWindowViews::ShouldShowWindowIcon() const { + return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL; } void NativeAppWindowViews::SaveWindowPlacement(const gfx::Rect& bounds, diff --git a/extensions/components/native_app_window/native_app_window_views.h b/extensions/components/native_app_window/native_app_window_views.h index f89c2631d1fe22..b5213a0f624caa 100644 --- a/extensions/components/native_app_window/native_app_window_views.h +++ b/extensions/components/native_app_window/native_app_window_views.h @@ -95,6 +95,7 @@ class NativeAppWindowViews : public extensions::NativeAppWindow, bool CanMinimize() const override; base::string16 GetWindowTitle() const override; bool ShouldShowWindowTitle() const override; + bool ShouldShowWindowIcon() const override; void SaveWindowPlacement(const gfx::Rect& bounds, ui::WindowShowState show_state) override; void DeleteDelegate() override;