| 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/ui/extensions/extension_install_ui_default.h" | 5 #include "chrome/browser/ui/extensions/extension_install_ui_default.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/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" | 10 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // Creates an error infobar and delegate and adds the infobar to | 77 // Creates an error infobar and delegate and adds the infobar to |
| 78 // |infobar_service|. | 78 // |infobar_service|. |
| 79 static void Create(InfoBarService* infobar_service, | 79 static void Create(InfoBarService* infobar_service, |
| 80 const extensions::CrxInstallError& error); | 80 const extensions::CrxInstallError& error); |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 explicit ErrorInfoBarDelegate(const extensions::CrxInstallError& error); | 83 explicit ErrorInfoBarDelegate(const extensions::CrxInstallError& error); |
| 84 ~ErrorInfoBarDelegate() override; | 84 ~ErrorInfoBarDelegate() override; |
| 85 | 85 |
| 86 // ConfirmInfoBarDelegate: | 86 // ConfirmInfoBarDelegate: |
| 87 std::string GetIdentifier() const override; |
| 87 base::string16 GetMessageText() const override; | 88 base::string16 GetMessageText() const override; |
| 88 int GetButtons() const override; | 89 int GetButtons() const override; |
| 89 base::string16 GetLinkText() const override; | 90 base::string16 GetLinkText() const override; |
| 90 GURL GetLinkURL() const override; | 91 GURL GetLinkURL() const override; |
| 91 | 92 |
| 92 extensions::CrxInstallError error_; | 93 extensions::CrxInstallError error_; |
| 93 | 94 |
| 94 DISALLOW_COPY_AND_ASSIGN(ErrorInfoBarDelegate); | 95 DISALLOW_COPY_AND_ASSIGN(ErrorInfoBarDelegate); |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 // static | 98 // static |
| 98 void ErrorInfoBarDelegate::Create(InfoBarService* infobar_service, | 99 void ErrorInfoBarDelegate::Create(InfoBarService* infobar_service, |
| 99 const extensions::CrxInstallError& error) { | 100 const extensions::CrxInstallError& error) { |
| 100 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( | 101 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
| 101 scoped_ptr<ConfirmInfoBarDelegate>(new ErrorInfoBarDelegate(error)))); | 102 scoped_ptr<ConfirmInfoBarDelegate>(new ErrorInfoBarDelegate(error)))); |
| 102 } | 103 } |
| 103 | 104 |
| 104 ErrorInfoBarDelegate::ErrorInfoBarDelegate( | 105 ErrorInfoBarDelegate::ErrorInfoBarDelegate( |
| 105 const extensions::CrxInstallError& error) | 106 const extensions::CrxInstallError& error) |
| 106 : ConfirmInfoBarDelegate(), error_(error) { | 107 : ConfirmInfoBarDelegate(), error_(error) { |
| 107 } | 108 } |
| 108 | 109 |
| 109 ErrorInfoBarDelegate::~ErrorInfoBarDelegate() { | 110 ErrorInfoBarDelegate::~ErrorInfoBarDelegate() { |
| 110 } | 111 } |
| 111 | 112 |
| 113 std::string ErrorInfoBarDelegate::GetIdentifier() const { |
| 114 return "ErrorInfoBarDelegate"; |
| 115 } |
| 116 |
| 112 base::string16 ErrorInfoBarDelegate::GetMessageText() const { | 117 base::string16 ErrorInfoBarDelegate::GetMessageText() const { |
| 113 return error_.message(); | 118 return error_.message(); |
| 114 } | 119 } |
| 115 | 120 |
| 116 int ErrorInfoBarDelegate::GetButtons() const { | 121 int ErrorInfoBarDelegate::GetButtons() const { |
| 117 return BUTTON_OK; | 122 return BUTTON_OK; |
| 118 } | 123 } |
| 119 | 124 |
| 120 base::string16 ErrorInfoBarDelegate::GetLinkText() const { | 125 base::string16 ErrorInfoBarDelegate::GetLinkText() const { |
| 121 return (error_.type() == extensions::CrxInstallError::ERROR_OFF_STORE) | 126 return (error_.type() == extensions::CrxInstallError::ERROR_OFF_STORE) |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 gfx::NativeWindow ExtensionInstallUIDefault::GetDefaultInstallDialogParent() { | 255 gfx::NativeWindow ExtensionInstallUIDefault::GetDefaultInstallDialogParent() { |
| 251 Browser* browser = | 256 Browser* browser = |
| 252 chrome::FindLastActiveWithProfile(profile_, chrome::GetActiveDesktop()); | 257 chrome::FindLastActiveWithProfile(profile_, chrome::GetActiveDesktop()); |
| 253 if (browser) { | 258 if (browser) { |
| 254 content::WebContents* contents = | 259 content::WebContents* contents = |
| 255 browser->tab_strip_model()->GetActiveWebContents(); | 260 browser->tab_strip_model()->GetActiveWebContents(); |
| 256 return contents->GetTopLevelNativeWindow(); | 261 return contents->GetTopLevelNativeWindow(); |
| 257 } | 262 } |
| 258 return NULL; | 263 return NULL; |
| 259 } | 264 } |
| OLD | NEW |