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

Side by Side Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 12079097: Introduce PrefRegistrySyncable, simplifying PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add to PrefRegistrySyncable and PrefServiceSyncable to let sync know of pre-registered prefs. Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 extension_service()->extension_prefs(); 867 extension_service()->extension_prefs();
867 868
868 // Clear the registered events to ensure they are updated. 869 // Clear the registered events to ensure they are updated.
869 extension_prefs->SetRegisteredEvents(extension->id(), 870 extension_prefs->SetRegisteredEvents(extension->id(),
870 std::set<std::string>()); 871 std::set<std::string>());
871 872
872 const base::StringValue old_version("1"); 873 const base::StringValue old_version("1");
873 std::string pref_path("extensions.settings."); 874 std::string pref_path("extensions.settings.");
874 pref_path += extension->id(); 875 pref_path += extension->id();
875 pref_path += ".manifest.version"; 876 pref_path += ".manifest.version";
876 extension_prefs->pref_service()->RegisterStringPref( 877 // TODO(joi): Do registrations up front.
877 pref_path.c_str(), std::string(), PrefServiceSyncable::UNSYNCABLE_PREF); 878 PrefRegistrySyncable* registry = static_cast<PrefRegistrySyncable*>(
879 extension_prefs->pref_service()->DeprecatedGetPrefRegistry());
880 registry->RegisterStringPref(
881 pref_path.c_str(), std::string(), PrefRegistrySyncable::UNSYNCABLE_PREF);
878 extension_prefs->pref_service()->Set(pref_path.c_str(), old_version); 882 extension_prefs->pref_service()->Set(pref_path.c_str(), old_version);
879 } 883 }
880 884
881 // Component App Test 3 of 3: simulate a component extension upgrade that 885 // Component App Test 3 of 3: simulate a component extension upgrade that
882 // re-adds the OnLaunched event, and allows the app to be launched. 886 // re-adds the OnLaunched event, and allows the app to be launched.
883 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ComponentAppBackgroundPage) { 887 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ComponentAppBackgroundPage) {
884 CheckExtensionInstalledObserver should_install; 888 CheckExtensionInstalledObserver should_install;
885 // Since we are forcing an upgrade, we need to wait for the load again. 889 // Since we are forcing an upgrade, we need to wait for the load again.
886 content::WindowedNotificationObserver app_loaded_observer( 890 content::WindowedNotificationObserver app_loaded_observer(
887 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 891 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 #define MAYBE_WebContentsHasFocus WebContentsHasFocus 926 #define MAYBE_WebContentsHasFocus WebContentsHasFocus
923 #endif 927 #endif
924 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_WebContentsHasFocus) { 928 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_WebContentsHasFocus) {
925 const Extension* extension = LoadAndLaunchPlatformApp("minimal"); 929 const Extension* extension = LoadAndLaunchPlatformApp("minimal");
926 ShellWindow* window = CreateShellWindow(extension); 930 ShellWindow* window = CreateShellWindow(extension);
927 EXPECT_TRUE(window->web_contents()->GetRenderWidgetHostView()->HasFocus()); 931 EXPECT_TRUE(window->web_contents()->GetRenderWidgetHostView()->HasFocus());
928 CloseShellWindow(window); 932 CloseShellWindow(window);
929 } 933 }
930 934
931 } // namespace extensions 935 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698