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

Side by Side Diff: chrome/browser/background/background_mode_manager.cc

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 2 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 22 matching lines...) Expand all
33 #include "content/public/browser/notification_service.h" 33 #include "content/public/browser/notification_service.h"
34 #include "content/public/browser/notification_types.h" 34 #include "content/public/browser/notification_types.h"
35 #include "content/public/browser/user_metrics.h" 35 #include "content/public/browser/user_metrics.h"
36 #include "grit/chromium_strings.h" 36 #include "grit/chromium_strings.h"
37 #include "grit/generated_resources.h" 37 #include "grit/generated_resources.h"
38 #include "grit/theme_resources.h" 38 #include "grit/theme_resources.h"
39 #include "ui/base/l10n/l10n_util.h" 39 #include "ui/base/l10n/l10n_util.h"
40 #include "ui/base/resource/resource_bundle.h" 40 #include "ui/base/resource/resource_bundle.h"
41 41
42 using content::UserMetricsAction; 42 using content::UserMetricsAction;
43 using extensions::Extension;
44 using extensions::UpdatedExtensionPermissionsInfo;
43 45
44 BackgroundModeManager::BackgroundModeData::BackgroundModeData( 46 BackgroundModeManager::BackgroundModeData::BackgroundModeData(
45 int command_id, 47 int command_id,
46 Profile* profile) 48 Profile* profile)
47 : applications_(new BackgroundApplicationListModel(profile)), 49 : applications_(new BackgroundApplicationListModel(profile)),
48 command_id_(command_id), 50 command_id_(command_id),
49 profile_(profile) { 51 profile_(profile) {
50 } 52 }
51 53
52 BackgroundModeManager::BackgroundModeData::~BackgroundModeData() { 54 BackgroundModeManager::BackgroundModeData::~BackgroundModeData() {
(...skipping 18 matching lines...) Expand all
71 return false; 73 return false;
72 } 74 }
73 75
74 void BackgroundModeManager::BackgroundModeData::ExecuteCommand(int item) { 76 void BackgroundModeManager::BackgroundModeData::ExecuteCommand(int item) {
75 switch (item) { 77 switch (item) {
76 case IDC_MinimumLabelValue: 78 case IDC_MinimumLabelValue:
77 // Do nothing. This is just a label. 79 // Do nothing. This is just a label.
78 break; 80 break;
79 default: 81 default:
80 // Launch the app associated with this item. 82 // Launch the app associated with this item.
81 const Extension* extension = applications_->GetExtension(item); 83 const Extension* extension = applications_->
84 GetExtension(item);
82 BackgroundModeManager::LaunchBackgroundApplication(profile_, extension); 85 BackgroundModeManager::LaunchBackgroundApplication(profile_, extension);
83 break; 86 break;
84 } 87 }
85 } 88 }
86 89
87 Browser* BackgroundModeManager::BackgroundModeData::GetBrowserWindow() { 90 Browser* BackgroundModeManager::BackgroundModeData::GetBrowserWindow() {
88 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); 91 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
89 if (!browser) { 92 if (!browser) {
90 Browser::OpenEmptyWindow(profile_); 93 Browser::OpenEmptyWindow(profile_);
91 browser = BrowserList::GetLastActiveWithProfile(profile_); 94 browser = BrowserList::GetLastActiveWithProfile(profile_);
92 } 95 }
93 return browser; 96 return browser;
94 } 97 }
95 98
96 int BackgroundModeManager::BackgroundModeData::GetBackgroundAppCount() const { 99 int BackgroundModeManager::BackgroundModeData::GetBackgroundAppCount() const {
97 return applications_->size(); 100 return applications_->size();
98 } 101 }
99 102
100 void BackgroundModeManager::BackgroundModeData::BuildProfileMenu( 103 void BackgroundModeManager::BackgroundModeData::BuildProfileMenu(
101 ui::SimpleMenuModel* menu, 104 ui::SimpleMenuModel* menu,
102 ui::SimpleMenuModel* containing_menu) { 105 ui::SimpleMenuModel* containing_menu) {
103 int position = 0; 106 int position = 0;
104 // When there are no background applications, we want to display 107 // When there are no background applications, we want to display
105 // just a label stating that none are running. 108 // just a label stating that none are running.
106 if (applications_->size() < 1) { 109 if (applications_->size() < 1) {
107 menu->AddItemWithStringId(IDC_MinimumLabelValue, 110 menu->AddItemWithStringId(IDC_MinimumLabelValue,
108 IDS_BACKGROUND_APP_NOT_INSTALLED); 111 IDS_BACKGROUND_APP_NOT_INSTALLED);
109 } else { 112 } else {
110 for (ExtensionList::const_iterator cursor = applications_->begin(); 113 for (extensions::ExtensionList::const_iterator cursor =
114 applications_->begin();
111 cursor != applications_->end(); 115 cursor != applications_->end();
112 ++cursor, ++position) { 116 ++cursor, ++position) {
113 const SkBitmap* icon = applications_->GetIcon(*cursor); 117 const SkBitmap* icon = applications_->GetIcon(*cursor);
114 DCHECK(position == applications_->GetPosition(*cursor)); 118 DCHECK(position == applications_->GetPosition(*cursor));
115 const std::string& name = (*cursor)->name(); 119 const std::string& name = (*cursor)->name();
116 menu->AddItem(position, UTF8ToUTF16(name)); 120 menu->AddItem(position, UTF8ToUTF16(name));
117 if (icon) 121 if (icon)
118 menu->SetIcon(menu->GetItemCount() - 1, *icon); 122 menu->SetIcon(menu->GetItemCount() - 1, *icon);
119 } 123 }
120 } 124 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 *extension, profile)) { 303 *extension, profile)) {
300 // Extensions loaded after the ExtensionsService is ready should be 304 // Extensions loaded after the ExtensionsService is ready should be
301 // treated as new installs. 305 // treated as new installs.
302 if (profile->GetExtensionService()->is_ready()) 306 if (profile->GetExtensionService()->is_ready())
303 OnBackgroundAppInstalled(extension); 307 OnBackgroundAppInstalled(extension);
304 } 308 }
305 } 309 }
306 break; 310 break;
307 case chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED: { 311 case chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED: {
308 UpdatedExtensionPermissionsInfo* info = 312 UpdatedExtensionPermissionsInfo* info =
309 content::Details<UpdatedExtensionPermissionsInfo>(details).ptr(); 313 content::Details<UpdatedExtensionPermissionsInfo>( details).ptr();
sky 2012/05/14 15:00:07 '( d' -> '(d'
mitchellwrosen 2012/05/18 22:53:16 Done.
310 if (info->permissions->HasAPIPermission( 314 if (info->permissions->HasAPIPermission(
311 ExtensionAPIPermission::kBackground) && 315 ExtensionAPIPermission::kBackground) &&
312 info->reason == UpdatedExtensionPermissionsInfo::ADDED) { 316 info->reason == UpdatedExtensionPermissionsInfo::ADDED) {
313 // Turned on background permission, so treat this as a new install. 317 // Turned on background permission, so treat this as a new install.
314 OnBackgroundAppInstalled(info->extension); 318 OnBackgroundAppInstalled(info->extension);
315 } 319 }
316 } 320 }
317 break; 321 break;
318 case content::NOTIFICATION_APP_TERMINATING: 322 case content::NOTIFICATION_APP_TERMINATING:
319 // Make sure we aren't still keeping the app alive (only happens if we 323 // Make sure we aren't still keeping the app alive (only happens if we
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 } 765 }
762 } 766 }
763 return profile_it; 767 return profile_it;
764 } 768 }
765 769
766 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { 770 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const {
767 PrefService* service = g_browser_process->local_state(); 771 PrefService* service = g_browser_process->local_state();
768 DCHECK(service); 772 DCHECK(service);
769 return service->GetBoolean(prefs::kBackgroundModeEnabled); 773 return service->GetBoolean(prefs::kBackgroundModeEnabled);
770 } 774 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698