OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
36 #include "content/public/browser/notification_types.h" | 36 #include "content/public/browser/notification_types.h" |
37 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
38 #include "grit/chromium_strings.h" | 38 #include "grit/chromium_strings.h" |
39 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
40 #include "grit/theme_resources.h" | 40 #include "grit/theme_resources.h" |
41 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
42 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
43 | 43 |
44 using content::UserMetricsAction; | 44 using content::UserMetricsAction; |
| 45 using extensions::Extension; |
| 46 using extensions::UpdatedExtensionPermissionsInfo; |
45 | 47 |
46 BackgroundModeManager::BackgroundModeData::BackgroundModeData( | 48 BackgroundModeManager::BackgroundModeData::BackgroundModeData( |
47 int command_id, | 49 int command_id, |
48 Profile* profile) | 50 Profile* profile) |
49 : applications_(new BackgroundApplicationListModel(profile)), | 51 : applications_(new BackgroundApplicationListModel(profile)), |
50 command_id_(command_id), | 52 command_id_(command_id), |
51 profile_(profile) { | 53 profile_(profile) { |
52 } | 54 } |
53 | 55 |
54 BackgroundModeManager::BackgroundModeData::~BackgroundModeData() { | 56 BackgroundModeManager::BackgroundModeData::~BackgroundModeData() { |
(...skipping 18 matching lines...) Expand all Loading... |
73 return false; | 75 return false; |
74 } | 76 } |
75 | 77 |
76 void BackgroundModeManager::BackgroundModeData::ExecuteCommand(int item) { | 78 void BackgroundModeManager::BackgroundModeData::ExecuteCommand(int item) { |
77 switch (item) { | 79 switch (item) { |
78 case IDC_MinimumLabelValue: | 80 case IDC_MinimumLabelValue: |
79 // Do nothing. This is just a label. | 81 // Do nothing. This is just a label. |
80 break; | 82 break; |
81 default: | 83 default: |
82 // Launch the app associated with this item. | 84 // Launch the app associated with this item. |
83 const Extension* extension = applications_->GetExtension(item); | 85 const Extension* extension = applications_-> |
| 86 GetExtension(item); |
84 BackgroundModeManager::LaunchBackgroundApplication(profile_, extension); | 87 BackgroundModeManager::LaunchBackgroundApplication(profile_, extension); |
85 break; | 88 break; |
86 } | 89 } |
87 } | 90 } |
88 | 91 |
89 Browser* BackgroundModeManager::BackgroundModeData::GetBrowserWindow() { | 92 Browser* BackgroundModeManager::BackgroundModeData::GetBrowserWindow() { |
90 Browser* browser = browser::FindLastActiveWithProfile(profile_); | 93 Browser* browser = browser::FindLastActiveWithProfile(profile_); |
91 if (!browser) { | 94 if (!browser) { |
92 Browser::OpenEmptyWindow(profile_); | 95 Browser::OpenEmptyWindow(profile_); |
93 browser = browser::FindLastActiveWithProfile(profile_); | 96 browser = browser::FindLastActiveWithProfile(profile_); |
94 } | 97 } |
95 return browser; | 98 return browser; |
96 } | 99 } |
97 | 100 |
98 int BackgroundModeManager::BackgroundModeData::GetBackgroundAppCount() const { | 101 int BackgroundModeManager::BackgroundModeData::GetBackgroundAppCount() const { |
99 return applications_->size(); | 102 return applications_->size(); |
100 } | 103 } |
101 | 104 |
102 void BackgroundModeManager::BackgroundModeData::BuildProfileMenu( | 105 void BackgroundModeManager::BackgroundModeData::BuildProfileMenu( |
103 ui::SimpleMenuModel* menu, | 106 ui::SimpleMenuModel* menu, |
104 ui::SimpleMenuModel* containing_menu) { | 107 ui::SimpleMenuModel* containing_menu) { |
105 int position = 0; | 108 int position = 0; |
106 // When there are no background applications, we want to display | 109 // When there are no background applications, we want to display |
107 // just a label stating that none are running. | 110 // just a label stating that none are running. |
108 if (applications_->size() < 1) { | 111 if (applications_->size() < 1) { |
109 menu->AddItemWithStringId(IDC_MinimumLabelValue, | 112 menu->AddItemWithStringId(IDC_MinimumLabelValue, |
110 IDS_BACKGROUND_APP_NOT_INSTALLED); | 113 IDS_BACKGROUND_APP_NOT_INSTALLED); |
111 } else { | 114 } else { |
112 for (ExtensionList::const_iterator cursor = applications_->begin(); | 115 for (extensions::ExtensionList::const_iterator cursor = |
| 116 applications_->begin(); |
113 cursor != applications_->end(); | 117 cursor != applications_->end(); |
114 ++cursor, ++position) { | 118 ++cursor, ++position) { |
115 const SkBitmap* icon = applications_->GetIcon(*cursor); | 119 const SkBitmap* icon = applications_->GetIcon(*cursor); |
116 DCHECK(position == applications_->GetPosition(*cursor)); | 120 DCHECK(position == applications_->GetPosition(*cursor)); |
117 const std::string& name = (*cursor)->name(); | 121 const std::string& name = (*cursor)->name(); |
118 menu->AddItem(position, UTF8ToUTF16(name)); | 122 menu->AddItem(position, UTF8ToUTF16(name)); |
119 if (icon) | 123 if (icon) |
120 menu->SetIcon(menu->GetItemCount() - 1, *icon); | 124 menu->SetIcon(menu->GetItemCount() - 1, *icon); |
121 } | 125 } |
122 } | 126 } |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 } | 767 } |
764 } | 768 } |
765 return profile_it; | 769 return profile_it; |
766 } | 770 } |
767 | 771 |
768 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { | 772 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { |
769 PrefService* service = g_browser_process->local_state(); | 773 PrefService* service = g_browser_process->local_state(); |
770 DCHECK(service); | 774 DCHECK(service); |
771 return service->GetBoolean(prefs::kBackgroundModeEnabled); | 775 return service->GetBoolean(prefs::kBackgroundModeEnabled); |
772 } | 776 } |
OLD | NEW |