Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: chrome/browser/extensions/extension_install_ui.cc

Issue 165373: Merge 23055 - Make the theme install infobar have an 'undo' button instead... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/chrome/browser/extensions/extension_install_ui.cc:r23055
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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.h" 5 #include "chrome/browser/extensions/extension_install_ui.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 19 matching lines...) Expand all
30 30
31 void ExtensionInstallUI::ConfirmInstall(CrxInstaller* installer, 31 void ExtensionInstallUI::ConfirmInstall(CrxInstaller* installer,
32 Extension* extension, 32 Extension* extension,
33 SkBitmap* install_icon) { 33 SkBitmap* install_icon) {
34 DCHECK(ui_loop_ == MessageLoop::current()); 34 DCHECK(ui_loop_ == MessageLoop::current());
35 35
36 // We special-case themes to not show any confirm UI. Instead they are 36 // We special-case themes to not show any confirm UI. Instead they are
37 // immediately installed, and then we show an infobar (see OnInstallSuccess) 37 // immediately installed, and then we show an infobar (see OnInstallSuccess)
38 // to allow the user to revert if they don't like it. 38 // to allow the user to revert if they don't like it.
39 if (extension->IsTheme()) { 39 if (extension->IsTheme()) {
40 // Remember the current theme in case the user pressed undo.
41 Extension* previous_theme = profile_->GetTheme();
42 if (previous_theme)
43 previous_theme_id_ = previous_theme->id();
44
40 installer->ContinueInstall(); 45 installer->ContinueInstall();
41 return; 46 return;
42 } 47 }
43 48
44 #if defined(OS_WIN) 49 #if defined(OS_WIN)
45 ShowExtensionInstallPrompt(profile_, installer, extension, install_icon); 50 ShowExtensionInstallPrompt(profile_, installer, extension, install_icon);
46 51
47 #elif defined(OS_MACOSX) 52 #elif defined(OS_MACOSX)
48 // TODO(port): Implement nicer UI. 53 // TODO(port): Implement nicer UI.
49 // Using CoreFoundation to do this dialog is unimaginably lame but will do 54 // Using CoreFoundation to do this dialog is unimaginably lame but will do
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 #else 96 #else
92 LOG(ERROR) << "Extension install failed: " << error.c_str(); 97 LOG(ERROR) << "Extension install failed: " << error.c_str();
93 NOTREACHED(); 98 NOTREACHED();
94 #endif 99 #endif
95 } 100 }
96 101
97 void ExtensionInstallUI::OnOverinstallAttempted(Extension* extension) { 102 void ExtensionInstallUI::OnOverinstallAttempted(Extension* extension) {
98 ShowThemeInfoBar(extension); 103 ShowThemeInfoBar(extension);
99 } 104 }
100 105
101 void ExtensionInstallUI::ShowThemeInfoBar(Extension* extension) { 106 void ExtensionInstallUI::ShowThemeInfoBar(Extension* new_theme) {
102 if (!extension->IsTheme()) 107 if (!new_theme->IsTheme())
103 return; 108 return;
104 109
105 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); 110 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
106 if (!browser) 111 if (!browser)
107 return; 112 return;
108 113
109 TabContents* tab_contents = browser->GetSelectedTabContents(); 114 TabContents* tab_contents = browser->GetSelectedTabContents();
110 if (!tab_contents) 115 if (!tab_contents)
111 return; 116 return;
112 117
113 // First find any previous theme preview infobars. 118 // First find any previous theme preview infobars.
114 InfoBarDelegate* old_delegate = NULL; 119 InfoBarDelegate* old_delegate = NULL;
115 for (int i = 0; i < tab_contents->infobar_delegate_count(); ++i) { 120 for (int i = 0; i < tab_contents->infobar_delegate_count(); ++i) {
116 InfoBarDelegate* delegate = tab_contents->GetInfoBarDelegateAt(i); 121 InfoBarDelegate* delegate = tab_contents->GetInfoBarDelegateAt(i);
117 if (delegate->AsThemePreviewInfobarDelegate()) { 122 if (delegate->AsThemePreviewInfobarDelegate()) {
118 old_delegate = delegate; 123 old_delegate = delegate;
119 break; 124 break;
120 } 125 }
121 } 126 }
122 127
123 // Then either replace that old one or add a new one. 128 // Then either replace that old one or add a new one.
124 InfoBarDelegate* new_delegate = new ThemePreviewInfobarDelegate(tab_contents, 129 InfoBarDelegate* new_delegate = new ThemePreviewInfobarDelegate(tab_contents,
125 extension->name()); 130 new_theme->name(), previous_theme_id_);
126 131
127 if (old_delegate) 132 if (old_delegate)
128 tab_contents->ReplaceInfoBar(old_delegate, new_delegate); 133 tab_contents->ReplaceInfoBar(old_delegate, new_delegate);
129 else 134 else
130 tab_contents->AddInfoBar(new_delegate); 135 tab_contents->AddInfoBar(new_delegate);
131 } 136 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_ui.h ('k') | chrome/browser/extensions/theme_preview_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698