| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 | 36 |
| 37 std::string expected_extension_id_; | 37 std::string expected_extension_id_; |
| 38 const Extension* installed_extension_; | 38 const Extension* installed_extension_; |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 // content::NotificationObserver | 41 // content::NotificationObserver |
| 42 virtual void Observe(int type, | 42 virtual void Observe(int type, |
| 43 const content::NotificationSource& source, | 43 const content::NotificationSource& source, |
| 44 const content::NotificationDetails& details) OVERRIDE { | 44 const content::NotificationDetails& details) OVERRIDE { |
| 45 if (type == chrome::NOTIFICATION_EXTENSION_INSTALLED) { | 45 if (type == chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED) { |
| 46 const Extension* extension = | 46 const Extension* extension = |
| 47 content::Details<const InstalledExtensionInfo>(details)->extension; | 47 content::Details<const InstalledExtensionInfo>(details)->extension; |
| 48 if (extension->id() == expected_extension_id_) { | 48 if (extension->id() == expected_extension_id_) { |
| 49 installed_extension_ = extension; | 49 installed_extension_ = extension; |
| 50 base::MessageLoopForUI::current()->Quit(); | 50 base::MessageLoopForUI::current()->Quit(); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // TODO(samarth): delete along with rest of the NTP4 code. | 56 // TODO(samarth): delete along with rest of the NTP4 code. |
| 57 IN_PROC_BROWSER_TEST_F(ExtensionFromWebAppTest, DISABLED_Basic) { | 57 IN_PROC_BROWSER_TEST_F(ExtensionFromWebAppTest, DISABLED_Basic) { |
| 58 #if defined(OS_WIN) && defined(USE_ASH) | 58 #if defined(OS_WIN) && defined(USE_ASH) |
| 59 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 59 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 60 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 60 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 61 return; | 61 return; |
| 62 #endif | 62 #endif |
| 63 | 63 |
| 64 browser()->profile()->GetExtensionService()->set_show_extensions_prompts( | 64 browser()->profile()->GetExtensionService()->set_show_extensions_prompts( |
| 65 false); | 65 false); |
| 66 | 66 |
| 67 content::NotificationRegistrar registrar; | 67 content::NotificationRegistrar registrar; |
| 68 registrar.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 68 registrar.Add(this, |
| 69 chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED, |
| 69 content::NotificationService::AllSources()); | 70 content::NotificationService::AllSources()); |
| 70 | 71 |
| 71 expected_extension_id_ = "ffnmbohohhobhkjpfbefbjifapgcmpaa"; | 72 expected_extension_id_ = "ffnmbohohhobhkjpfbefbjifapgcmpaa"; |
| 72 ui_test_utils::NavigateToURL( | 73 ui_test_utils::NavigateToURL( |
| 73 browser(), | 74 browser(), |
| 74 GURL("chrome://newtab")); | 75 GURL("chrome://newtab")); |
| 75 EXPECT_TRUE(content::ExecuteScript( | 76 EXPECT_TRUE(content::ExecuteScript( |
| 76 browser()->tab_strip_model()->GetActiveWebContents(), | 77 browser()->tab_strip_model()->GetActiveWebContents(), |
| 77 "chrome.send('generateAppForLink', " | 78 "chrome.send('generateAppForLink', " |
| 78 "['http://www.example.com', 'Test application', 0])")); | 79 "['http://www.example.com', 'Test application', 0])")); |
| 79 | 80 |
| 80 if (!installed_extension_) | 81 if (!installed_extension_) |
| 81 content::RunMessageLoop(); | 82 content::RunMessageLoop(); |
| 82 | 83 |
| 83 EXPECT_TRUE(installed_extension_); | 84 EXPECT_TRUE(installed_extension_); |
| 84 EXPECT_TRUE(installed_extension_->is_hosted_app()); | 85 EXPECT_TRUE(installed_extension_->is_hosted_app()); |
| 85 EXPECT_EQ("Test application", installed_extension_->name()); | 86 EXPECT_EQ("Test application", installed_extension_->name()); |
| 86 EXPECT_EQ("", installed_extension_->description()); | 87 EXPECT_EQ("", installed_extension_->description()); |
| 87 EXPECT_EQ(GURL("http://www.example.com/"), | 88 EXPECT_EQ(GURL("http://www.example.com/"), |
| 88 AppLaunchInfo::GetLaunchWebURL(installed_extension_)); | 89 AppLaunchInfo::GetLaunchWebURL(installed_extension_)); |
| 89 EXPECT_EQ(LAUNCH_CONTAINER_TAB, | 90 EXPECT_EQ(LAUNCH_CONTAINER_TAB, |
| 90 AppLaunchInfo::GetLaunchContainer(installed_extension_)); | 91 AppLaunchInfo::GetLaunchContainer(installed_extension_)); |
| 91 EXPECT_EQ(0u, installed_extension_->GetActivePermissions()->apis().size()); | 92 EXPECT_EQ(0u, installed_extension_->GetActivePermissions()->apis().size()); |
| 92 EXPECT_EQ(0u, IconsInfo::GetIcons(installed_extension_).map().size()); | 93 EXPECT_EQ(0u, IconsInfo::GetIcons(installed_extension_).map().size()); |
| 93 } | 94 } |
| 94 | 95 |
| 95 } // namespace extensions | 96 } // namespace extensions |
| OLD | NEW |