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