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

Side by Side Diff: chrome/browser/background_application_list_model.cc

Issue 5908003: Added Background Application entries to Dock menu (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: First round of code review follow-up Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/background_application_list_model.h" 5 #include "chrome/browser/background_application_list_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util_collator.h" 9 #include "app/l10n_util_collator.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/background_mode_manager.h" 13 #include "chrome/browser/background_mode_manager.h"
13 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/extensions/extension_prefs.h" 15 #include "chrome/browser/extensions/extension_prefs.h"
15 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/image_loading_tracker.h" 17 #include "chrome/browser/extensions/image_loading_tracker.h"
17 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_resource.h" 21 #include "chrome/common/extensions/extension_resource.h"
21 #include "chrome/common/notification_service.h" 22 #include "chrome/common/notification_service.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 Source<Profile>(profile)); 149 Source<Profile>(profile));
149 registrar_.Add(this, 150 registrar_.Add(this,
150 NotificationType::EXTENSION_UNLOADED, 151 NotificationType::EXTENSION_UNLOADED,
151 Source<Profile>(profile)); 152 Source<Profile>(profile));
152 registrar_.Add(this, 153 registrar_.Add(this,
153 NotificationType::EXTENSION_UNLOADED_DISABLED, 154 NotificationType::EXTENSION_UNLOADED_DISABLED,
154 Source<Profile>(profile)); 155 Source<Profile>(profile));
155 registrar_.Add(this, 156 registrar_.Add(this,
156 NotificationType::EXTENSIONS_READY, 157 NotificationType::EXTENSIONS_READY,
157 Source<Profile>(profile)); 158 Source<Profile>(profile));
159 ExtensionService* service = profile->GetExtensionService();
160 if (service && service->is_ready())
161 Update();
158 } 162 }
159 163
160 void BackgroundApplicationListModel::AddObserver(Observer* observer) { 164 void BackgroundApplicationListModel::AddObserver(Observer* observer) {
161 observers_.AddObserver(observer); 165 observers_.AddObserver(observer);
162 } 166 }
163 167
164 void BackgroundApplicationListModel::AssociateApplicationData( 168 void BackgroundApplicationListModel::AssociateApplicationData(
165 const Extension* extension) { 169 const Extension* extension) {
166 DCHECK(IsBackgroundApp(*extension)); 170 DCHECK(IsBackgroundApp(*extension));
167 Application* application = FindApplication(extension); 171 Application* application = FindApplication(extension);
168 if (!application) { 172 if (!application) {
173 // App position is used as a dynamic command and so must be less than any
174 // predefined command id.
175 if (applications_.size() >= IDC_MinimumLabelValue) {
176 LOG(ERROR) << "Background application limit of " << IDC_MinimumLabelValue
177 << " exceeded. Ignoring.";
178 return;
179 }
169 application = new Application(this, extension); 180 application = new Application(this, extension);
170 applications_[extension->id()] = application; 181 applications_[extension->id()] = application;
171 application->RequestIcon(Extension::EXTENSION_ICON_BITTY); 182 application->RequestIcon(Extension::EXTENSION_ICON_BITTY);
172 } 183 }
173 } 184 }
174 185
175 void BackgroundApplicationListModel::DissociateApplicationData( 186 void BackgroundApplicationListModel::DissociateApplicationData(
176 const Extension* extension) { 187 const Extension* extension) {
177 ApplicationMap::iterator found = applications_.find(extension->id()); 188 ApplicationMap::iterator found = applications_.find(extension->id());
178 if (found != applications_.end()) { 189 if (found != applications_.end()) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 (*old_cursor)->name() == (*new_cursor)->name() && 310 (*old_cursor)->name() == (*new_cursor)->name() &&
300 (*old_cursor)->id() == (*new_cursor)->id()) { 311 (*old_cursor)->id() == (*new_cursor)->id()) {
301 ++old_cursor; 312 ++old_cursor;
302 ++new_cursor; 313 ++new_cursor;
303 } 314 }
304 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { 315 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) {
305 extensions_ = extensions; 316 extensions_ = extensions;
306 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged()); 317 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged());
307 } 318 }
308 } 319 }
OLDNEW
« chrome/browser/app_controller_mac.mm ('K') | « chrome/browser/app_controller_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698