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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/extensions/extension_install_prompt.h" | 11 #include "chrome/browser/extensions/extension_install_prompt.h" |
12 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" | 12 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" |
13 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 13 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 14 #include "chrome/browser/infobars/infobar.h" |
14 #include "chrome/browser/infobars/infobar_service.h" | 15 #include "chrome/browser/infobars/infobar_service.h" |
15 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 16 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/search/search.h" | 18 #include "chrome/browser/search/search.h" |
18 #include "chrome/browser/themes/theme_service.h" | 19 #include "chrome/browser/themes/theme_service.h" |
19 #include "chrome/browser/themes/theme_service_factory.h" | 20 #include "chrome/browser/themes/theme_service_factory.h" |
20 #include "chrome/browser/ui/app_list/app_list_service.h" | 21 #include "chrome/browser/ui/app_list/app_list_service.h" |
21 #include "chrome/browser/ui/app_list/app_list_util.h" | 22 #include "chrome/browser/ui/app_list/app_list_util.h" |
22 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/browser_dialogs.h" | 24 #include "chrome/browser/ui/browser_dialogs.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 if (browser) | 74 if (browser) |
74 chrome::ShowExtensionInstalledBubble(extension, browser, icon); | 75 chrome::ShowExtensionInstalledBubble(extension, browser, icon); |
75 } | 76 } |
76 | 77 |
77 | 78 |
78 // ErrorInfoBarDelegate ------------------------------------------------------- | 79 // ErrorInfoBarDelegate ------------------------------------------------------- |
79 | 80 |
80 // Helper class to put up an infobar when installation fails. | 81 // Helper class to put up an infobar when installation fails. |
81 class ErrorInfoBarDelegate : public ConfirmInfoBarDelegate { | 82 class ErrorInfoBarDelegate : public ConfirmInfoBarDelegate { |
82 public: | 83 public: |
83 // Creates an error infobar delegate and adds it to |infobar_service|. | 84 // Creates an error infobar and delegate and adds the infobar to |
| 85 // |infobar_service|. |
84 static void Create(InfoBarService* infobar_service, | 86 static void Create(InfoBarService* infobar_service, |
85 const extensions::CrxInstallerError& error); | 87 const extensions::CrxInstallerError& error); |
86 | 88 |
87 private: | 89 private: |
88 ErrorInfoBarDelegate(InfoBarService* infobar_service, | 90 explicit ErrorInfoBarDelegate(const extensions::CrxInstallerError& error); |
89 const extensions::CrxInstallerError& error); | |
90 virtual ~ErrorInfoBarDelegate(); | 91 virtual ~ErrorInfoBarDelegate(); |
91 | 92 |
92 // ConfirmInfoBarDelegate: | 93 // ConfirmInfoBarDelegate: |
93 virtual string16 GetMessageText() const OVERRIDE; | 94 virtual string16 GetMessageText() const OVERRIDE; |
94 virtual int GetButtons() const OVERRIDE; | 95 virtual int GetButtons() const OVERRIDE; |
95 virtual string16 GetLinkText() const OVERRIDE; | 96 virtual string16 GetLinkText() const OVERRIDE; |
96 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 97 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
97 | 98 |
98 extensions::CrxInstallerError error_; | 99 extensions::CrxInstallerError error_; |
99 | 100 |
100 DISALLOW_COPY_AND_ASSIGN(ErrorInfoBarDelegate); | 101 DISALLOW_COPY_AND_ASSIGN(ErrorInfoBarDelegate); |
101 }; | 102 }; |
102 | 103 |
103 // static | 104 // static |
104 void ErrorInfoBarDelegate::Create(InfoBarService* infobar_service, | 105 void ErrorInfoBarDelegate::Create(InfoBarService* infobar_service, |
105 const extensions::CrxInstallerError& error) { | 106 const extensions::CrxInstallerError& error) { |
106 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( | 107 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( |
107 new ErrorInfoBarDelegate(infobar_service, error))); | 108 scoped_ptr<ConfirmInfoBarDelegate>(new ErrorInfoBarDelegate(error)))); |
108 } | 109 } |
109 | 110 |
110 ErrorInfoBarDelegate::ErrorInfoBarDelegate( | 111 ErrorInfoBarDelegate::ErrorInfoBarDelegate( |
111 InfoBarService* infobar_service, | |
112 const extensions::CrxInstallerError& error) | 112 const extensions::CrxInstallerError& error) |
113 : ConfirmInfoBarDelegate(infobar_service), | 113 : ConfirmInfoBarDelegate(), |
114 error_(error) { | 114 error_(error) { |
115 } | 115 } |
116 | 116 |
117 ErrorInfoBarDelegate::~ErrorInfoBarDelegate() { | 117 ErrorInfoBarDelegate::~ErrorInfoBarDelegate() { |
118 } | 118 } |
119 | 119 |
120 string16 ErrorInfoBarDelegate::GetMessageText() const { | 120 string16 ErrorInfoBarDelegate::GetMessageText() const { |
121 return error_.message(); | 121 return error_.message(); |
122 } | 122 } |
123 | 123 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 browser->tab_strip_model()->GetActiveWebContents(); | 284 browser->tab_strip_model()->GetActiveWebContents(); |
285 if (!web_contents) | 285 if (!web_contents) |
286 return; | 286 return; |
287 ErrorInfoBarDelegate::Create(InfoBarService::FromWebContents(web_contents), | 287 ErrorInfoBarDelegate::Create(InfoBarService::FromWebContents(web_contents), |
288 error); | 288 error); |
289 } | 289 } |
290 | 290 |
291 void ExtensionInstallUIDefault::SetUseAppInstalledBubble(bool use_bubble) { | 291 void ExtensionInstallUIDefault::SetUseAppInstalledBubble(bool use_bubble) { |
292 use_app_installed_bubble_ = use_bubble; | 292 use_app_installed_bubble_ = use_bubble; |
293 } | 293 } |
OLD | NEW |