| OLD | NEW |
| 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/theme_preview_infobar_delegate.h" | 5 #include "chrome/browser/extensions/theme_preview_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
| 10 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
| 11 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 12 | 12 |
| 13 ThemePreviewInfobarDelegate::ThemePreviewInfobarDelegate( | 13 ThemePreviewInfobarDelegate::ThemePreviewInfobarDelegate( |
| 14 TabContents* tab_contents, const std::string& name) | 14 TabContents* tab_contents, const std::string& name) |
| 15 : ConfirmInfoBarDelegate(tab_contents), | 15 : ConfirmInfoBarDelegate(tab_contents), |
| 16 profile_(tab_contents->profile()), name_(name) { | 16 profile_(tab_contents->profile()), name_(name) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 bool ThemePreviewInfobarDelegate::EqualsDelegate(InfoBarDelegate* delegate) | |
| 20 const { | |
| 21 // If another infobar of this type is showing, this will prevent us adding | |
| 22 // a new one, we only care if they're the same type, as pressing undo always | |
| 23 // has the same result each time. This does mean that the text continues | |
| 24 // to refer to the old theme, but this is good enough for beta. | |
| 25 // http://crbug.com/17932 | |
| 26 if (delegate->AsThemePreviewInfobarDelegate()) | |
| 27 return true; | |
| 28 | |
| 29 return false; | |
| 30 } | |
| 31 | |
| 32 void ThemePreviewInfobarDelegate::InfoBarClosed() { | 19 void ThemePreviewInfobarDelegate::InfoBarClosed() { |
| 33 delete this; | 20 delete this; |
| 34 } | 21 } |
| 35 | 22 |
| 36 std::wstring ThemePreviewInfobarDelegate::GetMessageText() const { | 23 std::wstring ThemePreviewInfobarDelegate::GetMessageText() const { |
| 37 return l10n_util::GetStringF(IDS_THEME_PREVIEW_INFOBAR_LABEL, | 24 return l10n_util::GetStringF(IDS_THEME_PREVIEW_INFOBAR_LABEL, |
| 38 UTF8ToWide(name_)); | 25 UTF8ToWide(name_)); |
| 39 } | 26 } |
| 40 | 27 |
| 41 SkBitmap* ThemePreviewInfobarDelegate::GetIcon() const { | 28 SkBitmap* ThemePreviewInfobarDelegate::GetIcon() const { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 67 // Blech, this is a total hack. | 54 // Blech, this is a total hack. |
| 68 // | 55 // |
| 69 // a) We should be uninstalling via ExtensionsService, not | 56 // a) We should be uninstalling via ExtensionsService, not |
| 70 // Profile::ClearTheme(). | 57 // Profile::ClearTheme(). |
| 71 // b) We should be able to view the theme without installing it. This would | 58 // b) We should be able to view the theme without installing it. This would |
| 72 // help in edge cases like the user closing the window or tab before making | 59 // help in edge cases like the user closing the window or tab before making |
| 73 // a decision. | 60 // a decision. |
| 74 profile_->ClearTheme(); | 61 profile_->ClearTheme(); |
| 75 return true; | 62 return true; |
| 76 } | 63 } |
| OLD | NEW |