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

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: Fixed failing tests ToolbarActionsBarBubbleViewsTest.TestClickLearnMoreLink and TestBubbleLayoutAct… Created 4 years, 2 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
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/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
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();
48 const extensions::Extension* extension =
49 extensions::ExtensionRegistry::Get(controller_->profile())
50 ->enabled_extensions()
51 .GetByID(list[0]);
52
53 DCHECK(extension);
54
55 if (controller_->delegate()->SupportsPolicyIndicator() &&
56 extensions::Manifest::IsPolicyLocation(extension->location()))
Devlin 2016/09/26 20:13:09 this seems like it should be pulled into a helper
catmullings 2016/10/06 18:24:19 Done.
57 return base::string16();
58 else
Devlin 2016/09/26 20:13:09 no else after return
catmullings 2016/10/06 18:24:19 Done.
59 return controller_->delegate()->GetActionButtonLabel();
41 } 60 }
42 61
43 base::string16 ExtensionMessageBubbleBridge::GetDismissButtonText() { 62 base::string16 ExtensionMessageBubbleBridge::GetDismissButtonText() {
44 return controller_->delegate()->GetDismissButtonLabel(); 63 return controller_->delegate()->GetDismissButtonLabel();
45 } 64 }
46 65
47 base::string16 ExtensionMessageBubbleBridge::GetLearnMoreButtonText() { 66 base::string16 ExtensionMessageBubbleBridge::GetLearnMoreButtonText() {
48 return controller_->delegate()->GetLearnMoreLabel(); 67 return controller_->delegate()->GetLearnMoreLabel();
49 } 68 }
50 69
(...skipping 16 matching lines...) Expand all
67 break; 86 break;
68 } 87 }
69 case CLOSE_EXECUTE: 88 case CLOSE_EXECUTE:
70 controller_->OnBubbleAction(); 89 controller_->OnBubbleAction();
71 break; 90 break;
72 case CLOSE_LEARN_MORE: 91 case CLOSE_LEARN_MORE:
73 controller_->OnLinkClicked(); 92 controller_->OnLinkClicked();
74 break; 93 break;
75 } 94 }
76 } 95 }
96
97 std::unique_ptr<ToolbarActionsBarBubbleDelegate::ExtraViewInfo>
98 ExtensionMessageBubbleBridge::GetExtraViewInfo() {
99 const extensions::ExtensionIdList& list = controller_->GetExtensionIdList();
100 const extensions::Extension* extension =
101 extensions::ExtensionRegistry::Get(controller_->profile())
102 ->enabled_extensions()
103 .GetByID(list[0]);
104
105 DCHECK(extension);
106
107 std::unique_ptr<ExtraViewInfo> extra_view_info =
108 base::MakeUnique<ExtraViewInfo>();
109
110 if (controller_->delegate()->SupportsPolicyIndicator() &&
111 extensions::Manifest::IsPolicyLocation(extension->location())) {
112 DCHECK_EQ(1u, list.size());
113 extra_view_info->resource_id = IDR_OMNIBOX_HTTPS_POLICY_WARNING;
114 extra_view_info->text =
115 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALLED_BY_ADMIN);
116 extra_view_info->is_text_linked = false;
117 } else {
118 extra_view_info->text = controller_->delegate()->GetLearnMoreLabel();
119 extra_view_info->is_text_linked = true;
120 }
121
122 return extra_view_info;
123 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698