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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
13 #include "chrome/browser/command_updater.h" | 13 #include "chrome/browser/command_updater.h" |
14 #include "chrome/browser/content_settings/host_content_settings_map.h" | 14 #include "chrome/browser/content_settings/host_content_settings_map.h" |
15 #include "chrome/browser/defaults.h" | 15 #include "chrome/browser/defaults.h" |
16 #include "chrome/browser/extensions/extension_browsertest.h" | 16 #include "chrome/browser/extensions/extension_browsertest.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_system.h" |
18 #include "chrome/browser/extensions/tab_helper.h" | 19 #include "chrome/browser/extensions/tab_helper.h" |
19 #include "chrome/browser/first_run/first_run.h" | 20 #include "chrome/browser/first_run/first_run.h" |
20 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 21 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
23 #include "chrome/browser/translate/translate_tab_helper.h" | 24 #include "chrome/browser/translate/translate_tab_helper.h" |
24 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 25 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
25 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" | 26 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" |
26 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 27 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 204 |
204 return page_title; | 205 return page_title; |
205 #else | 206 #else |
206 // Do we need to use the above code on POSIX as well? | 207 // Do we need to use the above code on POSIX as well? |
207 return page_title; | 208 return page_title; |
208 #endif | 209 #endif |
209 } | 210 } |
210 | 211 |
211 // Returns the app extension aptly named "App Test". | 212 // Returns the app extension aptly named "App Test". |
212 const Extension* GetExtension() { | 213 const Extension* GetExtension() { |
213 const ExtensionSet* extensions = | 214 const ExtensionSet* extensions = extensions::ExtensionSystem::Get( |
214 browser()->profile()->GetExtensionService()->extensions(); | 215 browser()->profile())->extension_service()->extensions(); |
215 for (ExtensionSet::const_iterator it = extensions->begin(); | 216 for (ExtensionSet::const_iterator it = extensions->begin(); |
216 it != extensions->end(); ++it) { | 217 it != extensions->end(); ++it) { |
217 if ((*it)->name() == "App Test") | 218 if ((*it)->name() == "App Test") |
218 return *it; | 219 return *it; |
219 } | 220 } |
220 NOTREACHED(); | 221 NOTREACHED(); |
221 return NULL; | 222 return NULL; |
222 } | 223 } |
223 }; | 224 }; |
224 | 225 |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 | 880 |
880 model->AddWebContents(app_contents, 0, content::PageTransitionFromInt(0), | 881 model->AddWebContents(app_contents, 0, content::PageTransitionFromInt(0), |
881 TabStripModel::ADD_NONE); | 882 TabStripModel::ADD_NONE); |
882 model->SetTabPinned(0, true); | 883 model->SetTabPinned(0, true); |
883 ui_test_utils::NavigateToURL(browser(), url); | 884 ui_test_utils::NavigateToURL(browser(), url); |
884 | 885 |
885 MockTabStripModelObserver observer; | 886 MockTabStripModelObserver observer; |
886 model->AddObserver(&observer); | 887 model->AddObserver(&observer); |
887 | 888 |
888 // Uninstall the extension and make sure TabClosing is sent. | 889 // Uninstall the extension and make sure TabClosing is sent. |
889 ExtensionService* service = browser()->profile()->GetExtensionService(); | 890 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 891 browser()->profile())->extension_service(); |
890 service->UninstallExtension(GetExtension()->id(), false, NULL); | 892 service->UninstallExtension(GetExtension()->id(), false, NULL); |
891 EXPECT_EQ(1, observer.closing_count()); | 893 EXPECT_EQ(1, observer.closing_count()); |
892 | 894 |
893 model->RemoveObserver(&observer); | 895 model->RemoveObserver(&observer); |
894 | 896 |
895 // There should only be one tab now. | 897 // There should only be one tab now. |
896 ASSERT_EQ(1, browser()->tab_count()); | 898 ASSERT_EQ(1, browser()->tab_count()); |
897 } | 899 } |
898 | 900 |
899 #if !defined(OS_MACOSX) | 901 #if !defined(OS_MACOSX) |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 EXPECT_TRUE(new_command_updater->IsCommandEnabled(IDC_OPTIONS)); | 1249 EXPECT_TRUE(new_command_updater->IsCommandEnabled(IDC_OPTIONS)); |
1248 } | 1250 } |
1249 | 1251 |
1250 // Makes sure Extensions and Settings commands are disabled in certain | 1252 // Makes sure Extensions and Settings commands are disabled in certain |
1251 // circumstances even though normally they should stay enabled. | 1253 // circumstances even though normally they should stay enabled. |
1252 IN_PROC_BROWSER_TEST_F(BrowserTest, | 1254 IN_PROC_BROWSER_TEST_F(BrowserTest, |
1253 DisableExtensionsAndSettingsWhenIncognitoIsDisabled) { | 1255 DisableExtensionsAndSettingsWhenIncognitoIsDisabled) { |
1254 CommandUpdater* command_updater = | 1256 CommandUpdater* command_updater = |
1255 browser()->command_controller()->command_updater(); | 1257 browser()->command_controller()->command_updater(); |
1256 // Disable extensions. This should disable Extensions menu. | 1258 // Disable extensions. This should disable Extensions menu. |
1257 browser()->profile()->GetExtensionService()->set_extensions_enabled(false); | 1259 extensions::ExtensionSystem::Get(browser()->profile())->extension_service()-> |
| 1260 set_extensions_enabled(false); |
1258 // Set Incognito to DISABLED. | 1261 // Set Incognito to DISABLED. |
1259 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), | 1262 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), |
1260 IncognitoModePrefs::DISABLED); | 1263 IncognitoModePrefs::DISABLED); |
1261 // Make sure Manage Extensions command is disabled. | 1264 // Make sure Manage Extensions command is disabled. |
1262 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_MANAGE_EXTENSIONS)); | 1265 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_MANAGE_EXTENSIONS)); |
1263 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_NEW_WINDOW)); | 1266 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_NEW_WINDOW)); |
1264 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER)); | 1267 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER)); |
1265 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); | 1268 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); |
1266 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_OPTIONS)); | 1269 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_OPTIONS)); |
1267 | 1270 |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1930 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 1933 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
1931 } | 1934 } |
1932 | 1935 |
1933 // Shift-middle-clicks open in a foreground tab. | 1936 // Shift-middle-clicks open in a foreground tab. |
1934 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { | 1937 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { |
1935 int modifiers = WebKit::WebInputEvent::ShiftKey; | 1938 int modifiers = WebKit::WebInputEvent::ShiftKey; |
1936 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; | 1939 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; |
1937 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 1940 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
1938 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 1941 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
1939 } | 1942 } |
OLD | NEW |