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

Side by Side Diff: extensions/browser/extension_prefs.cc

Issue 2886923002: [extension SW]: Support event listener registration and event dispatching. (Closed)
Patch Set: address comments Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/extension_prefs.h" 5 #include "extensions/browser/extension_prefs.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <iterator> 10 #include <iterator>
(...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 if (!extension_dict->HasKey(pref_names::kPrefIncognitoContentSettings)) { 1936 if (!extension_dict->HasKey(pref_names::kPrefIncognitoContentSettings)) {
1937 extension_dict->Set(pref_names::kPrefIncognitoContentSettings, 1937 extension_dict->Set(pref_names::kPrefIncognitoContentSettings,
1938 new base::ListValue); 1938 new base::ListValue);
1939 } 1939 }
1940 1940
1941 // If this point has been reached, any pending installs should be considered 1941 // If this point has been reached, any pending installs should be considered
1942 // out of date. 1942 // out of date.
1943 extension_dict->Remove(kDelayedInstallInfo, NULL); 1943 extension_dict->Remove(kDelayedInstallInfo, NULL);
1944 1944
1945 // Clear state that may be registered from a previous install. 1945 // Clear state that may be registered from a previous install.
1946 extension_dict->Remove(EventRouter::kRegisteredEvents, NULL); 1946 extension_dict->Remove(EventRouter::kRegisteredLazyEvents, nullptr);
1947 extension_dict->Remove(EventRouter::kRegisteredServiceWorkerEvents, nullptr);
1947 1948
1948 // FYI, all code below here races on sudden shutdown because |extension_dict|, 1949 // FYI, all code below here races on sudden shutdown because |extension_dict|,
1949 // |app_sorting|, |extension_pref_value_map_|, and (potentially) observers 1950 // |app_sorting|, |extension_pref_value_map_|, and (potentially) observers
1950 // are updated non-transactionally. This is probably not fixable without 1951 // are updated non-transactionally. This is probably not fixable without
1951 // nested transactional updates to pref dictionaries. 1952 // nested transactional updates to pref dictionaries.
1952 if (needs_sort_ordinal) 1953 if (needs_sort_ordinal)
1953 app_sorting()->EnsureValidOrdinals(extension_id, suggested_page_ordinal); 1954 app_sorting()->EnsureValidOrdinals(extension_id, suggested_page_ordinal);
1954 1955
1955 bool is_enabled = false; 1956 bool is_enabled = false;
1956 int initial_state; 1957 int initial_state;
1957 if (extension_dict->GetInteger(kPrefState, &initial_state)) { 1958 if (extension_dict->GetInteger(kPrefState, &initial_state)) {
1958 is_enabled = initial_state == Extension::ENABLED; 1959 is_enabled = initial_state == Extension::ENABLED;
1959 } 1960 }
1960 bool is_incognito_enabled = IsIncognitoEnabled(extension_id); 1961 bool is_incognito_enabled = IsIncognitoEnabled(extension_id);
1961 1962
1962 extension_pref_value_map_->RegisterExtension( 1963 extension_pref_value_map_->RegisterExtension(
1963 extension_id, install_time, is_enabled, is_incognito_enabled); 1964 extension_id, install_time, is_enabled, is_incognito_enabled);
1964 1965
1965 for (auto& observer : observer_list_) 1966 for (auto& observer : observer_list_)
1966 observer.OnExtensionRegistered(extension_id, install_time, is_enabled); 1967 observer.OnExtensionRegistered(extension_id, install_time, is_enabled);
1967 } 1968 }
1968 1969
1969 } // namespace extensions 1970 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698