Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/views/extensions/extension_action_view_controller.h" | 5 #include "chrome/browser/ui/views/extensions/extension_action_view_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/extensions/api/commands/command_service.h" | 8 #include "chrome/browser/extensions/api/commands/command_service.h" |
| 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 10 #include "chrome/browser/extensions/extension_action.h" | 10 #include "chrome/browser/extensions/extension_action.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 // If another extension action wants to show its context menu, allow it to. | 237 // If another extension action wants to show its context menu, allow it to. |
| 238 if (!followup_context_menu_task_.is_null()) { | 238 if (!followup_context_menu_task_.is_null()) { |
| 239 base::Closure task = followup_context_menu_task_; | 239 base::Closure task = followup_context_menu_task_; |
| 240 followup_context_menu_task_ = base::Closure(); | 240 followup_context_menu_task_ = base::Closure(); |
| 241 task.Run(); | 241 task.Run(); |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 | 244 |
| 245 bool ExtensionActionViewController::ShowPopupWithUrl( | 245 bool ExtensionActionViewController::ShowPopupWithUrl( |
| 246 ExtensionPopup::ShowAction show_action, const GURL& popup_url) { | 246 ExtensionPopup::ShowAction show_action, const GURL& popup_url) { |
| 247 ExtensionActionViewController* preferred_controller = | |
| 248 delegate_->GetPreferredPopupViewController(); | |
| 249 if (preferred_controller != this) | |
|
Peter Kasting
2014/09/11 20:23:12
Can we just make callers call this method on the c
Devlin
2014/09/11 20:53:42
I think that's actually more complicated overall.
Peter Kasting
2014/09/11 20:57:37
I'm only suggesting hoisting this to ExecuteAction
Devlin
2014/09/11 21:04:07
Ah, misunderstood. Yes, that's fine - done. (Onl
| |
| 250 return preferred_controller->ShowPopupWithUrl(show_action, popup_url); | |
| 251 | |
| 247 // If we're already showing the popup for this browser action, just hide it | 252 // If we're already showing the popup for this browser action, just hide it |
| 248 // and return. | 253 // and return. |
| 249 bool already_showing = popup_ != NULL; | 254 bool already_showing = popup_ != NULL; |
| 250 | 255 |
| 251 // Always hide the current popup, even if it's not the same. | 256 // Always hide the current popup, even if it's not the same. |
| 252 // Only one popup should be visible at a time. | 257 // Only one popup should be visible at a time. |
| 253 delegate_->HideActivePopup(); | 258 delegate_->HideActivePopup(); |
| 254 | 259 |
| 255 // Similarly, don't allow a context menu and a popup to be showing | 260 // Similarly, don't allow a context menu and a popup to be showing |
| 256 // simultaneously. | 261 // simultaneously. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 } | 310 } |
| 306 | 311 |
| 307 void ExtensionActionViewController::CleanupPopup(bool close_widget) { | 312 void ExtensionActionViewController::CleanupPopup(bool close_widget) { |
| 308 DCHECK(popup_); | 313 DCHECK(popup_); |
| 309 delegate_->CleanupPopup(); | 314 delegate_->CleanupPopup(); |
| 310 popup_->GetWidget()->RemoveObserver(this); | 315 popup_->GetWidget()->RemoveObserver(this); |
| 311 if (close_widget) | 316 if (close_widget) |
| 312 popup_->GetWidget()->Close(); | 317 popup_->GetWidget()->Close(); |
| 313 popup_ = NULL; | 318 popup_ = NULL; |
| 314 } | 319 } |
| OLD | NEW |