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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 bool disable_failure_ui_for_tests = false; | 48 bool disable_failure_ui_for_tests = false; |
49 | 49 |
50 // Helper class to put up an infobar when installation fails. | 50 // Helper class to put up an infobar when installation fails. |
51 class ErrorInfobarDelegate : public ConfirmInfoBarDelegate { | 51 class ErrorInfobarDelegate : public ConfirmInfoBarDelegate { |
52 public: | 52 public: |
53 ErrorInfobarDelegate(InfoBarTabHelper* infobar_helper, | 53 ErrorInfobarDelegate(InfoBarTabHelper* infobar_helper, |
54 Browser* browser, | 54 Browser* browser, |
55 const CrxInstallerError& error) | 55 const extensions::CrxInstallerError& error) |
56 : ConfirmInfoBarDelegate(infobar_helper), | 56 : ConfirmInfoBarDelegate(infobar_helper), |
57 browser_(browser), | 57 browser_(browser), |
58 error_(error) { | 58 error_(error) { |
59 } | 59 } |
60 | 60 |
61 private: | 61 private: |
62 virtual string16 GetMessageText() const OVERRIDE { | 62 virtual string16 GetMessageText() const OVERRIDE { |
63 return error_.message(); | 63 return error_.message(); |
64 } | 64 } |
65 | 65 |
66 virtual int GetButtons() const OVERRIDE { | 66 virtual int GetButtons() const OVERRIDE { |
67 return BUTTON_OK; | 67 return BUTTON_OK; |
68 } | 68 } |
69 | 69 |
70 virtual string16 GetLinkText() const OVERRIDE { | 70 virtual string16 GetLinkText() const OVERRIDE { |
71 return error_.type() == CrxInstallerError::ERROR_OFF_STORE ? | 71 return error_.type() == extensions::CrxInstallerError::ERROR_OFF_STORE ? |
72 l10n_util::GetStringUTF16(IDS_LEARN_MORE) : ASCIIToUTF16(""); | 72 l10n_util::GetStringUTF16(IDS_LEARN_MORE) : ASCIIToUTF16(""); |
73 } | 73 } |
74 | 74 |
75 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE { | 75 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE { |
76 chrome::NavigateParams params( | 76 chrome::NavigateParams params( |
77 browser_, | 77 browser_, |
78 GURL("http://support.google.com/chrome_webstore/?p=crx_warning"), | 78 GURL("http://support.google.com/chrome_webstore/?p=crx_warning"), |
79 content::PAGE_TRANSITION_LINK); | 79 content::PAGE_TRANSITION_LINK); |
80 params.disposition = NEW_FOREGROUND_TAB; | 80 params.disposition = NEW_FOREGROUND_TAB; |
81 chrome::Navigate(¶ms); | 81 chrome::Navigate(¶ms); |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 Browser* browser_; | 85 Browser* browser_; |
86 CrxInstallerError error_; | 86 extensions::CrxInstallerError error_; |
87 }; | 87 }; |
88 | 88 |
89 } // namespace | 89 } // namespace |
90 | 90 |
91 ExtensionInstallUIDefault::ExtensionInstallUIDefault(Profile* profile) | 91 ExtensionInstallUIDefault::ExtensionInstallUIDefault(Profile* profile) |
92 : skip_post_install_ui_(false), | 92 : skip_post_install_ui_(false), |
93 previous_using_native_theme_(false), | 93 previous_using_native_theme_(false), |
94 use_app_installed_bubble_(false) { | 94 use_app_installed_bubble_(false) { |
95 profile_ = profile; | 95 profile_ = profile; |
96 | 96 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 if (extension->is_app() && !use_bubble_for_apps) { | 139 if (extension->is_app() && !use_bubble_for_apps) { |
140 ExtensionInstallUI::OpenAppInstalledUI(browser, extension->id()); | 140 ExtensionInstallUI::OpenAppInstalledUI(browser, extension->id()); |
141 return; | 141 return; |
142 } | 142 } |
143 | 143 |
144 chrome::ShowExtensionInstalledBubble(extension, browser, *icon); | 144 chrome::ShowExtensionInstalledBubble(extension, browser, *icon); |
145 } | 145 } |
146 | 146 |
147 void ExtensionInstallUIDefault::OnInstallFailure( | 147 void ExtensionInstallUIDefault::OnInstallFailure( |
148 const CrxInstallerError& error) { | 148 const extensions::CrxInstallerError& error) { |
149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
150 if (disable_failure_ui_for_tests || skip_post_install_ui_) | 150 if (disable_failure_ui_for_tests || skip_post_install_ui_) |
151 return; | 151 return; |
152 | 152 |
153 Browser* browser = browser::FindLastActiveWithProfile(profile_); | 153 Browser* browser = browser::FindLastActiveWithProfile(profile_); |
154 TabContents* tab_contents = chrome::GetActiveTabContents(browser); | 154 TabContents* tab_contents = chrome::GetActiveTabContents(browser); |
155 if (!tab_contents) | 155 if (!tab_contents) |
156 return; | 156 return; |
157 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 157 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); |
158 infobar_helper->AddInfoBar( | 158 infobar_helper->AddInfoBar( |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 Browser* browser = browser::FindBrowserWithWebContents(web_contents); | 268 Browser* browser = browser::FindBrowserWithWebContents(web_contents); |
269 return chrome::CreateExtensionInstallPromptWithBrowser(browser); | 269 return chrome::CreateExtensionInstallPromptWithBrowser(browser); |
270 } | 270 } |
271 | 271 |
272 // static | 272 // static |
273 ExtensionInstallPrompt* ExtensionInstallUI::CreateInstallPromptWithProfile( | 273 ExtensionInstallPrompt* ExtensionInstallUI::CreateInstallPromptWithProfile( |
274 Profile* profile) { | 274 Profile* profile) { |
275 Browser* browser = browser::FindLastActiveWithProfile(profile); | 275 Browser* browser = browser::FindLastActiveWithProfile(profile); |
276 return chrome::CreateExtensionInstallPromptWithBrowser(browser); | 276 return chrome::CreateExtensionInstallPromptWithBrowser(browser); |
277 } | 277 } |
OLD | NEW |