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 "chrome/browser/extensions/external_install_ui.h" | 5 #include "chrome/browser/extensions/external_install_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
29 #include "chrome/common/extensions/extension.h" | 29 #include "chrome/common/extensions/extension.h" |
30 #include "content/public/browser/notification_details.h" | 30 #include "content/public/browser/notification_details.h" |
31 #include "content/public/browser/notification_observer.h" | 31 #include "content/public/browser/notification_observer.h" |
32 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
33 #include "content/public/browser/notification_source.h" | 33 #include "content/public/browser/notification_source.h" |
34 #include "grit/chromium_strings.h" | 34 #include "grit/chromium_strings.h" |
35 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
36 #include "grit/theme_resources.h" | 36 #include "grit/theme_resources.h" |
37 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
| 38 #include "ui/base/resource/resource_bundle.h" |
| 39 #include "ui/gfx/image/image.h" |
38 | 40 |
39 namespace extensions { | 41 namespace extensions { |
40 | 42 |
41 namespace { | 43 namespace { |
42 | 44 |
43 // Whether the external extension can use the streamlined bubble install flow. | 45 // Whether the external extension can use the streamlined bubble install flow. |
44 bool UseBubbleInstall(const Extension* extension, bool is_new_profile) { | 46 bool UseBubbleInstall(const Extension* extension, bool is_new_profile) { |
45 return extension->UpdatesFromGallery() && !is_new_profile; | 47 return extension->UpdatesFromGallery() && !is_new_profile; |
46 } | 48 } |
47 | 49 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 93 |
92 const Extension* extension() const { return extension_; } | 94 const Extension* extension() const { return extension_; } |
93 | 95 |
94 // GlobalError implementation. | 96 // GlobalError implementation. |
95 virtual Severity GetSeverity() OVERRIDE; | 97 virtual Severity GetSeverity() OVERRIDE; |
96 virtual bool HasMenuItem() OVERRIDE; | 98 virtual bool HasMenuItem() OVERRIDE; |
97 virtual int MenuItemCommandID() OVERRIDE; | 99 virtual int MenuItemCommandID() OVERRIDE; |
98 virtual string16 MenuItemLabel() OVERRIDE; | 100 virtual string16 MenuItemLabel() OVERRIDE; |
99 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; | 101 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; |
100 virtual bool HasBubbleView() OVERRIDE; | 102 virtual bool HasBubbleView() OVERRIDE; |
| 103 virtual gfx::Image GetBubbleViewIcon() OVERRIDE; |
101 virtual string16 GetBubbleViewTitle() OVERRIDE; | 104 virtual string16 GetBubbleViewTitle() OVERRIDE; |
102 virtual std::vector<string16> GetBubbleViewMessages() OVERRIDE; | 105 virtual std::vector<string16> GetBubbleViewMessages() OVERRIDE; |
103 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; | 106 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; |
104 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; | 107 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; |
105 virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; | 108 virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; |
106 virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; | 109 virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; |
107 virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; | 110 virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; |
108 | 111 |
109 // content::NotificationObserver implementation. | 112 // content::NotificationObserver implementation. |
110 virtual void Observe(int type, | 113 virtual void Observe(int type, |
(...skipping 12 matching lines...) Expand all Loading... |
123 ExternalInstallGlobalError(ExtensionService* service, | 126 ExternalInstallGlobalError(ExtensionService* service, |
124 const Extension* extension); | 127 const Extension* extension); |
125 virtual ~ExternalInstallGlobalError(); | 128 virtual ~ExternalInstallGlobalError(); |
126 | 129 |
127 void set_prompt(const ExtensionInstallPrompt::Prompt& prompt) { | 130 void set_prompt(const ExtensionInstallPrompt::Prompt& prompt) { |
128 prompt_ = &prompt; | 131 prompt_ = &prompt; |
129 } | 132 } |
130 | 133 |
131 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; | 134 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; |
132 virtual bool HasBubbleView() OVERRIDE; | 135 virtual bool HasBubbleView() OVERRIDE; |
| 136 virtual gfx::Image GetBubbleViewIcon() OVERRIDE; |
133 virtual string16 GetBubbleViewTitle() OVERRIDE; | 137 virtual string16 GetBubbleViewTitle() OVERRIDE; |
134 virtual std::vector<string16> GetBubbleViewMessages() OVERRIDE; | 138 virtual std::vector<string16> GetBubbleViewMessages() OVERRIDE; |
135 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; | 139 virtual string16 GetBubbleViewAcceptButtonLabel() OVERRIDE; |
136 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; | 140 virtual string16 GetBubbleViewCancelButtonLabel() OVERRIDE; |
137 virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; | 141 virtual void OnBubbleViewDidClose(Browser* browser) OVERRIDE; |
138 virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; | 142 virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE; |
139 virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; | 143 virtual void BubbleViewCancelButtonPressed(Browser* browser) OVERRIDE; |
140 | 144 |
141 protected: | 145 protected: |
142 // Ref-counted, but needs to be disposed of if we are dismissed without | 146 // Ref-counted, but needs to be disposed of if we are dismissed without |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 return l10n_util::GetStringFUTF16(id, UTF8ToUTF16(extension_->name())); | 238 return l10n_util::GetStringFUTF16(id, UTF8ToUTF16(extension_->name())); |
235 } | 239 } |
236 | 240 |
237 void ExternalInstallMenuAlert::ExecuteMenuItem(Browser* browser) { | 241 void ExternalInstallMenuAlert::ExecuteMenuItem(Browser* browser) { |
238 ShowExternalInstallDialog(service_, browser, extension_); | 242 ShowExternalInstallDialog(service_, browser, extension_); |
239 } | 243 } |
240 | 244 |
241 bool ExternalInstallMenuAlert::HasBubbleView() { | 245 bool ExternalInstallMenuAlert::HasBubbleView() { |
242 return false; | 246 return false; |
243 } | 247 } |
| 248 |
| 249 gfx::Image ExternalInstallMenuAlert::GetBubbleViewIcon() { |
| 250 return gfx::Image(); |
| 251 } |
| 252 |
244 string16 ExternalInstallMenuAlert::GetBubbleViewTitle() { | 253 string16 ExternalInstallMenuAlert::GetBubbleViewTitle() { |
245 return string16(); | 254 return string16(); |
246 } | 255 } |
247 | 256 |
248 std::vector<string16> ExternalInstallMenuAlert::GetBubbleViewMessages() { | 257 std::vector<string16> ExternalInstallMenuAlert::GetBubbleViewMessages() { |
249 return std::vector<string16>(); | 258 return std::vector<string16>(); |
250 } | 259 } |
251 | 260 |
252 string16 ExternalInstallMenuAlert::GetBubbleViewAcceptButtonLabel() { | 261 string16 ExternalInstallMenuAlert::GetBubbleViewAcceptButtonLabel() { |
253 return string16(); | 262 return string16(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 319 } |
311 | 320 |
312 void ExternalInstallGlobalError::ExecuteMenuItem(Browser* browser) { | 321 void ExternalInstallGlobalError::ExecuteMenuItem(Browser* browser) { |
313 ShowBubbleView(browser); | 322 ShowBubbleView(browser); |
314 } | 323 } |
315 | 324 |
316 bool ExternalInstallGlobalError::HasBubbleView() { | 325 bool ExternalInstallGlobalError::HasBubbleView() { |
317 return true; | 326 return true; |
318 } | 327 } |
319 | 328 |
| 329 gfx::Image ExternalInstallGlobalError::GetBubbleViewIcon() { |
| 330 return ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 331 IDR_INPUT_ALERT); |
| 332 } |
| 333 |
320 string16 ExternalInstallGlobalError::GetBubbleViewTitle() { | 334 string16 ExternalInstallGlobalError::GetBubbleViewTitle() { |
321 return prompt_->GetDialogTitle(); | 335 return prompt_->GetDialogTitle(); |
322 } | 336 } |
323 | 337 |
324 std::vector<string16> ExternalInstallGlobalError::GetBubbleViewMessages() { | 338 std::vector<string16> ExternalInstallGlobalError::GetBubbleViewMessages() { |
325 std::vector<string16> messages; | 339 std::vector<string16> messages; |
326 messages.push_back(prompt_->GetHeading()); | 340 messages.push_back(prompt_->GetHeading()); |
327 if (prompt_->GetPermissionCount()) { | 341 if (prompt_->GetPermissionCount()) { |
328 messages.push_back(prompt_->GetPermissionsHeading()); | 342 messages.push_back(prompt_->GetPermissionsHeading()); |
329 for (size_t i = 0; i < prompt_->GetPermissionCount(); ++i) { | 343 for (size_t i = 0; i < prompt_->GetPermissionCount(); ++i) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 | 427 |
414 bool HasExternalInstallBubble(ExtensionService* service) { | 428 bool HasExternalInstallBubble(ExtensionService* service) { |
415 GlobalErrorService* error_service = | 429 GlobalErrorService* error_service = |
416 GlobalErrorServiceFactory::GetForProfile(service->profile()); | 430 GlobalErrorServiceFactory::GetForProfile(service->profile()); |
417 GlobalError* error = error_service->GetGlobalErrorByMenuItemCommandID( | 431 GlobalError* error = error_service->GetGlobalErrorByMenuItemCommandID( |
418 kMenuCommandId); | 432 kMenuCommandId); |
419 return error && error->HasBubbleView(); | 433 return error && error->HasBubbleView(); |
420 } | 434 } |
421 | 435 |
422 } // namespace extensions | 436 } // namespace extensions |
OLD | NEW |