| Index: chrome/browser/ui/extensions/shell_window.cc
|
| diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..358d253e0dc6b9d5484fcce374f607e2bfeeabec
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/extensions/shell_window.cc
|
| @@ -0,0 +1,56 @@
|
| +// 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.
|
| +
|
| +#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"
|
| +
|
| +#if defined(TOOLKIT_USES_GTK)
|
| +#include "chrome/browser/ui/gtk/extensions/shell_window_gtk.h"
|
| +#endif
|
| +
|
| +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);
|
| +
|
| +#if defined(TOOLKIT_USES_GTK)
|
| + // This object will delete itself when the window is closed.
|
| + return new ShellWindowGtk(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";
|
| + }
|
| +}
|
|
|