Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_message_bubble_bridge.h" | 5 #include "chrome/browser/ui/extensions/extension_message_bubble_bridge.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | |
| 9 #include "chrome/browser/extensions/extension_message_bubble_controller.h" | 10 #include "chrome/browser/extensions/extension_message_bubble_controller.h" |
| 11 #include "chrome/browser/profiles/profile.h" | |
| 12 #include "chrome/grit/generated_resources.h" | |
| 13 #include "components/grit/components_scaled_resources.h" | |
| 14 #include "extensions/browser/extension_registry.h" | |
| 15 #include "ui/base/l10n/l10n_util.h" | |
| 16 #include "ui/base/resource/resource_bundle.h" | |
| 10 | 17 |
| 11 ExtensionMessageBubbleBridge::ExtensionMessageBubbleBridge( | 18 ExtensionMessageBubbleBridge::ExtensionMessageBubbleBridge( |
| 12 std::unique_ptr<extensions::ExtensionMessageBubbleController> controller) | 19 std::unique_ptr<extensions::ExtensionMessageBubbleController> controller) |
| 13 : controller_(std::move(controller)) {} | 20 : controller_(std::move(controller)) {} |
| 14 | 21 |
| 15 ExtensionMessageBubbleBridge::~ExtensionMessageBubbleBridge() {} | 22 ExtensionMessageBubbleBridge::~ExtensionMessageBubbleBridge() {} |
| 16 | 23 |
| 17 bool ExtensionMessageBubbleBridge::ShouldShow() { | 24 bool ExtensionMessageBubbleBridge::ShouldShow() { |
| 18 return controller_->ShouldShow(); | 25 return controller_->ShouldShow(); |
| 19 } | 26 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 30 bool anchored_to_action) { | 37 bool anchored_to_action) { |
| 31 return controller_->delegate()->GetMessageBody( | 38 return controller_->delegate()->GetMessageBody( |
| 32 anchored_to_action, controller_->GetExtensionIdList().size()); | 39 anchored_to_action, controller_->GetExtensionIdList().size()); |
| 33 } | 40 } |
| 34 | 41 |
| 35 base::string16 ExtensionMessageBubbleBridge::GetItemListText() { | 42 base::string16 ExtensionMessageBubbleBridge::GetItemListText() { |
| 36 return controller_->GetExtensionListForDisplay(); | 43 return controller_->GetExtensionListForDisplay(); |
| 37 } | 44 } |
| 38 | 45 |
| 39 base::string16 ExtensionMessageBubbleBridge::GetActionButtonText() { | 46 base::string16 ExtensionMessageBubbleBridge::GetActionButtonText() { |
| 40 return controller_->delegate()->GetActionButtonLabel(); | 47 const extensions::ExtensionIdList& list = controller_->GetExtensionIdList(); |
|
catmullings
2016/09/08 15:42:30
Lines 47 - 59 are obviously duplicated code from t
Devlin
2016/09/12 22:51:43
Sounds reasonable to me, though note that you have
catmullings
2016/09/22 00:00:10
Done.
catmullings
2016/09/22 00:00:10
Mkay. Line 55 should be the only straggler, since
| |
| 48 const extensions::Extension* extension = | |
| 49 extensions::ExtensionRegistry::Get(controller_->profile()) | |
| 50 ->enabled_extensions() | |
| 51 .GetByID(list[0]); | |
| 52 | |
| 53 DCHECK(extension); | |
| 54 | |
| 55 std::unique_ptr<ExtraViewInfo> extra_view_info = | |
| 56 base::MakeUnique<ExtraViewInfo>(); | |
| 57 | |
| 58 if (controller_->delegate()->SupportsPolicyIndicator() && | |
| 59 extensions::Manifest::IsPolicyLocation(extension->location())) | |
| 60 return base::string16(); | |
|
catmullings
2016/09/08 15:42:30
Initial attempt to remove the "Restore Settings" b
| |
| 61 else | |
| 62 return controller_->delegate()->GetActionButtonLabel(); | |
| 41 } | 63 } |
| 42 | 64 |
| 43 base::string16 ExtensionMessageBubbleBridge::GetDismissButtonText() { | 65 base::string16 ExtensionMessageBubbleBridge::GetDismissButtonText() { |
| 44 return controller_->delegate()->GetDismissButtonLabel(); | 66 return controller_->delegate()->GetDismissButtonLabel(); |
| 45 } | 67 } |
| 46 | 68 |
| 47 base::string16 ExtensionMessageBubbleBridge::GetLearnMoreButtonText() { | 69 base::string16 ExtensionMessageBubbleBridge::GetLearnMoreButtonText() { |
| 48 return controller_->delegate()->GetLearnMoreLabel(); | 70 return controller_->delegate()->GetLearnMoreLabel(); |
| 49 } | 71 } |
| 50 | 72 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 67 break; | 89 break; |
| 68 } | 90 } |
| 69 case CLOSE_EXECUTE: | 91 case CLOSE_EXECUTE: |
| 70 controller_->OnBubbleAction(); | 92 controller_->OnBubbleAction(); |
| 71 break; | 93 break; |
| 72 case CLOSE_LEARN_MORE: | 94 case CLOSE_LEARN_MORE: |
| 73 controller_->OnLinkClicked(); | 95 controller_->OnLinkClicked(); |
| 74 break; | 96 break; |
| 75 } | 97 } |
| 76 } | 98 } |
| 99 | |
| 100 std::unique_ptr<ToolbarActionsBarBubbleDelegate::ExtraViewInfo> | |
| 101 ExtensionMessageBubbleBridge::GetExtraViewInfo() { | |
| 102 const extensions::ExtensionIdList& list = controller_->GetExtensionIdList(); | |
| 103 const extensions::Extension* extension = | |
| 104 extensions::ExtensionRegistry::Get(controller_->profile()) | |
| 105 ->enabled_extensions() | |
| 106 .GetByID(list[0]); | |
| 107 | |
| 108 DCHECK(extension); | |
| 109 | |
| 110 std::unique_ptr<ExtraViewInfo> extra_view_info = | |
| 111 base::MakeUnique<ExtraViewInfo>(); | |
| 112 | |
| 113 if (controller_->delegate()->SupportsPolicyIndicator() && | |
| 114 extensions::Manifest::IsPolicyLocation(extension->location())) { | |
| 115 DCHECK_EQ(1u, list.size()); | |
| 116 extra_view_info->resource_id = IDR_OMNIBOX_HTTPS_POLICY_WARNING; | |
| 117 extra_view_info->text = | |
| 118 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALLED_BY_ADMIN); | |
| 119 extra_view_info->is_text_linked = false; | |
| 120 } else { | |
| 121 extra_view_info->text = controller_->delegate()->GetLearnMoreLabel(); | |
| 122 extra_view_info->is_text_linked = true; | |
| 123 } | |
| 124 | |
| 125 return extra_view_info; | |
| 126 } | |
| OLD | NEW |