Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4968)

Unified Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 10920084: don't display platform app resources in normal browser windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self review Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/ui/browser_navigator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/platform_app_browsertest.cc
diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc
index 636ee305a463e099b79fa2c63f17ca94aa99fc41..8ecde65a705abd381e8f34c1b835afbbb7ec4ee3 100644
--- a/chrome/browser/extensions/platform_app_browsertest.cc
+++ b/chrome/browser/extensions/platform_app_browsertest.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/extensions/shell_window.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_intents_dispatcher.h"
@@ -99,6 +100,36 @@ class LaunchReplyHandler {
base::WeakPtrFactory<LaunchReplyHandler> weak_ptr_factory_;
};
+// This class keeps track of tabs as they are added to the browser. It will be
+// "done" (i.e. won't block on Wait()) once |observations| tabs have been added.
+class TabsAddedNotificationObserver :
Lei Zhang 2012/09/28 18:50:31 nit: I think the linter will be happier if you put
+ public content::WindowedNotificationObserver {
+ public:
+ explicit TabsAddedNotificationObserver(size_t observations)
+ : content::WindowedNotificationObserver(
+ chrome::NOTIFICATION_TAB_ADDED,
+ content::NotificationService::AllSources()),
+ observations_(observations) {
+ }
+
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE {
+ observed_tabs_.push_back(
+ content::Details<WebContents>(details).ptr());
+ if (observed_tabs_.size() == observations_)
+ content::WindowedNotificationObserver::Observe(type, source, details);
+ }
+
+ const std::vector<content::WebContents*>& tabs() { return observed_tabs_; }
+
+ private:
+ size_t observations_;
+ std::vector<content::WebContents*> observed_tabs_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabsAddedNotificationObserver);
+};
+
const char kTestFilePath[] = "platform_apps/launch_files/test.txt";
} // namespace
@@ -318,8 +349,17 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenuClicked) {
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) {
+ TabsAddedNotificationObserver observer(2);
+
ASSERT_TRUE(StartTestServer());
ASSERT_TRUE(RunPlatformAppTest("platform_apps/navigation")) << message_;
+
+ observer.Wait();
+ ASSERT_EQ(2U, observer.tabs().size());
+ EXPECT_EQ(chrome::kExtensionInvalidRequestURL,
+ observer.tabs()[0]->GetURL().spec());
+ EXPECT_EQ("http://chromium.org/",
+ observer.tabs()[1]->GetURL().spec());
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Iframes) {
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/ui/browser_navigator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698