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

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

Issue 508513002: Remove implicit conversions from scoped_refptr to T* in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Two more Created 6 years, 4 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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/extensions/settings_api_helpers.h" 5 #include "chrome/browser/extensions/settings_api_helpers.h"
6 6
7 #include "chrome/browser/extensions/api/preference/preference_api.h" 7 #include "chrome/browser/extensions/api/preference/preference_api.h"
8 #include "chrome/common/pref_names.h" 8 #include "chrome/common/pref_names.h"
9 #include "components/search_engines/search_engines_pref_names.h" 9 #include "components/search_engines/search_engines_pref_names.h"
10 #include "extensions/browser/extension_pref_value_map.h" 10 #include "extensions/browser/extension_pref_value_map.h"
11 #include "extensions/browser/extension_pref_value_map_factory.h" 11 #include "extensions/browser/extension_pref_value_map_factory.h"
12 #include "extensions/browser/extension_registry.h" 12 #include "extensions/browser/extension_registry.h"
13 #include "extensions/common/extension_set.h" 13 #include "extensions/common/extension_set.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 namespace { 17 namespace {
18 18
19 // Returns which |extension| (if any) is overriding a particular |type| of 19 // Returns which |extension| (if any) is overriding a particular |type| of
20 // setting. 20 // setting.
21 const Extension* FindOverridingExtension( 21 const Extension* FindOverridingExtension(
22 content::BrowserContext* browser_context, 22 content::BrowserContext* browser_context,
23 SettingsApiOverrideType type) { 23 SettingsApiOverrideType type) {
24 const ExtensionSet& extensions = 24 const ExtensionSet& extensions =
25 ExtensionRegistry::Get(browser_context)->enabled_extensions(); 25 ExtensionRegistry::Get(browser_context)->enabled_extensions();
26 26
27 for (ExtensionSet::const_iterator it = extensions.begin(); 27 for (ExtensionSet::const_iterator it = extensions.begin();
28 it != extensions.end(); 28 it != extensions.end();
29 ++it) { 29 ++it) {
30 const SettingsOverrides* settings = SettingsOverrides::Get(*it); 30 const SettingsOverrides* settings = SettingsOverrides::Get(it->get());
31 if (settings) { 31 if (settings) {
32 if (type == BUBBLE_TYPE_HOME_PAGE && !settings->homepage) 32 if (type == BUBBLE_TYPE_HOME_PAGE && !settings->homepage)
33 continue; 33 continue;
34 if (type == BUBBLE_TYPE_STARTUP_PAGES && settings->startup_pages.empty()) 34 if (type == BUBBLE_TYPE_STARTUP_PAGES && settings->startup_pages.empty())
35 continue; 35 continue;
36 if (type == BUBBLE_TYPE_SEARCH_ENGINE && !settings->search_engine) 36 if (type == BUBBLE_TYPE_SEARCH_ENGINE && !settings->search_engine)
37 continue; 37 continue;
38 38
39 std::string key; 39 std::string key;
40 switch (type) { 40 switch (type) {
41 case BUBBLE_TYPE_HOME_PAGE: 41 case BUBBLE_TYPE_HOME_PAGE:
42 key = prefs::kHomePage; 42 key = prefs::kHomePage;
43 break; 43 break;
44 case BUBBLE_TYPE_STARTUP_PAGES: 44 case BUBBLE_TYPE_STARTUP_PAGES:
45 key = prefs::kRestoreOnStartup; 45 key = prefs::kRestoreOnStartup;
46 break; 46 break;
47 case BUBBLE_TYPE_SEARCH_ENGINE: 47 case BUBBLE_TYPE_SEARCH_ENGINE:
48 key = prefs::kDefaultSearchProviderEnabled; 48 key = prefs::kDefaultSearchProviderEnabled;
49 break; 49 break;
50 } 50 }
51 51
52 // Found an extension overriding the current type, check if primary. 52 // Found an extension overriding the current type, check if primary.
53 PreferenceAPI* preference_api = PreferenceAPI::Get(browser_context); 53 PreferenceAPI* preference_api = PreferenceAPI::Get(browser_context);
54 if (preference_api && // Expected to be NULL in unit tests. 54 if (preference_api && // Expected to be NULL in unit tests.
55 !preference_api->DoesExtensionControlPref((*it)->id(), key, NULL)) 55 !preference_api->DoesExtensionControlPref((*it)->id(), key, NULL))
56 continue; // Not primary. 56 continue; // Not primary.
57 57
58 // Found the primary extension. 58 // Found the primary extension.
59 return *it; 59 return it->get();
60 } 60 }
61 } 61 }
62 62
63 return NULL; 63 return NULL;
64 } 64 }
65 65
66 } // namespace 66 } // namespace
67 67
68 const Extension* GetExtensionOverridingHomepage( 68 const Extension* GetExtensionOverridingHomepage(
69 content::BrowserContext* browser_context) { 69 content::BrowserContext* browser_context) {
(...skipping 18 matching lines...) Expand all
88 return NULL; // Can be null during testing. 88 return NULL; // Can be null during testing.
89 std::string extension_id = 89 std::string extension_id =
90 extension_prefs_value_map->GetExtensionControllingPref(prefs::kProxy); 90 extension_prefs_value_map->GetExtensionControllingPref(prefs::kProxy);
91 if (extension_id.empty()) 91 if (extension_id.empty())
92 return NULL; 92 return NULL;
93 return ExtensionRegistry::Get(browser_context)->GetExtensionById( 93 return ExtensionRegistry::Get(browser_context)->GetExtensionById(
94 extension_id, ExtensionRegistry::ENABLED); 94 extension_id, ExtensionRegistry::ENABLED);
95 } 95 }
96 96
97 } // namespace extensions 97 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698