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

Unified Diff: chrome/browser/external_protocol/external_protocol_handler.cc

Issue 2660333004: Revert of Migrate external protocol prefs from local state to profiles (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/external_protocol/external_protocol_handler.cc
diff --git a/chrome/browser/external_protocol/external_protocol_handler.cc b/chrome/browser/external_protocol/external_protocol_handler.cc
index 96206ede108ceb270528815e79cfac3a20b06ef8..d629ddd98ff24f7f1c2f9bf67f78d26ff9dc560f 100644
--- a/chrome/browser/external_protocol/external_protocol_handler.cc
+++ b/chrome/browser/external_protocol/external_protocol_handler.cc
@@ -52,12 +52,11 @@
ExternalProtocolHandler::BlockState GetBlockStateWithDelegate(
const std::string& scheme,
- ExternalProtocolHandler::Delegate* delegate,
- Profile* profile) {
+ ExternalProtocolHandler::Delegate* delegate) {
if (!delegate)
- return ExternalProtocolHandler::GetBlockState(scheme, profile);
-
- return delegate->GetBlockState(scheme, profile);
+ return ExternalProtocolHandler::GetBlockState(scheme);
+
+ return delegate->GetBlockState(scheme);
}
void RunExternalProtocolDialogWithDelegate(
@@ -136,8 +135,7 @@
// static
ExternalProtocolHandler::BlockState ExternalProtocolHandler::GetBlockState(
- const std::string& scheme,
- Profile* profile) {
+ const std::string& scheme) {
// If we are being carpet bombed, block the request.
if (!g_accept_requests)
return BLOCK;
@@ -149,36 +147,18 @@
return BLOCK;
}
- // Check if there are any prefs in the local state. If there are, wipe them,
- // and migrate the prefs to the profile.
- // TODO(ramyasharma) remove the migration in M61.
- PrefService* local_prefs = g_browser_process->local_state();
- PrefService* profile_prefs = profile->GetPrefs();
- if (local_prefs && profile_prefs) { // May be NULL during testing.
- DictionaryPrefUpdate local_state_schemas(local_prefs,
- prefs::kExcludedSchemes);
- DictionaryPrefUpdate update_excluded_schemas_profile(
- profile_prefs, prefs::kExcludedSchemes);
- if (update_excluded_schemas_profile->empty()) {
- // Copy local state to profile state.
- for (base::DictionaryValue::Iterator it(*local_state_schemas);
- !it.IsAtEnd(); it.Advance()) {
- bool is_blocked;
- // Discard local state if set to blocked, to reset all users
- // stuck in 'Do Nothing' + 'Do Not Open' state back to the default
- // prompt state.
- if (it.value().GetAsBoolean(&is_blocked) && !is_blocked)
- update_excluded_schemas_profile->SetBoolean(it.key(), is_blocked);
- }
- // TODO(ramyasharma): Clear only if required.
- local_prefs->ClearPref(prefs::kExcludedSchemes);
- }
-
- // Prepopulate the default states each time.
- PrepopulateDictionary(update_excluded_schemas_profile.Get());
+ // Check the stored prefs.
+ // TODO(pkasting): This kind of thing should go in the preferences on the
+ // profile, not in the local state. http://crbug.com/457254
+ PrefService* pref = g_browser_process->local_state();
+ if (pref) { // May be NULL during testing.
+ DictionaryPrefUpdate update_excluded_schemas(pref, prefs::kExcludedSchemes);
+
+ // Warm up the dictionary if needed.
+ PrepopulateDictionary(update_excluded_schemas.Get());
bool should_block;
- if (update_excluded_schemas_profile->GetBoolean(scheme, &should_block))
+ if (update_excluded_schemas->GetBoolean(scheme, &should_block))
return should_block ? BLOCK : DONT_BLOCK;
}
@@ -187,18 +167,18 @@
// static
void ExternalProtocolHandler::SetBlockState(const std::string& scheme,
- BlockState state,
- Profile* profile) {
+ BlockState state) {
// Set in the stored prefs.
- PrefService* profile_prefs = profile->GetPrefs();
- if (profile_prefs) { // May be NULL during testing.
- DictionaryPrefUpdate update_excluded_schemas_profile(
- profile_prefs, prefs::kExcludedSchemes);
- if (!update_excluded_schemas_profile->empty()) {
- if (state == UNKNOWN)
- update_excluded_schemas_profile->Remove(scheme, nullptr);
- else
- update_excluded_schemas_profile->SetBoolean(scheme, (state == BLOCK));
+ // TODO(pkasting): This kind of thing should go in the preferences on the
+ // profile, not in the local state. http://crbug.com/457254
+ PrefService* pref = g_browser_process->local_state();
+ if (pref) { // May be NULL during testing.
+ DictionaryPrefUpdate update_excluded_schemas(pref, prefs::kExcludedSchemes);
+
+ if (state == UNKNOWN) {
+ update_excluded_schemas->Remove(scheme, NULL);
+ } else {
+ update_excluded_schemas->SetBoolean(scheme, (state == BLOCK));
}
}
}
@@ -217,14 +197,8 @@
// have parameters unexpected by the external program.
std::string escaped_url_string = net::EscapeExternalHandlerValue(url.spec());
GURL escaped_url(escaped_url_string);
-
- content::WebContents* web_contents = tab_util::GetWebContentsByID(
- render_process_host_id, render_view_routing_id);
- Profile* profile = nullptr;
- if (web_contents) // Maybe NULL during testing.
- profile = Profile::FromBrowserContext(web_contents->GetBrowserContext());
BlockState block_state =
- GetBlockStateWithDelegate(escaped_url.scheme(), delegate, profile);
+ GetBlockStateWithDelegate(escaped_url.scheme(), delegate);
if (block_state == BLOCK) {
if (delegate)
delegate->BlockRequest();
@@ -269,6 +243,11 @@
// static
void ExternalProtocolHandler::PrepopulateDictionary(
base::DictionaryValue* win_pref) {
+ static bool is_warm = false;
+ if (is_warm)
+ return;
+ is_warm = true;
+
static const char* const denied_schemes[] = {
"afp",
"data",

Powered by Google App Engine
This is Rietveld 408576698