| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/api/commands/command_service.h" | 9 #include "chrome/browser/extensions/api/commands/command_service.h" |
| 10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 343 |
| 344 sidebar_host_.reset(extensions::ExtensionViewHostFactory::CreateSidebarHost( | 344 sidebar_host_.reset(extensions::ExtensionViewHostFactory::CreateSidebarHost( |
| 345 sidebar_url, browser_)); | 345 sidebar_url, browser_)); |
| 346 | 346 |
| 347 sidebar_host_->CreateRenderViewSoon(); | 347 sidebar_host_->CreateRenderViewSoon(); |
| 348 sidebar_host_->host_contents()->SetInitialFocus(); | 348 sidebar_host_->host_contents()->SetInitialFocus(); |
| 349 | 349 |
| 350 DCHECK(toolbar_actions_bar_); | 350 DCHECK(toolbar_actions_bar_); |
| 351 toolbar_actions_bar_->SetSidebarOwner(this); | 351 toolbar_actions_bar_->SetSidebarOwner(this); |
| 352 | 352 |
| 353 platform_delegate_->ShowSidebar(sidebar_host_->host_contents()); |
| 354 |
| 353 PressButtonWithSlideOutIfEnabled( | 355 PressButtonWithSlideOutIfEnabled( |
| 354 base::Bind(&ExtensionActionViewController::PressButton, | 356 base::Bind(&ExtensionActionViewController::PressButton, |
| 355 weak_factory_.GetWeakPtr(), true)); | 357 weak_factory_.GetWeakPtr(), true)); |
| 356 return true; | 358 return true; |
| 357 } | 359 } |
| 358 | 360 |
| 359 void ExtensionActionViewController::ShowPopup( | 361 void ExtensionActionViewController::ShowPopup( |
| 360 scoped_ptr<extensions::ExtensionViewHost> popup_host, | 362 scoped_ptr<extensions::ExtensionViewHost> popup_host, |
| 361 bool grant_tab_permissions, | 363 bool grant_tab_permissions, |
| 362 PopupShowAction show_action) { | 364 PopupShowAction show_action) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 383 void ExtensionActionViewController::HideActiveSidebar() { | 385 void ExtensionActionViewController::HideActiveSidebar() { |
| 384 DCHECK(toolbar_actions_bar_); | 386 DCHECK(toolbar_actions_bar_); |
| 385 DCHECK_EQ(ActionInfo::TYPE_BROWSER, extension_action_->action_type()); | 387 DCHECK_EQ(ActionInfo::TYPE_BROWSER, extension_action_->action_type()); |
| 386 toolbar_actions_bar_->HideActiveSidebar(); | 388 toolbar_actions_bar_->HideActiveSidebar(); |
| 387 } | 389 } |
| 388 | 390 |
| 389 void ExtensionActionViewController::HideSidebar() { | 391 void ExtensionActionViewController::HideSidebar() { |
| 390 if (!sidebar_host_) | 392 if (!sidebar_host_) |
| 391 return; | 393 return; |
| 392 | 394 |
| 395 platform_delegate_->HideSidebar(); |
| 396 |
| 393 sidebar_host_.reset(); | 397 sidebar_host_.reset(); |
| 394 if (toolbar_actions_bar_) | 398 if (toolbar_actions_bar_) |
| 395 toolbar_actions_bar_->SetSidebarOwner(nullptr); | 399 toolbar_actions_bar_->SetSidebarOwner(nullptr); |
| 396 | 400 |
| 397 RaiseButton(); | 401 RaiseButton(); |
| 398 } | 402 } |
| 399 | 403 |
| 400 void ExtensionActionViewController::RaiseButton() { | 404 void ExtensionActionViewController::RaiseButton() { |
| 401 // Reset button state | 405 // Reset button state |
| 402 if (toolbar_actions_bar_) { | 406 if (toolbar_actions_bar_) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 // overflowed, we add a decoration so that the user can see which overflowed | 463 // overflowed, we add a decoration so that the user can see which overflowed |
| 460 // action wants to run (since they wouldn't be able to see the change from | 464 // action wants to run (since they wouldn't be able to see the change from |
| 461 // grayscale to color). | 465 // grayscale to color). |
| 462 bool is_overflow = | 466 bool is_overflow = |
| 463 toolbar_actions_bar_ && toolbar_actions_bar_->in_overflow_mode(); | 467 toolbar_actions_bar_ && toolbar_actions_bar_->in_overflow_mode(); |
| 464 image_source->set_paint_decoration(WantsToRun(web_contents) && is_overflow); | 468 image_source->set_paint_decoration(WantsToRun(web_contents) && is_overflow); |
| 465 } | 469 } |
| 466 | 470 |
| 467 return image_source.Pass(); | 471 return image_source.Pass(); |
| 468 } | 472 } |
| OLD | NEW |