| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
| 7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 12 #include "chrome/browser/infobars/infobar.h" | 12 #include "chrome/browser/infobars/infobar.h" |
| 13 #include "chrome/browser/infobars/infobar_manager.h" |
| 13 #include "chrome/browser/infobars/infobar_service.h" | 14 #include "chrome/browser/infobars/infobar_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/themes/theme_service.h" | 16 #include "chrome/browser/themes/theme_service.h" |
| 16 #include "chrome/browser/themes/theme_service_factory.h" | 17 #include "chrome/browser/themes/theme_service_factory.h" |
| 17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_commands.h" | 19 #include "chrome/browser/ui/browser_commands.h" |
| 19 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 22 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 22 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 using extensions::Extension; | 34 using extensions::Extension; |
| 34 | 35 |
| 35 class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { | 36 class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { |
| 36 public: | 37 public: |
| 37 // Checks that a theme info bar is currently visible and issues an undo to | 38 // Checks that a theme info bar is currently visible and issues an undo to |
| 38 // revert to the previous theme. | 39 // revert to the previous theme. |
| 39 void VerifyThemeInfoBarAndUndoInstall() { | 40 void VerifyThemeInfoBarAndUndoInstall() { |
| 40 WebContents* web_contents = | 41 WebContents* web_contents = |
| 41 browser()->tab_strip_model()->GetActiveWebContents(); | 42 browser()->tab_strip_model()->GetActiveWebContents(); |
| 42 ASSERT_TRUE(web_contents); | 43 ASSERT_TRUE(web_contents); |
| 43 InfoBarService* infobar_service = | 44 InfoBarManager* infobar_manager = |
| 44 InfoBarService::FromWebContents(web_contents); | 45 InfoBarService::FromWebContents(web_contents)->infobar_manager(); |
| 45 ASSERT_EQ(1U, infobar_service->infobar_count()); | 46 ASSERT_EQ(1U, infobar_manager->infobar_count()); |
| 46 ConfirmInfoBarDelegate* delegate = | 47 ConfirmInfoBarDelegate* delegate = |
| 47 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); | 48 infobar_manager->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); |
| 48 ASSERT_TRUE(delegate); | 49 ASSERT_TRUE(delegate); |
| 49 delegate->Cancel(); | 50 delegate->Cancel(); |
| 50 ASSERT_EQ(0U, infobar_service->infobar_count()); | 51 ASSERT_EQ(0U, infobar_manager->infobar_count()); |
| 51 } | 52 } |
| 52 | 53 |
| 53 // Install the given theme from the data dir and verify expected name. | 54 // Install the given theme from the data dir and verify expected name. |
| 54 void InstallThemeAndVerify(const char* theme_name, | 55 void InstallThemeAndVerify(const char* theme_name, |
| 55 const std::string& expected_name) { | 56 const std::string& expected_name) { |
| 56 // If there is already a theme installed, the current theme should be | 57 // If there is already a theme installed, the current theme should be |
| 57 // disabled and the new one installed + enabled. | 58 // disabled and the new one installed + enabled. |
| 58 int expected_change = GetTheme() ? 0 : 1; | 59 int expected_change = GetTheme() ? 0 : 1; |
| 59 const base::FilePath theme_path = test_data_dir_.AppendASCII(theme_name); | 60 const base::FilePath theme_path = test_data_dir_.AppendASCII(theme_name); |
| 60 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_path, expected_change, | 61 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_path, expected_change, |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 sorting->OnExtensionMoved( | 243 sorting->OnExtensionMoved( |
| 243 app_id, base::EmptyString(), extension_misc::kWebStoreAppId); | 244 app_id, base::EmptyString(), extension_misc::kWebStoreAppId); |
| 244 EXPECT_EQ(app_id, last_reordered_extension_id_); | 245 EXPECT_EQ(app_id, last_reordered_extension_id_); |
| 245 | 246 |
| 246 // Now install the app. | 247 // Now install the app. |
| 247 const extensions::Extension* test_app = LoadExtension(app_dir); | 248 const extensions::Extension* test_app = LoadExtension(app_dir); |
| 248 ASSERT_TRUE(test_app); | 249 ASSERT_TRUE(test_app); |
| 249 EXPECT_TRUE(service->GetInstalledExtension(app_id)); | 250 EXPECT_TRUE(service->GetInstalledExtension(app_id)); |
| 250 EXPECT_EQ(app_id, test_app->id()); | 251 EXPECT_EQ(app_id, test_app->id()); |
| 251 } | 252 } |
| OLD | NEW |