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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 6 Created 8 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 (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 "chrome/browser/extensions/extension_toolbar_model.h" 5 #include "chrome/browser/extensions/extension_toolbar_model.h"
6 6
7 #include "chrome/browser/extensions/extension_prefs.h" 7 #include "chrome/browser/extensions/extension_prefs.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/common/chrome_notification_types.h" 12 #include "chrome/common/chrome_notification_types.h"
13 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "content/public/browser/notification_details.h" 15 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_source.h" 16 #include "content/public/browser/notification_source.h"
17 17
18 using extensions::Extension;
19 using extensions::ExtensionList;
20
18 ExtensionToolbarModel::ExtensionToolbarModel(ExtensionService* service) 21 ExtensionToolbarModel::ExtensionToolbarModel(ExtensionService* service)
19 : service_(service), 22 : service_(service),
20 prefs_(service->profile()->GetPrefs()), 23 prefs_(service->profile()->GetPrefs()),
21 extensions_initialized_(false) { 24 extensions_initialized_(false) {
22 DCHECK(service_); 25 DCHECK(service_);
23 26
24 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 27 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
25 content::Source<Profile>(service_->profile())); 28 content::Source<Profile>(service_->profile()));
26 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 29 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
27 content::Source<Profile>(service_->profile())); 30 content::Source<Profile>(service_->profile()));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (type == chrome::NOTIFICATION_EXTENSIONS_READY) { 97 if (type == chrome::NOTIFICATION_EXTENSIONS_READY) {
95 InitializeExtensionList(); 98 InitializeExtensionList();
96 return; 99 return;
97 } 100 }
98 101
99 if (!service_->is_ready()) 102 if (!service_->is_ready())
100 return; 103 return;
101 104
102 const Extension* extension = NULL; 105 const Extension* extension = NULL;
103 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { 106 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) {
104 extension = content::Details<UnloadedExtensionInfo>(details)->extension; 107 extension = content::Details<extensions::UnloadedExtensionInfo>(
108 details)->extension;
105 } else { 109 } else {
106 extension = content::Details<const Extension>(details).ptr(); 110 extension = content::Details<const Extension>(details).ptr();
107 } 111 }
108 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { 112 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
109 // We don't want to add the same extension twice. It may have already been 113 // We don't want to add the same extension twice. It may have already been
110 // added by EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED below, if the user 114 // added by EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED below, if the user
111 // hides the browser action and then disables and enables the extension. 115 // hides the browser action and then disables and enables the extension.
112 for (size_t i = 0; i < toolitems_.size(); i++) { 116 for (size_t i = 0; i < toolitems_.size(); i++) {
113 if (toolitems_[i].get() == extension) 117 if (toolitems_[i].get() == extension)
114 return; // Already exists. 118 return; // Already exists.
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 int incognito_index = 0, i = 0; 262 int incognito_index = 0, i = 0;
259 for (ExtensionList::iterator iter = begin(); iter != end(); 263 for (ExtensionList::iterator iter = begin(); iter != end();
260 ++iter, ++i) { 264 ++iter, ++i) {
261 if (original_index == i) 265 if (original_index == i)
262 break; 266 break;
263 if (service_->IsIncognitoEnabled((*iter)->id())) 267 if (service_->IsIncognitoEnabled((*iter)->id()))
264 ++incognito_index; 268 ++incognito_index;
265 } 269 }
266 return incognito_index; 270 return incognito_index;
267 } 271 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.h ('k') | chrome/browser/extensions/extension_toolbar_model_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698