| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_error.h" | 5 #include "chrome/browser/extensions/external_install_error.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 else | 44 else |
| 45 id = IDS_EXTENSION_EXTERNAL_INSTALL_ALERT_EXTENSION; | 45 id = IDS_EXTENSION_EXTERNAL_INSTALL_ALERT_EXTENSION; |
| 46 | 46 |
| 47 return l10n_util::GetStringFUTF16(id, base::UTF8ToUTF16(extension->name())); | 47 return l10n_util::GetStringFUTF16(id, base::UTF8ToUTF16(extension->name())); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // A global error that spawns a dialog when the menu item is clicked. | 50 // A global error that spawns a dialog when the menu item is clicked. |
| 51 class ExternalInstallMenuAlert : public GlobalError { | 51 class ExternalInstallMenuAlert : public GlobalError { |
| 52 public: | 52 public: |
| 53 explicit ExternalInstallMenuAlert(ExternalInstallError* error); | 53 explicit ExternalInstallMenuAlert(ExternalInstallError* error); |
| 54 virtual ~ExternalInstallMenuAlert(); | 54 ~ExternalInstallMenuAlert() override; |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 // GlobalError implementation. | 57 // GlobalError implementation. |
| 58 virtual Severity GetSeverity() override; | 58 Severity GetSeverity() override; |
| 59 virtual bool HasMenuItem() override; | 59 bool HasMenuItem() override; |
| 60 virtual int MenuItemCommandID() override; | 60 int MenuItemCommandID() override; |
| 61 virtual base::string16 MenuItemLabel() override; | 61 base::string16 MenuItemLabel() override; |
| 62 virtual void ExecuteMenuItem(Browser* browser) override; | 62 void ExecuteMenuItem(Browser* browser) override; |
| 63 virtual bool HasBubbleView() override; | 63 bool HasBubbleView() override; |
| 64 virtual bool HasShownBubbleView() override; | 64 bool HasShownBubbleView() override; |
| 65 virtual void ShowBubbleView(Browser* browser) override; | 65 void ShowBubbleView(Browser* browser) override; |
| 66 virtual GlobalErrorBubbleViewBase* GetBubbleView() override; | 66 GlobalErrorBubbleViewBase* GetBubbleView() override; |
| 67 | 67 |
| 68 // The owning ExternalInstallError. | 68 // The owning ExternalInstallError. |
| 69 ExternalInstallError* error_; | 69 ExternalInstallError* error_; |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(ExternalInstallMenuAlert); | 71 DISALLOW_COPY_AND_ASSIGN(ExternalInstallMenuAlert); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 // A global error that spawns a bubble when the menu item is clicked. | 74 // A global error that spawns a bubble when the menu item is clicked. |
| 75 class ExternalInstallBubbleAlert : public GlobalErrorWithStandardBubble { | 75 class ExternalInstallBubbleAlert : public GlobalErrorWithStandardBubble { |
| 76 public: | 76 public: |
| 77 explicit ExternalInstallBubbleAlert(ExternalInstallError* error, | 77 explicit ExternalInstallBubbleAlert(ExternalInstallError* error, |
| 78 ExtensionInstallPrompt::Prompt* prompt); | 78 ExtensionInstallPrompt::Prompt* prompt); |
| 79 virtual ~ExternalInstallBubbleAlert(); | 79 ~ExternalInstallBubbleAlert() override; |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 // GlobalError implementation. | 82 // GlobalError implementation. |
| 83 virtual Severity GetSeverity() override; | 83 Severity GetSeverity() override; |
| 84 virtual bool HasMenuItem() override; | 84 bool HasMenuItem() override; |
| 85 virtual int MenuItemCommandID() override; | 85 int MenuItemCommandID() override; |
| 86 virtual base::string16 MenuItemLabel() override; | 86 base::string16 MenuItemLabel() override; |
| 87 virtual void ExecuteMenuItem(Browser* browser) override; | 87 void ExecuteMenuItem(Browser* browser) override; |
| 88 | 88 |
| 89 // GlobalErrorWithStandardBubble implementation. | 89 // GlobalErrorWithStandardBubble implementation. |
| 90 virtual gfx::Image GetBubbleViewIcon() override; | 90 gfx::Image GetBubbleViewIcon() override; |
| 91 virtual base::string16 GetBubbleViewTitle() override; | 91 base::string16 GetBubbleViewTitle() override; |
| 92 virtual std::vector<base::string16> GetBubbleViewMessages() override; | 92 std::vector<base::string16> GetBubbleViewMessages() override; |
| 93 virtual base::string16 GetBubbleViewAcceptButtonLabel() override; | 93 base::string16 GetBubbleViewAcceptButtonLabel() override; |
| 94 virtual base::string16 GetBubbleViewCancelButtonLabel() override; | 94 base::string16 GetBubbleViewCancelButtonLabel() override; |
| 95 virtual void OnBubbleViewDidClose(Browser* browser) override; | 95 void OnBubbleViewDidClose(Browser* browser) override; |
| 96 virtual void BubbleViewAcceptButtonPressed(Browser* browser) override; | 96 void BubbleViewAcceptButtonPressed(Browser* browser) override; |
| 97 virtual void BubbleViewCancelButtonPressed(Browser* browser) override; | 97 void BubbleViewCancelButtonPressed(Browser* browser) override; |
| 98 | 98 |
| 99 // The owning ExternalInstallError. | 99 // The owning ExternalInstallError. |
| 100 ExternalInstallError* error_; | 100 ExternalInstallError* error_; |
| 101 | 101 |
| 102 // The Prompt with all information, which we then use to populate the bubble. | 102 // The Prompt with all information, which we then use to populate the bubble. |
| 103 ExtensionInstallPrompt::Prompt* prompt_; | 103 ExtensionInstallPrompt::Prompt* prompt_; |
| 104 | 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(ExternalInstallBubbleAlert); | 105 DISALLOW_COPY_AND_ASSIGN(ExternalInstallBubbleAlert); |
| 106 }; | 106 }; |
| 107 | 107 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 if (browser) | 395 if (browser) |
| 396 global_error_->ShowBubbleView(browser); | 396 global_error_->ShowBubbleView(browser); |
| 397 } else { | 397 } else { |
| 398 DCHECK(alert_type_ == MENU_ALERT); | 398 DCHECK(alert_type_ == MENU_ALERT); |
| 399 global_error_.reset(new ExternalInstallMenuAlert(this)); | 399 global_error_.reset(new ExternalInstallMenuAlert(this)); |
| 400 error_service_->AddGlobalError(global_error_.get()); | 400 error_service_->AddGlobalError(global_error_.get()); |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 | 403 |
| 404 } // namespace extensions | 404 } // namespace extensions |
| OLD | NEW |