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

Side by Side Diff: chrome/browser/ui/extensions/extension_message_bubble_bridge.cc

Issue 2206693002: Improve settings override bubble to indicate policy installed extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 1 month 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
OLDNEW
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/gfx/vector_icons_public.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 }
20 27
21 bool ExtensionMessageBubbleBridge::ShouldCloseOnDeactivate() { 28 bool ExtensionMessageBubbleBridge::ShouldCloseOnDeactivate() {
22 return controller_->CloseOnDeactivate(); 29 return controller_->CloseOnDeactivate();
23 } 30 }
24 31
32 bool ExtensionMessageBubbleBridge::IsPolicyIndicationNeeded(
33 const extensions::Extension* extension) {
34 return controller_->delegate()->SupportsPolicyIndicator() &&
35 extensions::Manifest::IsPolicyLocation(extension->location());
36 }
37
25 base::string16 ExtensionMessageBubbleBridge::GetHeadingText() { 38 base::string16 ExtensionMessageBubbleBridge::GetHeadingText() {
26 return controller_->delegate()->GetTitle(); 39 return controller_->delegate()->GetTitle();
27 } 40 }
28 41
29 base::string16 ExtensionMessageBubbleBridge::GetBodyText( 42 base::string16 ExtensionMessageBubbleBridge::GetBodyText(
30 bool anchored_to_action) { 43 bool anchored_to_action) {
31 return controller_->delegate()->GetMessageBody( 44 return controller_->delegate()->GetMessageBody(
32 anchored_to_action, controller_->GetExtensionIdList().size()); 45 anchored_to_action, controller_->GetExtensionIdList().size());
33 } 46 }
34 47
35 base::string16 ExtensionMessageBubbleBridge::GetItemListText() { 48 base::string16 ExtensionMessageBubbleBridge::GetItemListText() {
36 return controller_->GetExtensionListForDisplay(); 49 return controller_->GetExtensionListForDisplay();
37 } 50 }
38 51
39 base::string16 ExtensionMessageBubbleBridge::GetActionButtonText() { 52 base::string16 ExtensionMessageBubbleBridge::GetActionButtonText() {
53 const extensions::ExtensionIdList& list = controller_->GetExtensionIdList();
54 DCHECK(!list.empty());
55 const extensions::Extension* extension =
56 extensions::ExtensionRegistry::Get(controller_->profile())
57 ->enabled_extensions()
58 .GetByID(list[0]);
59
60 DCHECK(extension);
61 // An empty string is returned so that we don't display the button prompting
62 // to remove policy-installed extensions.
63 if (IsPolicyIndicationNeeded(extension))
64 return base::string16();
40 return controller_->delegate()->GetActionButtonLabel(); 65 return controller_->delegate()->GetActionButtonLabel();
41 } 66 }
42 67
43 base::string16 ExtensionMessageBubbleBridge::GetDismissButtonText() { 68 base::string16 ExtensionMessageBubbleBridge::GetDismissButtonText() {
44 return controller_->delegate()->GetDismissButtonLabel(); 69 return controller_->delegate()->GetDismissButtonLabel();
45 } 70 }
46 71
47 base::string16 ExtensionMessageBubbleBridge::GetLearnMoreButtonText() { 72 base::string16 ExtensionMessageBubbleBridge::GetLearnMoreButtonText() {
48 return controller_->delegate()->GetLearnMoreLabel(); 73 return controller_->delegate()->GetLearnMoreLabel();
49 } 74 }
(...skipping 17 matching lines...) Expand all
67 break; 92 break;
68 } 93 }
69 case CLOSE_EXECUTE: 94 case CLOSE_EXECUTE:
70 controller_->OnBubbleAction(); 95 controller_->OnBubbleAction();
71 break; 96 break;
72 case CLOSE_LEARN_MORE: 97 case CLOSE_LEARN_MORE:
73 controller_->OnLinkClicked(); 98 controller_->OnLinkClicked();
74 break; 99 break;
75 } 100 }
76 } 101 }
102
103 std::unique_ptr<ToolbarActionsBarBubbleDelegate::ExtraViewInfo>
104 ExtensionMessageBubbleBridge::GetExtraViewInfo() {
105 const extensions::ExtensionIdList& list = controller_->GetExtensionIdList();
106 const extensions::Extension* extension =
107 extensions::ExtensionRegistry::Get(controller_->profile())
108 ->enabled_extensions()
109 .GetByID(list[0]);
110
111 DCHECK(extension);
112
113 std::unique_ptr<ExtraViewInfo> extra_view_info =
114 base::MakeUnique<ExtraViewInfo>();
115
116 if (IsPolicyIndicationNeeded(extension)) {
117 DCHECK_EQ(1u, list.size());
118 extra_view_info->resource_id = gfx::VectorIconId::BUSINESS;
119 extra_view_info->text =
120 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALLED_BY_ADMIN);
121 extra_view_info->is_text_linked = false;
122 } else {
123 extra_view_info->text = controller_->delegate()->GetLearnMoreLabel();
124 extra_view_info->is_text_linked = true;
125 }
126
127 return extra_view_info;
128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698