| 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/extensions/extension_action_view_controller.h" | 5 #include "chrome/browser/ui/extensions/extension_action_view_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 void ExtensionActionViewController::OnContextMenuClosed() { | 178 void ExtensionActionViewController::OnContextMenuClosed() { |
| 179 if (toolbar_actions_bar_ && | 179 if (toolbar_actions_bar_ && |
| 180 toolbar_actions_bar_->popped_out_action() == this && | 180 toolbar_actions_bar_->popped_out_action() == this && |
| 181 !is_showing_popup()) { | 181 !is_showing_popup()) { |
| 182 toolbar_actions_bar_->UndoPopOut(); | 182 toolbar_actions_bar_->UndoPopOut(); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 bool ExtensionActionViewController::ExecuteAction(bool by_user) { | 186 bool ExtensionActionViewController::ExecuteAction(bool by_user) { |
| 187 if (!ExtensionIsValid()) |
| 188 return false; |
| 189 |
| 190 if (!IsEnabled(view_delegate_->GetCurrentWebContents())) { |
| 191 if (DisabledClickOpensMenu()) |
| 192 GetPreferredPopupViewController()->platform_delegate_->ShowContextMenu(); |
| 193 return false; |
| 194 } |
| 195 |
| 187 return ExecuteAction(SHOW_POPUP, by_user); | 196 return ExecuteAction(SHOW_POPUP, by_user); |
| 188 } | 197 } |
| 189 | 198 |
| 190 void ExtensionActionViewController::UpdateState() { | 199 void ExtensionActionViewController::UpdateState() { |
| 191 if (!ExtensionIsValid()) | 200 if (!ExtensionIsValid()) |
| 192 return; | 201 return; |
| 193 | 202 |
| 194 view_delegate_->UpdateState(); | 203 view_delegate_->UpdateState(); |
| 195 } | 204 } |
| 196 | 205 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 extensions::ExtensionActionAPI::Get(browser_->profile()); | 404 extensions::ExtensionActionAPI::Get(browser_->profile()); |
| 396 bool has_blocked_actions = api->HasBeenBlocked(extension(), web_contents); | 405 bool has_blocked_actions = api->HasBeenBlocked(extension(), web_contents); |
| 397 image_source->set_paint_blocked_actions_decoration(has_blocked_actions); | 406 image_source->set_paint_blocked_actions_decoration(has_blocked_actions); |
| 398 image_source->set_paint_page_action_decoration( | 407 image_source->set_paint_page_action_decoration( |
| 399 !has_blocked_actions && is_overflow && | 408 !has_blocked_actions && is_overflow && |
| 400 api->PageActionWantsToRun(extension(), web_contents)); | 409 api->PageActionWantsToRun(extension(), web_contents)); |
| 401 } | 410 } |
| 402 | 411 |
| 403 return image_source; | 412 return image_source; |
| 404 } | 413 } |
| OLD | NEW |