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/extension_install_ui_default.h" | 5 #include "chrome/browser/extensions/extension_install_ui_default.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/extension_install_prompt.h" | 9 #include "chrome/browser/extensions/extension_install_prompt.h" |
10 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" | 10 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 bool disable_failure_ui_for_tests = false; | 47 bool disable_failure_ui_for_tests = false; |
48 | 48 |
49 // Helper class to put up an infobar when installation fails. | 49 // Helper class to put up an infobar when installation fails. |
50 class ErrorInfobarDelegate : public ConfirmInfoBarDelegate { | 50 class ErrorInfobarDelegate : public ConfirmInfoBarDelegate { |
51 public: | 51 public: |
52 ErrorInfobarDelegate(InfoBarTabHelper* infobar_helper, | 52 ErrorInfobarDelegate(InfoBarTabHelper* infobar_helper, |
53 Browser* browser, | 53 Browser* browser, |
54 const CrxInstallerError& error) | 54 const extensions::CrxInstallerError& error) |
55 : ConfirmInfoBarDelegate(infobar_helper), | 55 : ConfirmInfoBarDelegate(infobar_helper), |
56 browser_(browser), | 56 browser_(browser), |
57 error_(error) { | 57 error_(error) { |
58 } | 58 } |
59 | 59 |
60 private: | 60 private: |
61 virtual string16 GetMessageText() const OVERRIDE { | 61 virtual string16 GetMessageText() const OVERRIDE { |
62 return error_.message(); | 62 return error_.message(); |
63 } | 63 } |
64 | 64 |
65 virtual int GetButtons() const OVERRIDE { | 65 virtual int GetButtons() const OVERRIDE { |
66 return BUTTON_OK; | 66 return BUTTON_OK; |
67 } | 67 } |
68 | 68 |
69 virtual string16 GetLinkText() const OVERRIDE { | 69 virtual string16 GetLinkText() const OVERRIDE { |
70 return error_.type() == CrxInstallerError::ERROR_OFF_STORE ? | 70 return error_.type() == extensions::CrxInstallerError::ERROR_OFF_STORE ? |
71 l10n_util::GetStringUTF16(IDS_LEARN_MORE) : ASCIIToUTF16(""); | 71 l10n_util::GetStringUTF16(IDS_LEARN_MORE) : ASCIIToUTF16(""); |
72 } | 72 } |
73 | 73 |
74 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE { | 74 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE { |
75 chrome::NavigateParams params( | 75 chrome::NavigateParams params( |
76 browser_, | 76 browser_, |
77 GURL("http://support.google.com/chrome_webstore/?p=crx_warning"), | 77 GURL("http://support.google.com/chrome_webstore/?p=crx_warning"), |
78 content::PAGE_TRANSITION_LINK); | 78 content::PAGE_TRANSITION_LINK); |
79 params.disposition = NEW_FOREGROUND_TAB; | 79 params.disposition = NEW_FOREGROUND_TAB; |
80 chrome::Navigate(¶ms); | 80 chrome::Navigate(¶ms); |
81 return false; | 81 return false; |
82 } | 82 } |
83 | 83 |
84 Browser* browser_; | 84 Browser* browser_; |
85 CrxInstallerError error_; | 85 extensions::CrxInstallerError error_; |
86 }; | 86 }; |
87 | 87 |
88 } // namespace | 88 } // namespace |
89 | 89 |
90 ExtensionInstallUIDefault::ExtensionInstallUIDefault(Browser* browser) | 90 ExtensionInstallUIDefault::ExtensionInstallUIDefault(Browser* browser) |
91 : skip_post_install_ui_(false), | 91 : skip_post_install_ui_(false), |
92 previous_using_native_theme_(false), | 92 previous_using_native_theme_(false), |
93 use_app_installed_bubble_(false) { | 93 use_app_installed_bubble_(false) { |
94 browser_ = browser; | 94 browser_ = browser; |
95 | 95 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 if (extension->is_app() && !use_bubble_for_apps) { | 138 if (extension->is_app() && !use_bubble_for_apps) { |
139 ExtensionInstallUI::OpenAppInstalledUI(browser, extension->id()); | 139 ExtensionInstallUI::OpenAppInstalledUI(browser, extension->id()); |
140 return; | 140 return; |
141 } | 141 } |
142 | 142 |
143 chrome::ShowExtensionInstalledBubble(extension, browser, *icon); | 143 chrome::ShowExtensionInstalledBubble(extension, browser, *icon); |
144 } | 144 } |
145 | 145 |
146 void ExtensionInstallUIDefault::OnInstallFailure( | 146 void ExtensionInstallUIDefault::OnInstallFailure( |
147 const CrxInstallerError& error) { | 147 const extensions::CrxInstallerError& error) { |
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
149 if (disable_failure_ui_for_tests || skip_post_install_ui_) | 149 if (disable_failure_ui_for_tests || skip_post_install_ui_) |
150 return; | 150 return; |
151 | 151 |
152 Browser* browser = browser::FindLastActiveWithProfile(browser_->profile()); | 152 Browser* browser = browser::FindLastActiveWithProfile(browser_->profile()); |
153 TabContents* tab_contents = chrome::GetActiveTabContents(browser); | 153 TabContents* tab_contents = chrome::GetActiveTabContents(browser); |
154 if (!tab_contents) | 154 if (!tab_contents) |
155 return; | 155 return; |
156 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 156 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); |
157 infobar_helper->AddInfoBar( | 157 infobar_helper->AddInfoBar( |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 #else | 253 #else |
254 NOTREACHED(); | 254 NOTREACHED(); |
255 #endif | 255 #endif |
256 } | 256 } |
257 } | 257 } |
258 | 258 |
259 // static | 259 // static |
260 void ExtensionInstallUI::DisableFailureUIForTests() { | 260 void ExtensionInstallUI::DisableFailureUIForTests() { |
261 disable_failure_ui_for_tests = true; | 261 disable_failure_ui_for_tests = true; |
262 } | 262 } |
OLD | NEW |