diff options
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r-- | chrome/browser/ui/browser.cc | 28 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/browser_browsertest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/ui/extensions/shell_window.cc | 58 | ||||
-rw-r--r-- | chrome/browser/ui/extensions/shell_window.h | 52 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/browser_titlebar.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/browser_window_gtk.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/extensions/shell_window_gtk.cc | 50 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/extensions/shell_window_gtk.h | 36 |
9 files changed, 32 insertions, 215 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 8586e02..118bdd8 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -49,6 +49,7 @@ #include "chrome/browser/extensions/default_apps_trial.h" #include "chrome/browser/extensions/extension_browser_event_router.h" #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h" +#include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_prefs.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_tab_helper.h" @@ -102,7 +103,6 @@ #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/constrained_window_tab_helper.h" -#include "chrome/browser/ui/extensions/shell_window.h" #include "chrome/browser/ui/find_bar/find_bar.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" #include "chrome/browser/ui/find_bar/find_tab_helper.h" @@ -649,17 +649,9 @@ WebContents* Browser::OpenApplication( UMA_HISTOGRAM_ENUMERATION("Extensions.AppLaunchContainer", container, 100); switch (container) { - case extension_misc::LAUNCH_SHELL: { - ShellWindow* shell_window = ShellWindow::Create( - profile, - extension, - UrlForExtension(extension, override_url)); - if (shell_window) - tab = shell_window->web_contents(); - break; - } case extension_misc::LAUNCH_WINDOW: case extension_misc::LAUNCH_PANEL: + case extension_misc::LAUNCH_SHELL: tab = Browser::OpenApplicationWindow(profile, extension, container, override_url, NULL); break; @@ -690,8 +682,18 @@ WebContents* Browser::OpenApplicationWindow( web_app::GenerateApplicationNameFromExtensionId(extension->id()) : web_app::GenerateApplicationNameFromURL(url); - Type type = extension && (container == extension_misc::LAUNCH_PANEL) ? - TYPE_PANEL : TYPE_POPUP; + Type type = TYPE_POPUP; + if (extension) { + switch (container) { + case extension_misc::LAUNCH_PANEL: + type = TYPE_PANEL; + break; + case extension_misc::LAUNCH_SHELL: + type = TYPE_SHELL; + break; + default: break; + } + } gfx::Rect window_bounds; if (extension) { @@ -912,6 +914,8 @@ bool Browser::ShouldSaveWindowPlacement() const { case TYPE_PANEL: // Do not save the window placement of panels. return false; + case TYPE_SHELL: + return true; default: return false; } diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 4eb9744..d1a0f92 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -102,7 +102,8 @@ class Browser : public TabHandlerDelegate, // BrowserTest.StartMaximized. TYPE_TABBED = 1, TYPE_POPUP = 2, - TYPE_PANEL = 3 + TYPE_PANEL = 3, + TYPE_SHELL = 4 }; // Possible elements of the Browser window. @@ -850,6 +851,7 @@ class Browser : public TabHandlerDelegate, bool is_type_tabbed() const { return type_ == TYPE_TABBED; } bool is_type_popup() const { return type_ == TYPE_POPUP; } bool is_type_panel() const { return type_ == TYPE_PANEL; } + bool is_type_shell() const { return type_ == TYPE_SHELL; } bool is_app() const; bool is_devtools() const; diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index 9c411575..c0c4dac 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -1116,7 +1116,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { IN_PROC_BROWSER_TEST_F(BrowserTest, StartMaximized) { // Can't test TYPE_PANEL as they are currently created differently (and can't // end up maximized). - Browser::Type types[] = { Browser::TYPE_TABBED, Browser::TYPE_POPUP }; + Browser::Type types[] = + { Browser::TYPE_TABBED, Browser::TYPE_POPUP, Browser::TYPE_SHELL }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(types); ++i) { Browser* max_browser = new Browser(types[i], browser()->profile()); max_browser->set_show_state(ui::SHOW_STATE_MAXIMIZED); @@ -1136,7 +1137,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, StartMaximized) { IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_StartMinimized) { // Can't test TYPE_PANEL as they are currently created differently (and can't // end up minimized). - Browser::Type types[] = { Browser::TYPE_TABBED, Browser::TYPE_POPUP }; + Browser::Type types[] = + { Browser::TYPE_TABBED, Browser::TYPE_POPUP, Browser::TYPE_SHELL }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(types); ++i) { Browser* min_browser = new Browser(types[i], browser()->profile()); min_browser->set_show_state(ui::SHOW_STATE_MINIMIZED); diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc deleted file mode 100644 index 0a21d5c..0000000 --- a/chrome/browser/ui/extensions/shell_window.cc +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/extensions/shell_window.h" - -#include "chrome/browser/extensions/extension_process_manager.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/common/chrome_notification_types.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/notification_source.h" - -ShellWindow::ShellWindow(ExtensionHost* host) - : host_(host) { - // Close the window in response to window.close() and the like. - registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, - content::Source<Profile>(host->profile())); -} - -ShellWindow::~ShellWindow() { -} - -ShellWindow* ShellWindow::Create(Profile* profile, - const Extension* extension, - const GURL& url) { - ExtensionProcessManager* manager = profile->GetExtensionProcessManager(); - DCHECK(manager); - if (!manager) - return NULL; - - ExtensionHost* host = manager->CreateShellHost(extension, url); - // CHECK host so that non-GTK platform compilers don't complain about unused - // variables. - // TODO(mihaip): remove when ShellWindow has been implemented everywhere. - CHECK(host); - -#if defined(TOOLKIT_GTK) - // This object will delete itself when the window is closed. - // TODO(mihaip): remove the #if block when ShellWindow has been implemented - // everywhere. - return ShellWindow::CreateShellWindow(host); -#endif - - return NULL; -} - -void ShellWindow::Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - switch (type) { - case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: - if (content::Details<ExtensionHost>(host_.get()) == details) - Close(); - break; - default: - NOTREACHED() << "Received unexpected notification"; - } -} diff --git a/chrome/browser/ui/extensions/shell_window.h b/chrome/browser/ui/extensions/shell_window.h deleted file mode 100644 index ce5f957..0000000 --- a/chrome/browser/ui/extensions/shell_window.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ -#define CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ -#pragma once - -#include "base/memory/scoped_ptr.h" -#include "chrome/browser/extensions/extension_host.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" - -class GURL; -class Extension; -class ExtensionHost; -class Profile; - -namespace content { -class WebContents; -} - -class ShellWindow : public content::NotificationObserver { - public: - content::WebContents* web_contents() const { return host_->host_contents(); } - - static ShellWindow* Create(Profile* profile, - const Extension* extension, - const GURL& url); - - // Closes the displayed window and invokes the destructor. - virtual void Close() = 0; - - // content::NotificationObserver implementation. - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - - protected: - explicit ShellWindow(ExtensionHost* host_); - virtual ~ShellWindow(); - - // Instantiates a platform-specific ShellWindow subclass (one implementation - // per platform). Public users of ShellWindow should use ShellWindow::Create. - static ShellWindow* CreateShellWindow(ExtensionHost* host); - - scoped_ptr<ExtensionHost> host_; - - content::NotificationRegistrar registrar_; -}; - -#endif // CHROME_BROWSER_UI_EXTENSIONS_SHELL_WINDOW_H_ diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc index 6ccafe8..c304558 100644 --- a/chrome/browser/ui/gtk/browser_titlebar.cc +++ b/chrome/browser/ui/gtk/browser_titlebar.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -627,6 +627,10 @@ void BrowserTitlebar::UpdateTitleAndIcon() { NOTREACHED() << "We should never have a tabbed app window."; break; } + case Browser::TYPE_SHELL: { + // Shell windows don't show titles and icons for now. + break; + } case Browser::TYPE_PANEL: { break; } diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index b2f1970..47cc23c 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -1981,7 +1981,8 @@ void BrowserWindowGtk::ConnectAccelerators() { } void BrowserWindowGtk::UpdateCustomFrame() { - gtk_window_set_decorated(window_, !UseCustomFrame()); + gtk_window_set_decorated( + window_, !UseCustomFrame() && browser_->type() != Browser::TYPE_SHELL); titlebar_->UpdateCustomFrame(UseCustomFrame() && !IsFullscreen()); UpdateWindowShape(bounds_.width(), bounds_.height()); } diff --git a/chrome/browser/ui/gtk/extensions/shell_window_gtk.cc b/chrome/browser/ui/gtk/extensions/shell_window_gtk.cc deleted file mode 100644 index 525a7dc..0000000 --- a/chrome/browser/ui/gtk/extensions/shell_window_gtk.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/gtk/extensions/shell_window_gtk.h" - -#include "chrome/browser/extensions/extension_host.h" -#include "content/browser/renderer_host/render_widget_host_view_gtk.h" - -ShellWindowGtk::ShellWindowGtk(ExtensionHost* host) - : ShellWindow(host) { - host_->view()->SetContainer(this); - window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); - - gtk_container_add(GTK_CONTAINER(window_), host_->view()->native_view()); - - // TOOD(mihaip): Allow window dimensions to be specified in manifest (and - // restore prior window dimensions and positions on relaunch). - gtk_widget_set_size_request(GTK_WIDGET(window_), 512, 384); - gtk_window_set_decorated(window_, false); - - g_signal_connect(window_, "delete-event", - G_CALLBACK(OnMainWindowDeleteEventThunk), this); - - gtk_window_present(window_); -} - -ShellWindowGtk::~ShellWindowGtk() { -} - -void ShellWindowGtk::Close() { - gtk_widget_destroy(GTK_WIDGET(window_)); - delete this; -} - -// Callback for the delete event. This event is fired when the user tries to -// close the window (e.g., clicking on the X in the window manager title bar). -gboolean ShellWindowGtk::OnMainWindowDeleteEvent(GtkWidget* widget, - GdkEvent* event) { - Close(); - - // Return true to prevent the GTK window from being destroyed. Close will - // destroy it for us. - return TRUE; -} - -// static -ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { - return new ShellWindowGtk(host); -} diff --git a/chrome/browser/ui/gtk/extensions/shell_window_gtk.h b/chrome/browser/ui/gtk/extensions/shell_window_gtk.h deleted file mode 100644 index 5c4ebb0..0000000 --- a/chrome/browser/ui/gtk/extensions/shell_window_gtk.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_SHELL_WINDOW_GTK_H_ -#define CHROME_BROWSER_UI_GTK_EXTENSIONS_SHELL_WINDOW_GTK_H_ -#pragma once - -#include <gtk/gtk.h> - -#include "chrome/browser/ui/extensions/shell_window.h" -#include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" -#include "ui/base/gtk/gtk_signal.h" - -class ExtensionHost; - -class ShellWindowGtk : public ShellWindow, - public ExtensionViewGtk::Container { - public: - explicit ShellWindowGtk(ExtensionHost* host); - - // ShellWindow implementation. - virtual void Close() OVERRIDE; - - private: - virtual ~ShellWindowGtk(); - - CHROMEGTK_CALLBACK_1(ShellWindowGtk, gboolean, OnMainWindowDeleteEvent, - GdkEvent*); - - GtkWindow* window_; - - DISALLOW_COPY_AND_ASSIGN(ShellWindowGtk); -}; - -#endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_SHELL_WINDOW_GTK_H_ |