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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_action_view.cc

Issue 869873008: [Extensions Toolbar] Move some popup logic to be platform-agnostic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avi's Created 5 years, 10 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 "chrome/browser/ui/views/toolbar/toolbar_action_view.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 views::MenuButton* ToolbarActionView::GetContextMenuButton() { 275 views::MenuButton* ToolbarActionView::GetContextMenuButton() {
276 DCHECK(visible()); // We should never show a context menu for a hidden item. 276 DCHECK(visible()); // We should never show a context menu for a hidden item.
277 return this; 277 return this;
278 } 278 }
279 279
280 content::WebContents* ToolbarActionView::GetCurrentWebContents() const { 280 content::WebContents* ToolbarActionView::GetCurrentWebContents() const {
281 return delegate_->GetCurrentWebContents(); 281 return delegate_->GetCurrentWebContents();
282 } 282 }
283 283
284 void ToolbarActionView::HideActivePopup() { 284 void ToolbarActionView::OnPopupShown(bool by_user) {
285 delegate_->HideActivePopup();
286 }
287
288 void ToolbarActionView::OnPopupShown(bool grant_tab_permissions) {
289 delegate_->SetPopupOwner(this); 285 delegate_->SetPopupOwner(this);
290 // If this was through direct user action, we press the menu button. 286 // If this was through direct user action, we press the menu button.
291 if (grant_tab_permissions) { 287 if (by_user) {
292 // We set the state of the menu button we're using as a reference view, 288 // We set the state of the menu button we're using as a reference view,
293 // which is either this or the overflow reference view. 289 // which is either this or the overflow reference view.
294 // This cast is safe because GetReferenceViewForPopup returns either |this| 290 // This cast is safe because GetReferenceViewForPopup returns either |this|
295 // or delegate_->GetOverflowReferenceView(), which returns a MenuButton. 291 // or delegate_->GetOverflowReferenceView(), which returns a MenuButton.
296 views::MenuButton* reference_view = 292 views::MenuButton* reference_view =
297 static_cast<views::MenuButton*>(GetReferenceViewForPopup()); 293 static_cast<views::MenuButton*>(GetReferenceViewForPopup());
298 pressed_lock_.reset(new views::MenuButton::PressedLock(reference_view)); 294 pressed_lock_.reset(new views::MenuButton::PressedLock(reference_view));
299 } 295 }
300 } 296 }
301 297
302 void ToolbarActionView::CleanupPopup() { 298 void ToolbarActionView::OnPopupClosed() {
303 // We need to do these actions synchronously (instead of closing and then 299 delegate_->SetPopupOwner(nullptr);
304 // performing the rest of the cleanup in OnWidgetDestroyed()) because
305 // OnWidgetDestroyed() can be called asynchronously from Close(), and we need
306 // to keep the delegate's popup owner up-to-date.
307 delegate_->SetPopupOwner(NULL);
308 pressed_lock_.reset(); // Unpress the menu button if it was pressed. 300 pressed_lock_.reset(); // Unpress the menu button if it was pressed.
309 } 301 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698