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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_installed_bubble_view.cc

Issue 2374253002: Fix bookmark bubble/star view highlighting for Harmony. (Closed)
Patch Set: fix tests, move bubble creation to toolbar Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/user_metrics_action.h" 10 #include "base/metrics/user_metrics_action.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 ExtensionInstalledBubbleView::~ExtensionInstalledBubbleView() {} 117 ExtensionInstalledBubbleView::~ExtensionInstalledBubbleView() {}
118 118
119 void ExtensionInstalledBubbleView::UpdateAnchorView() { 119 void ExtensionInstalledBubbleView::UpdateAnchorView() {
120 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser()); 120 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
121 121
122 views::View* reference_view = nullptr; 122 views::View* reference_view = nullptr;
123 switch (controller_->anchor_position()) { 123 switch (controller_->anchor_position()) {
124 case ExtensionInstalledBubble::ANCHOR_BROWSER_ACTION: { 124 case ExtensionInstalledBubble::ANCHOR_BROWSER_ACTION: {
125 BrowserActionsContainer* container = 125 BrowserActionsContainer* container =
126 browser_view->GetToolbarView()->browser_actions(); 126 browser_view->toolbar()->browser_actions();
127 // Hitting this DCHECK means |ShouldShow| failed. 127 // Hitting this DCHECK means |ShouldShow| failed.
128 DCHECK(!container->animating()); 128 DCHECK(!container->animating());
129 129
130 reference_view = container->GetViewForId(controller_->extension()->id()); 130 reference_view = container->GetViewForId(controller_->extension()->id());
131 break; 131 break;
132 } 132 }
133 case ExtensionInstalledBubble::ANCHOR_PAGE_ACTION: { 133 case ExtensionInstalledBubble::ANCHOR_PAGE_ACTION: {
134 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); 134 LocationBarView* location_bar_view = browser_view->GetLocationBarView();
135 ExtensionAction* page_action = 135 ExtensionAction* page_action =
136 extensions::ExtensionActionManager::Get(browser()->profile()) 136 extensions::ExtensionActionManager::Get(browser()->profile())
137 ->GetPageAction(*controller_->extension()); 137 ->GetPageAction(*controller_->extension());
138 location_bar_view->SetPreviewEnabledPageAction(page_action, 138 location_bar_view->SetPreviewEnabledPageAction(page_action,
139 true); // preview_enabled 139 true); // preview_enabled
140 reference_view = location_bar_view->GetPageActionView(page_action); 140 reference_view = location_bar_view->GetPageActionView(page_action);
141 DCHECK(reference_view); 141 DCHECK(reference_view);
142 break; 142 break;
143 } 143 }
144 case ExtensionInstalledBubble::ANCHOR_OMNIBOX: { 144 case ExtensionInstalledBubble::ANCHOR_OMNIBOX: {
145 reference_view = browser_view->GetLocationBarView()->location_icon_view(); 145 reference_view = browser_view->GetLocationBarView()->location_icon_view();
146 break; 146 break;
147 } 147 }
148 case ExtensionInstalledBubble::ANCHOR_APP_MENU: 148 case ExtensionInstalledBubble::ANCHOR_APP_MENU:
149 // Will be caught below. 149 // Will be caught below.
150 break; 150 break;
151 } 151 }
152 152
153 // Default case. 153 // Default case.
154 if (!reference_view || !reference_view->visible()) 154 if (!reference_view || !reference_view->visible())
155 reference_view = browser_view->GetToolbarView()->app_menu_button(); 155 reference_view = browser_view->toolbar()->app_menu_button();
156 SetAnchorView(reference_view); 156 SetAnchorView(reference_view);
157 } 157 }
158 158
159 void ExtensionInstalledBubbleView::CloseBubble() { 159 void ExtensionInstalledBubbleView::CloseBubble() {
160 if (controller_ && controller_->anchor_position() == 160 if (controller_ && controller_->anchor_position() ==
161 ExtensionInstalledBubble::ANCHOR_PAGE_ACTION) { 161 ExtensionInstalledBubble::ANCHOR_PAGE_ACTION) {
162 BrowserView* browser_view = 162 BrowserView* browser_view =
163 BrowserView::GetBrowserViewForBrowser(browser()); 163 BrowserView::GetBrowserViewForBrowser(browser());
164 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( 164 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction(
165 extensions::ExtensionActionManager::Get(browser()->profile()) 165 extensions::ExtensionActionManager::Get(browser()->profile())
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 bubble_view_ = nullptr; 342 bubble_view_ = nullptr;
343 } 343 }
344 344
345 } // namespace 345 } // namespace
346 346
347 // Views specific implementation. 347 // Views specific implementation.
348 bool ExtensionInstalledBubble::ShouldShow() { 348 bool ExtensionInstalledBubble::ShouldShow() {
349 if (anchor_position() == ANCHOR_BROWSER_ACTION) { 349 if (anchor_position() == ANCHOR_BROWSER_ACTION) {
350 BrowserActionsContainer* container = 350 BrowserActionsContainer* container =
351 BrowserView::GetBrowserViewForBrowser(browser()) 351 BrowserView::GetBrowserViewForBrowser(browser())
352 ->GetToolbarView() 352 ->toolbar()
353 ->browser_actions(); 353 ->browser_actions();
354 return !container->animating(); 354 return !container->animating();
355 } 355 }
356 return true; 356 return true;
357 } 357 }
358 358
359 // Implemented here to create the platform specific instance of the BubbleUi. 359 // Implemented here to create the platform specific instance of the BubbleUi.
360 std::unique_ptr<BubbleUi> ExtensionInstalledBubble::BuildBubbleUi() { 360 std::unique_ptr<BubbleUi> ExtensionInstalledBubble::BuildBubbleUi() {
361 return base::WrapUnique(new ExtensionInstalledBubbleUi(this)); 361 return base::WrapUnique(new ExtensionInstalledBubbleUi(this));
362 } 362 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/bookmark_override_browsertest.cc ('k') | chrome/browser/ui/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698