summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-07 03:44:00 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-07 03:44:00 +0000
commit382f975acaf866d18b67c092381fd7f71f60968a (patch)
tree14917f3b32e2442226160128253e910da649786b
parentdbb66e6bf4914172a96f5121b1ffcad73fb0826d (diff)
downloadchromium_src-382f975acaf866d18b67c092381fd7f71f60968a.zip
chromium_src-382f975acaf866d18b67c092381fd7f71f60968a.tar.gz
chromium_src-382f975acaf866d18b67c092381fd7f71f60968a.tar.bz2
Revert 116803 - Don't use browser windows for platform app shell windows.
This frees platform apps from having to disable browser behaviors they don't want (e.g. keyboard shortcuts). Reverts part of r112378, which add a "shell" browser window type, and redoes part of r114162 to not depend on browser windows when checking if the context menu is being displayed for a platform app. Review URL: http://codereview.chromium.org/8985008 TBR=mihaip@chromium.org Review URL: http://codereview.chromium.org/9125021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116810 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc3
-rw-r--r--chrome/browser/extensions/extension_host.cc14
-rw-r--r--chrome/browser/extensions/extension_host.h5
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc13
-rw-r--r--chrome/browser/extensions/extension_process_manager.h6
-rw-r--r--chrome/browser/extensions/platform_app_browsertest.cc102
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc57
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.h7
-rw-r--r--chrome/browser/ui/browser.cc28
-rw-r--r--chrome/browser/ui/browser.h4
-rw-r--r--chrome/browser/ui/browser_browsertest.cc8
-rw-r--r--chrome/browser/ui/extensions/shell_window.cc58
-rw-r--r--chrome/browser/ui/extensions/shell_window.h52
-rw-r--r--chrome/browser/ui/gtk/browser_titlebar.cc6
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc5
-rw-r--r--chrome/browser/ui/gtk/extensions/shell_window_gtk.cc50
-rw-r--r--chrome/browser/ui/gtk/extensions/shell_window_gtk.h36
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--chrome/common/chrome_view_type.cc3
-rw-r--r--chrome/common/chrome_view_type.h4
-rw-r--r--chrome/renderer/extensions/schema_generated_bindings.cc2
21 files changed, 108 insertions, 359 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 439a20e..831194a 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -2954,9 +2954,6 @@ void TestingAutomationProvider::GetBrowserInfo(
case chrome::VIEW_TYPE_EXTENSION_DIALOG:
type = "EXTENSION_DIALOG";
break;
- case chrome::VIEW_TYPE_APP_SHELL:
- type = "APP_SHELL";
- break;
default:
type = "unknown";
break;
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 578bf7e..9a467e5 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.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.
@@ -189,10 +189,6 @@ void ExtensionHost::CreateView(Browser* browser) {
#endif
}
-void ExtensionHost::CreateViewWithoutBrowser() {
- CreateView(NULL);
-}
-
WebContents* ExtensionHost::GetAssociatedWebContents() const {
return associated_web_contents_;
}
@@ -335,8 +331,7 @@ void ExtensionHost::DidStopLoading() {
did_stop_loading_ = true;
if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP ||
extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG ||
- extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR ||
- extension_host_type_ == chrome::VIEW_TYPE_APP_SHELL) {
+ extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) {
#if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)
if (view_.get())
view_->DidStopLoading();
@@ -359,8 +354,6 @@ void ExtensionHost::DidStopLoading() {
} else if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) {
UMA_HISTOGRAM_TIMES("Extensions.InfobarLoadTime",
since_created_.Elapsed());
- } else if (extension_host_type_ == chrome::VIEW_TYPE_APP_SHELL) {
- UMA_HISTOGRAM_TIMES("Extensions.ShellLoadTime", since_created_.Elapsed());
}
}
}
@@ -396,8 +389,7 @@ void ExtensionHost::CloseContents(WebContents* contents) {
if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP ||
extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_DIALOG ||
extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE ||
- extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR ||
- extension_host_type_ == chrome::VIEW_TYPE_APP_SHELL) {
+ extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) {
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
content::Source<Profile>(profile_),
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index 78945dc..6c73751 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -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.
@@ -71,9 +71,6 @@ class ExtensionHost : public content::WebContentsDelegate,
// instantiate Browser objects.
void CreateView(Browser* browser);
- // Helper variant of the above for cases where no Browser is present.
- void CreateViewWithoutBrowser();
-
const Extension* extension() const { return extension_; }
const std::string& extension_id() const { return extension_id_; }
content::WebContents* host_contents() const { return host_contents_.get(); }
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 99f9753..2db9472 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -116,19 +116,6 @@ ExtensionProcessManager::~ExtensionProcessManager() {
DCHECK(background_hosts_.empty());
}
-ExtensionHost* ExtensionProcessManager::CreateShellHost(
- const Extension* extension,
- const GURL& url) {
- DCHECK(extension);
- ExtensionHost* host = new ExtensionHost(extension,
- GetSiteInstanceForURL(url),
- url,
- chrome::VIEW_TYPE_APP_SHELL);
- host->CreateViewWithoutBrowser();
- OnExtensionHostCreated(host, false /* not a background host */);
- return host;
-}
-
ExtensionHost* ExtensionProcessManager::CreateViewHost(
const Extension* extension,
const GURL& url,
diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h
index 3f1f566..6553858 100644
--- a/chrome/browser/extensions/extension_process_manager.h
+++ b/chrome/browser/extensions/extension_process_manager.h
@@ -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.
@@ -33,8 +33,6 @@ class ExtensionProcessManager : public content::NotificationObserver {
static ExtensionProcessManager* Create(Profile* profile);
virtual ~ExtensionProcessManager();
- ExtensionHost* CreateShellHost(const Extension* extension, const GURL& url);
-
// Creates a new ExtensionHost with its associated view, grouping it in the
// appropriate SiteInstance (and therefore process) based on the URL and
// profile.
@@ -56,8 +54,6 @@ class ExtensionProcessManager : public content::NotificationObserver {
ExtensionHost* CreateInfobarHost(const GURL& url,
Browser* browser);
- ExtensionHost* CreateShellHost(const GURL& url, Browser* browser);
-
// Open the extension's options page.
void OpenOptionsPage(const Extension* extension, Browser* browser);
diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc
index 2e36d50..49f3721 100644
--- a/chrome/browser/extensions/platform_app_browsertest.cc
+++ b/chrome/browser/extensions/platform_app_browsertest.cc
@@ -1,10 +1,9 @@
-// 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.
#include "base/command_line.h"
#include "chrome/browser/extensions/extension_browsertest.h"
-#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/profiles/profile.h"
@@ -48,7 +47,6 @@ class PlatformAppBrowserTest : public ExtensionBrowserTest {
command_line->AppendSwitch(switches::kEnablePlatformApps);
}
- protected:
void LoadAndLaunchPlatformApp(const char* name) {
web_app::SetDisableShortcutCreationForTests(true);
EXPECT_TRUE(LoadExtension(test_data_dir_.AppendASCII("platform_apps").
@@ -59,7 +57,7 @@ class PlatformAppBrowserTest : public ExtensionBrowserTest {
last_loaded_extension_id_, false);
EXPECT_TRUE(extension);
- size_t platform_app_count = GetPlatformAppCount();
+ size_t browser_count = BrowserList::size();
Browser::OpenApplication(
browser()->profile(),
@@ -68,57 +66,51 @@ class PlatformAppBrowserTest : public ExtensionBrowserTest {
GURL(),
NEW_WINDOW);
- // Now we have a new platform app running.
- EXPECT_EQ(platform_app_count + 1, GetPlatformAppCount());
- }
-
- // Gets the number of platform apps that are running.
- size_t GetPlatformAppCount() {
- int count = 0;
- ExtensionProcessManager* process_manager =
- browser()->profile()->GetExtensionProcessManager();
- ExtensionProcessManager::const_iterator iter;
- for (iter = process_manager->begin(); iter != process_manager->end();
- ++iter) {
- ExtensionHost* host = *iter;
- if (host->extension() && host->extension()->is_platform_app())
- count++;
- }
-
- return count;
- }
-
- // Gets the WebContents associated with the ExtensionHost of the first
- // platform app that is found (most tests only deal with one platform
- // app, so this is good enough).
- WebContents* GetFirstPlatformAppWebContents() {
- ExtensionProcessManager* process_manager =
- browser()->profile()->GetExtensionProcessManager();
- ExtensionProcessManager::const_iterator iter;
- for (iter = process_manager->begin(); iter != process_manager->end();
- ++iter) {
- ExtensionHost* host = *iter;
- if (host->extension() && host->extension()->is_platform_app())
- return host->host_contents();
- }
-
- return NULL;
+ // Now we have a new browser instance.
+ EXPECT_EQ(browser_count + 1, BrowserList::size());
}
};
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenAppInShellContainer) {
- ASSERT_EQ(0u, GetPlatformAppCount());
+ // Start with one browser, new platform app will create another.
+ ASSERT_EQ(1u, BrowserList::size());
+
LoadAndLaunchPlatformApp("empty");
- ASSERT_EQ(1u, GetPlatformAppCount());
+
+ // The launch should have created a new browser, so there should be 2 now.
+ ASSERT_EQ(2u, BrowserList::size());
+
+ // The new browser is the last one.
+ BrowserList::const_reverse_iterator reverse_iterator(BrowserList::end());
+ Browser* new_browser = *(reverse_iterator++);
+
+ ASSERT_TRUE(new_browser);
+ ASSERT_TRUE(new_browser != browser());
+
+ // Expect an app in a shell window.
+ EXPECT_TRUE(new_browser->is_app());
+ EXPECT_TRUE(new_browser->is_type_shell());
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) {
+ // Start with one browser, new platform app will create another.
+ ASSERT_EQ(1u, BrowserList::size());
+
LoadAndLaunchPlatformApp("empty");
+ // The launch should have created a new browser, so there should be 2 now.
+ ASSERT_EQ(2u, BrowserList::size());
+
+ // The new browser is the last one.
+ BrowserList::const_reverse_iterator reverse_iterator(BrowserList::end());
+ Browser* new_browser = *(reverse_iterator++);
+
+ ASSERT_TRUE(new_browser);
+ ASSERT_TRUE(new_browser != browser());
+
// The empty app doesn't add any context menu items, so its menu should
// be empty.
- WebContents* web_contents = GetFirstPlatformAppWebContents();
- ASSERT_TRUE(web_contents);
+ WebContents* web_contents = new_browser->GetSelectedWebContents();
WebKit::WebContextMenuData data;
ContextMenuParams params(data);
PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents,
@@ -127,23 +119,29 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) {
ASSERT_FALSE(menu->menu_model().GetItemCount());
}
-// Disabled until shell windows are implemented on Windows.
-#if defined(OS_WIN)
-#define MAYBE_AppWithContextMenu DISABLED_AppWithContextMenu
-#else
-#define MAYBE_AppWithContextMenu AppWithContextMenu
-#endif
-IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_AppWithContextMenu) {
+IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) {
+ // Start with one browser, new platform app will create another.
+ ASSERT_EQ(1u, BrowserList::size());
+
ExtensionTestMessageListener listener1("created item", false);
LoadAndLaunchPlatformApp("context_menu");
// Wait for the extension to tell us it's created an item.
ASSERT_TRUE(listener1.WaitUntilSatisfied());
+ // The launch should have created a new browser, so there should be 2 now.
+ ASSERT_EQ(2u, BrowserList::size());
+
+ // The new browser is the last one.
+ BrowserList::const_reverse_iterator reverse_iterator(BrowserList::end());
+ Browser* new_browser = *(reverse_iterator++);
+
+ ASSERT_TRUE(new_browser);
+ ASSERT_TRUE(new_browser != browser());
+
// The context_menu app has one context menu item. This is all that should
// be in the menu, there should be no seperator.
- WebContents* web_contents = GetFirstPlatformAppWebContents();
- ASSERT_TRUE(web_contents);
+ WebContents* web_contents = new_browser->GetSelectedWebContents();
WebKit::WebContextMenuData data;
ContextMenuParams params(data);
PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents,
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 6edf617..7ce4e98 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.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.
@@ -24,7 +24,6 @@
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/extensions/extension_event_router.h"
-#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/net/browser_url_util.h"
@@ -49,12 +48,13 @@
#include "chrome/browser/translate/translate_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/print_messages.h"
#include "chrome/common/spellcheck_messages.h"
@@ -498,8 +498,7 @@ void RenderViewContextMenu::AppendAllExtensionItems() {
std::vector<std::pair<std::string, std::string> > sorted_ids;
for (std::set<std::string>::iterator i = ids.begin(); i != ids.end(); ++i) {
const Extension* extension = service->GetExtensionById(*i, false);
- // Platform apps have their context menus created directly in
- // AppendPlatformAppItems.
+ // Platform apps have their context menus created directly in InitMenu.
if (extension && !extension->is_platform_app())
sorted_ids.push_back(
std::pair<std::string, std::string>(extension->name(), *i));
@@ -523,14 +522,23 @@ void RenderViewContextMenu::AppendAllExtensionItems() {
}
void RenderViewContextMenu::InitMenu() {
- if (GetPlatformApp()) {
- AppendPlatformAppItems();
- return;
- }
-
bool has_link = !params_.unfiltered_link_url.is_empty();
bool has_selection = !params_.selection_text.empty();
+ Browser* active_browser = BrowserList::FindBrowserWithWebContents(
+ source_web_contents_);
+ if (active_browser && active_browser->is_app()) {
+ const std::string ext_id = web_app::GetExtensionIdFromApplicationName(
+ active_browser->app_name());
+ const Extension* app =
+ profile_->GetExtensionService()->GetInstalledExtension(ext_id);
+ if (app && app->is_platform_app()) {
+ int index = 0;
+ AppendExtensionItems(app->id(), &index);
+ return;
+ }
+ }
+
if (AppendCustomItems()) {
// If there's a selection, don't early return when there are custom items,
// but fall through to adding the normal ones after the custom ones.
@@ -628,35 +636,6 @@ void RenderViewContextMenu::InitMenu() {
observers_.AddObserver(print_preview_menu_observer_.get());
}
-const Extension* RenderViewContextMenu::GetPlatformApp() const {
- ExtensionProcessManager* process_manager =
- profile_->GetExtensionProcessManager();
- // There is no process manager in some tests.
- if (!process_manager) {
- return NULL;
- }
-
- ExtensionProcessManager::const_iterator iter;
- for (iter = process_manager->begin(); iter != process_manager->end();
- ++iter) {
- ExtensionHost* host = *iter;
- if (host->host_contents() == source_web_contents_) {
- if (host->extension() && host->extension()->is_platform_app()) {
- return host->extension();
- }
- }
- }
-
- return NULL;
-}
-
-void RenderViewContextMenu::AppendPlatformAppItems() {
- const Extension* platform_app = GetPlatformApp();
- DCHECK(platform_app);
- int index = 0;
- AppendExtensionItems(platform_app->id(), &index);
-}
-
void RenderViewContextMenu::LookUpInDictionary() {
// Used only in the Mac port.
NOTREACHED();
diff --git a/chrome/browser/tab_contents/render_view_context_menu.h b/chrome/browser/tab_contents/render_view_context_menu.h
index d07bb49..9bfd5edf 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.h
+++ b/chrome/browser/tab_contents/render_view_context_menu.h
@@ -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.
@@ -193,11 +193,6 @@ class RenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
const ContextMenuParams& params,
Profile* profile,
bool can_cross_incognito);
-
- // Gets the platform app (if any) associated with the TabContents that we're
- // in.
- const Extension* GetPlatformApp() const;
- void AppendPlatformAppItems();
bool AppendCustomItems();
void AppendDeveloperItems();
void AppendLinkItems();
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 3e47044..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_USES_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_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 3a4e24d..328f875 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2965,8 +2965,6 @@
'browser/ui/crypto_module_password_dialog_nss.cc',
'browser/ui/crypto_module_password_dialog_openssl.cc',
'browser/ui/dialog_style.h',
- 'browser/ui/extensions/shell_window.cc',
- 'browser/ui/extensions/shell_window.h',
'browser/ui/find_bar/find_bar.h',
'browser/ui/find_bar/find_bar_controller.cc',
'browser/ui/find_bar/find_bar_controller.h',
@@ -3062,8 +3060,6 @@
'browser/ui/gtk/extensions/extension_uninstall_dialog_gtk.cc',
'browser/ui/gtk/extensions/extension_view_gtk.cc',
'browser/ui/gtk/extensions/extension_view_gtk.h',
- 'browser/ui/gtk/extensions/shell_window_gtk.cc',
- 'browser/ui/gtk/extensions/shell_window_gtk.h',
'browser/ui/gtk/external_protocol_dialog_gtk.cc',
'browser/ui/gtk/external_protocol_dialog_gtk.h',
'browser/ui/gtk/find_bar_gtk.cc',
diff --git a/chrome/common/chrome_view_type.cc b/chrome/common/chrome_view_type.cc
index b41c1a1..8d5ffba 100644
--- a/chrome/common/chrome_view_type.cc
+++ b/chrome/common/chrome_view_type.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.
@@ -11,6 +11,5 @@ const char kViewTypePopup[] = "POPUP";
const char kViewTypeInfobar[] = "INFOBAR";
const char kViewTypeNotification[] = "NOTIFICATION";
const char kViewTypeExtensionDialog[] = "EXTENSION_DIALOG";
-const char kViewTypeAppShell[] = "SHELL";
const char kViewTypeAll[] = "ALL";
} // namespace chrome
diff --git a/chrome/common/chrome_view_type.h b/chrome/common/chrome_view_type.h
index d716fe1..926c1bd 100644
--- a/chrome/common/chrome_view_type.h
+++ b/chrome/common/chrome_view_type.h
@@ -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.
@@ -20,7 +20,6 @@ enum ViewType {
VIEW_TYPE_EXTENSION_INFOBAR,
VIEW_TYPE_NOTIFICATION,
VIEW_TYPE_EXTENSION_DIALOG,
- VIEW_TYPE_APP_SHELL,
};
// Constant strings corresponding to the Type enumeration values. Used
@@ -31,7 +30,6 @@ extern const char kViewTypePopup[];
extern const char kViewTypeInfobar[];
extern const char kViewTypeNotification[];
extern const char kViewTypeExtensionDialog[];
-extern const char kViewTypeAppShell[];
extern const char kViewTypeAll[];
} // namespace chrome
diff --git a/chrome/renderer/extensions/schema_generated_bindings.cc b/chrome/renderer/extensions/schema_generated_bindings.cc
index 8d5ff85..1c5b76d 100644
--- a/chrome/renderer/extensions/schema_generated_bindings.cc
+++ b/chrome/renderer/extensions/schema_generated_bindings.cc
@@ -312,8 +312,6 @@ class ExtensionImpl : public ChromeV8Extension {
view_type = chrome::VIEW_TYPE_EXTENSION_POPUP;
} else if (view_type_string == chrome::kViewTypeExtensionDialog) {
view_type = chrome::VIEW_TYPE_EXTENSION_DIALOG;
- } else if (view_type_string == chrome::kViewTypeAppShell) {
- view_type = chrome::VIEW_TYPE_APP_SHELL;
} else if (view_type_string != chrome::kViewTypeAll) {
return v8::Undefined();
}