| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
| 7 #include "base/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/automation/automation_util.h" | 10 #include "chrome/browser/automation/automation_util.h" |
| 11 #include "chrome/browser/devtools/devtools_window.h" | 11 #include "chrome/browser/devtools/devtools_window.h" |
| 12 #include "chrome/browser/extensions/api/permissions/permissions_api.h" | 12 #include "chrome/browser/extensions/api/permissions/permissions_api.h" |
| 13 #include "chrome/browser/extensions/extension_browsertest.h" | 13 #include "chrome/browser/extensions/extension_browsertest.h" |
| 14 #include "chrome/browser/extensions/extension_prefs.h" | 14 #include "chrome/browser/extensions/extension_prefs.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/extension_system.h" | 16 #include "chrome/browser/extensions/extension_system.h" |
| 17 #include "chrome/browser/extensions/extension_test_message_listener.h" | 17 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 18 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 18 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
| 19 #include "chrome/browser/extensions/platform_app_launcher.h" | 19 #include "chrome/browser/extensions/platform_app_launcher.h" |
| 20 #include "chrome/browser/extensions/shell_window_registry.h" | 20 #include "chrome/browser/extensions/shell_window_registry.h" |
| 21 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 21 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
| 22 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 23 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/extensions/application_launch.h" | 25 #include "chrome/browser/ui/extensions/application_launch.h" |
| 25 #include "chrome/browser/ui/extensions/native_app_window.h" | 26 #include "chrome/browser/ui/extensions/native_app_window.h" |
| 26 #include "chrome/browser/ui/extensions/shell_window.h" | 27 #include "chrome/browser/ui/extensions/shell_window.h" |
| 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 28 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" | 29 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 extension_service()->extension_prefs(); | 869 extension_service()->extension_prefs(); |
| 869 | 870 |
| 870 // Clear the registered events to ensure they are updated. | 871 // Clear the registered events to ensure they are updated. |
| 871 extension_prefs->SetRegisteredEvents(extension->id(), | 872 extension_prefs->SetRegisteredEvents(extension->id(), |
| 872 std::set<std::string>()); | 873 std::set<std::string>()); |
| 873 | 874 |
| 874 const base::StringValue old_version("1"); | 875 const base::StringValue old_version("1"); |
| 875 std::string pref_path("extensions.settings."); | 876 std::string pref_path("extensions.settings."); |
| 876 pref_path += extension->id(); | 877 pref_path += extension->id(); |
| 877 pref_path += ".manifest.version"; | 878 pref_path += ".manifest.version"; |
| 878 extension_prefs->pref_service()->RegisterStringPref( | 879 // TODO(joi): Do registrations up front. |
| 879 pref_path.c_str(), std::string(), PrefServiceSyncable::UNSYNCABLE_PREF); | 880 PrefRegistrySyncable* registry = static_cast<PrefRegistrySyncable*>( |
| 881 extension_prefs->pref_service()->DeprecatedGetPrefRegistry()); |
| 882 registry->RegisterStringPref( |
| 883 pref_path.c_str(), std::string(), PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 880 extension_prefs->pref_service()->Set(pref_path.c_str(), old_version); | 884 extension_prefs->pref_service()->Set(pref_path.c_str(), old_version); |
| 881 } | 885 } |
| 882 | 886 |
| 883 // Component App Test 3 of 3: simulate a component extension upgrade that | 887 // Component App Test 3 of 3: simulate a component extension upgrade that |
| 884 // re-adds the OnLaunched event, and allows the app to be launched. | 888 // re-adds the OnLaunched event, and allows the app to be launched. |
| 885 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ComponentAppBackgroundPage) { | 889 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ComponentAppBackgroundPage) { |
| 886 CheckExtensionInstalledObserver should_install; | 890 CheckExtensionInstalledObserver should_install; |
| 887 // Since we are forcing an upgrade, we need to wait for the load again. | 891 // Since we are forcing an upgrade, we need to wait for the load again. |
| 888 content::WindowedNotificationObserver app_loaded_observer( | 892 content::WindowedNotificationObserver app_loaded_observer( |
| 889 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 893 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 #define MAYBE_WebContentsHasFocus WebContentsHasFocus | 928 #define MAYBE_WebContentsHasFocus WebContentsHasFocus |
| 925 #endif | 929 #endif |
| 926 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_WebContentsHasFocus) { | 930 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_WebContentsHasFocus) { |
| 927 const Extension* extension = LoadAndLaunchPlatformApp("minimal"); | 931 const Extension* extension = LoadAndLaunchPlatformApp("minimal"); |
| 928 ShellWindow* window = CreateShellWindow(extension); | 932 ShellWindow* window = CreateShellWindow(extension); |
| 929 EXPECT_TRUE(window->web_contents()->GetRenderWidgetHostView()->HasFocus()); | 933 EXPECT_TRUE(window->web_contents()->GetRenderWidgetHostView()->HasFocus()); |
| 930 CloseShellWindow(window); | 934 CloseShellWindow(window); |
| 931 } | 935 } |
| 932 | 936 |
| 933 } // namespace extensions | 937 } // namespace extensions |
| OLD | NEW |