diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 07:43:41 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 07:43:41 +0000 |
commit | c2844fe20fbb2f982b81daa62ee9eb5208724d07 (patch) | |
tree | 1f2fd20a4277eb6bea301fd8e7817847944f69c5 | |
parent | eb353ca04e63ad89df7a6e505b71b8bce7f2ac71 (diff) | |
download | chromium_src-c2844fe20fbb2f982b81daa62ee9eb5208724d07.zip chromium_src-c2844fe20fbb2f982b81daa62ee9eb5208724d07.tar.gz chromium_src-c2844fe20fbb2f982b81daa62ee9eb5208724d07.tar.bz2 |
Implement operator* and operator-> for ScopedUserPrefUpdate
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6815008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81074 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/external_protocol_handler.cc | 27 | ||||
-rw-r--r-- | chrome/browser/prefs/scoped_user_pref_update.h | 8 |
2 files changed, 21 insertions, 14 deletions
diff --git a/chrome/browser/external_protocol_handler.cc b/chrome/browser/external_protocol_handler.cc index d2994c3..24b5984 100644 --- a/chrome/browser/external_protocol_handler.cc +++ b/chrome/browser/external_protocol_handler.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,6 +14,7 @@ #include "chrome/browser/browser_process_impl.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/common/pref_names.h" #include "googleurl/src/gurl.h" #include "net/base/escape.h" @@ -92,15 +93,13 @@ ExternalProtocolHandler::BlockState ExternalProtocolHandler::GetBlockState( // preferences on the profile, not in the local state. PrefService* pref = g_browser_process->local_state(); if (pref) { // May be NULL during testing. - DictionaryValue* win_pref = - pref->GetMutableDictionary(prefs::kExcludedSchemes); - CHECK(win_pref); + DictionaryPrefUpdate update_excluded_schemas(pref, prefs::kExcludedSchemes); // Warm up the dictionary if needed. - PrepopulateDictionary(win_pref); + PrepopulateDictionary(update_excluded_schemas.Get()); bool should_block; - if (win_pref->GetBoolean(scheme, &should_block)) + if (update_excluded_schemas->GetBoolean(scheme, &should_block)) return should_block ? BLOCK : DONT_BLOCK; } @@ -115,14 +114,14 @@ void ExternalProtocolHandler::SetBlockState(const std::string& scheme, // preferences on the profile, not in the local state. PrefService* pref = g_browser_process->local_state(); if (pref) { // May be NULL during testing. - DictionaryValue* win_pref = - pref->GetMutableDictionary(prefs::kExcludedSchemes); - CHECK(win_pref); - - if (state == UNKNOWN) - win_pref->Remove(scheme, NULL); - else - win_pref->SetBoolean(scheme, state == BLOCK ? true : false); + DictionaryPrefUpdate update_excluded_schemas(pref, prefs::kExcludedSchemes); + + if (state == UNKNOWN) { + update_excluded_schemas->Remove(scheme, NULL); + } else { + update_excluded_schemas->SetBoolean(scheme, + state == BLOCK ? true : false); + } } } diff --git a/chrome/browser/prefs/scoped_user_pref_update.h b/chrome/browser/prefs/scoped_user_pref_update.h index 69572fa..7885446 100644 --- a/chrome/browser/prefs/scoped_user_pref_update.h +++ b/chrome/browser/prefs/scoped_user_pref_update.h @@ -99,6 +99,14 @@ class ScopedUserPrefUpdateTemplate : public subtle::ScopedUserPrefUpdateBase { subtle::ScopedUserPrefUpdateBase::Get(type_enum_value)); } + T& operator*() { + return *Get(); + } + + T* operator->() { + return Get(); + } + private: DISALLOW_COPY_AND_ASSIGN(ScopedUserPrefUpdateTemplate); }; |