summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions')
-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
5 files changed, 55 insertions, 85 deletions
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 f0d0e52..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 for views.
-#if defined(TOOLKIT_VIEWS)
-#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,