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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_actions_bar.cc

Issue 1246643004: [Extensions UI] Highlight toolbar extensions when the redesign bubble is active (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 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/toolbar/toolbar_actions_bar.h" 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/profiler/scoped_tracker.h" 9 #include "base/profiler/scoped_tracker.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 365
366 for (size_t i = 0; i < toolbar_actions_.size(); ++i) 366 for (size_t i = 0; i < toolbar_actions_.size(); ++i)
367 delegate_->AddViewForAction(toolbar_actions_[i], i); 367 delegate_->AddViewForAction(toolbar_actions_[i], i);
368 } 368 }
369 369
370 // Once the actions are created, we should animate the changes. 370 // Once the actions are created, we should animate the changes.
371 suppress_animation_ = false; 371 suppress_animation_ = false;
372 372
373 // CreateActions() can be called multiple times, so we need to make sure we 373 // CreateActions() can be called multiple times, so we need to make sure we
374 // haven't already shown the bubble. 374 // haven't already shown the bubble.
375 if (!checked_extension_bubble_) { 375 // Extension bubbles can also highlight a subset of actions, so don't show the
376 // bubble if the toolbar is already highlighting a different set.
377 if (!checked_extension_bubble_ && !is_highlighting()) {
376 checked_extension_bubble_ = true; 378 checked_extension_bubble_ = true;
377 // CreateActions() can be called as part of the browser window set up, which 379 // CreateActions() can be called as part of the browser window set up, which
378 // we need to let finish before showing the actions. 380 // we need to let finish before showing the actions.
379 scoped_ptr<extensions::ExtensionMessageBubbleController> controller = 381 scoped_ptr<extensions::ExtensionMessageBubbleController> controller =
380 ExtensionMessageBubbleFactory(browser_->profile()).GetController(); 382 ExtensionMessageBubbleFactory(browser_->profile()).GetController();
381 if (controller) { 383 if (controller) {
382 base::ThreadTaskRunnerHandle::Get()->PostTask( 384 base::ThreadTaskRunnerHandle::Get()->PostTask(
383 FROM_HERE, base::Bind(&ToolbarActionsBar::MaybeShowExtensionBubble, 385 FROM_HERE, base::Bind(&ToolbarActionsBar::MaybeShowExtensionBubble,
384 weak_ptr_factory_.GetWeakPtr(), 386 weak_ptr_factory_.GetWeakPtr(),
385 base::Passed(controller.Pass()))); 387 base::Passed(controller.Pass())));
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 // We may already be at the right size (this can happen frequently with 659 // We may already be at the right size (this can happen frequently with
658 // overflow, where we have a fixed width, and in tests, where we skip 660 // overflow, where we have a fixed width, and in tests, where we skip
659 // animations). If this is the case, we still need to Redraw(), because the 661 // animations). If this is the case, we still need to Redraw(), because the
660 // icons within the toolbar may have changed (e.g. if we removed one 662 // icons within the toolbar may have changed (e.g. if we removed one
661 // action and added a different one in quick succession). 663 // action and added a different one in quick succession).
662 delegate_->Redraw(false); 664 delegate_->Redraw(false);
663 } 665 }
664 } 666 }
665 667
666 void ToolbarActionsBar::OnToolbarHighlightModeChanged(bool is_highlighting) { 668 void ToolbarActionsBar::OnToolbarHighlightModeChanged(bool is_highlighting) {
669 if (!model_->extensions_initialized())
670 return;
667 // It's a bit of a pain that we delete and recreate everything here, but given 671 // It's a bit of a pain that we delete and recreate everything here, but given
668 // everything else going on (the lack of highlight, [n] more extensions 672 // everything else going on (the lack of highlight, [n] more extensions
669 // appearing, etc), it's not worth the extra complexity to create and insert 673 // appearing, etc), it's not worth the extra complexity to create and insert
670 // only the new actions. 674 // only the new actions.
671 DeleteActions(); 675 DeleteActions();
672 CreateActions(); 676 CreateActions();
673 // Resize the delegate. We suppress the chevron so that we don't risk showing 677 // Resize the delegate. We suppress the chevron so that we don't risk showing
674 // it only for the duration of the animation. 678 // it only for the duration of the animation.
675 ResizeDelegate(gfx::Tween::LINEAR, true); 679 ResizeDelegate(gfx::Tween::LINEAR, true);
676 } 680 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 for (ToolbarActionViewController* action : toolbar_actions_) { 742 for (ToolbarActionViewController* action : toolbar_actions_) {
739 if (action->GetId() == id) 743 if (action->GetId() == id)
740 return action; 744 return action;
741 } 745 }
742 return nullptr; 746 return nullptr;
743 } 747 }
744 748
745 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { 749 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() {
746 return browser_->tab_strip_model()->GetActiveWebContents(); 750 return browser_->tab_strip_model()->GetActiveWebContents();
747 } 751 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_actions_bar.h ('k') | chrome/browser/ui/views/toolbar/browser_actions_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698