| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_message_bubble_controller.h" | 5 #include "chrome/browser/extensions/extension_message_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_message_bubble.h" | 10 #include "chrome/browser/extensions/extension_message_bubble.h" |
| 11 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
| 14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 15 #include "content/public/browser/user_metrics.h" | 16 #include "content/public/browser/user_metrics.h" |
| 16 #include "extensions/browser/extension_prefs.h" | 17 #include "extensions/browser/extension_prefs.h" |
| 17 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
| 18 #include "grit/components_strings.h" | 19 #include "grit/components_strings.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 20 | 21 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 116 } |
| 116 return return_value; | 117 return return_value; |
| 117 } | 118 } |
| 118 | 119 |
| 119 const ExtensionIdList& ExtensionMessageBubbleController::GetExtensionIdList() { | 120 const ExtensionIdList& ExtensionMessageBubbleController::GetExtensionIdList() { |
| 120 return *GetOrCreateExtensionList(); | 121 return *GetOrCreateExtensionList(); |
| 121 } | 122 } |
| 122 | 123 |
| 123 bool ExtensionMessageBubbleController::CloseOnDeactivate() { return false; } | 124 bool ExtensionMessageBubbleController::CloseOnDeactivate() { return false; } |
| 124 | 125 |
| 126 void ExtensionMessageBubbleController::HighlightExtensionsIfNecessary() { |
| 127 if (delegate_->ShouldHighlightExtensions()) { |
| 128 const ExtensionIdList& extension_ids = GetExtensionIdList(); |
| 129 DCHECK(!extension_ids.empty()); |
| 130 ExtensionToolbarModel::Get(profile_)->HighlightExtensions(extension_ids); |
| 131 } |
| 132 } |
| 133 |
| 125 void ExtensionMessageBubbleController::Show(ExtensionMessageBubble* bubble) { | 134 void ExtensionMessageBubbleController::Show(ExtensionMessageBubble* bubble) { |
| 126 // Wire up all the callbacks, to get notified what actions the user took. | |
| 127 base::Closure dismiss_button_callback = | |
| 128 base::Bind(&ExtensionMessageBubbleController::OnBubbleDismiss, | |
| 129 base::Unretained(this)); | |
| 130 base::Closure action_button_callback = | |
| 131 base::Bind(&ExtensionMessageBubbleController::OnBubbleAction, | |
| 132 base::Unretained(this)); | |
| 133 base::Closure link_callback = | |
| 134 base::Bind(&ExtensionMessageBubbleController::OnLinkClicked, | |
| 135 base::Unretained(this)); | |
| 136 bubble->OnActionButtonClicked(action_button_callback); | |
| 137 bubble->OnDismissButtonClicked(dismiss_button_callback); | |
| 138 bubble->OnLinkClicked(link_callback); | |
| 139 | |
| 140 bubble->Show(); | 135 bubble->Show(); |
| 141 } | 136 } |
| 142 | 137 |
| 143 void ExtensionMessageBubbleController::OnBubbleAction() { | 138 void ExtensionMessageBubbleController::OnBubbleAction() { |
| 144 DCHECK_EQ(ACTION_BOUNDARY, user_action_); | 139 DCHECK_EQ(ACTION_BOUNDARY, user_action_); |
| 145 user_action_ = ACTION_EXECUTE; | 140 user_action_ = ACTION_EXECUTE; |
| 146 | 141 |
| 147 delegate_->LogAction(ACTION_EXECUTE); | 142 delegate_->LogAction(ACTION_EXECUTE); |
| 148 delegate_->PerformAction(*GetOrCreateExtensionList()); | 143 delegate_->PerformAction(*GetOrCreateExtensionList()); |
| 149 AcknowledgeExtensions(); | 144 AcknowledgeExtensions(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 200 } |
| 206 | 201 |
| 207 delegate_->LogExtensionCount(extension_list_.size()); | 202 delegate_->LogExtensionCount(extension_list_.size()); |
| 208 initialized_ = true; | 203 initialized_ = true; |
| 209 } | 204 } |
| 210 | 205 |
| 211 return &extension_list_; | 206 return &extension_list_; |
| 212 } | 207 } |
| 213 | 208 |
| 214 } // namespace extensions | 209 } // namespace extensions |
| OLD | NEW |