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

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

Issue 2394143004: Harmony - Update anchors for the rest of the location bar icons that (Closed)
Patch Set: actually fix 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
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_view.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/i18n/number_formatting.h" 10 #include "base/i18n/number_formatting.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/ui/browser_command_controller.h" 22 #include "chrome/browser/ui/browser_command_controller.h"
23 #include "chrome/browser/ui/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
24 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" 24 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h"
25 #include "chrome/browser/ui/browser_tabstrip.h" 25 #include "chrome/browser/ui/browser_tabstrip.h"
26 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
27 #include "chrome/browser/ui/global_error/global_error_service.h" 27 #include "chrome/browser/ui/global_error/global_error_service.h"
28 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 28 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
29 #include "chrome/browser/ui/layout_constants.h" 29 #include "chrome/browser/ui/layout_constants.h"
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" 30 #include "chrome/browser/ui/tabs/tab_strip_model.h"
31 #include "chrome/browser/ui/view_ids.h" 31 #include "chrome/browser/ui/view_ids.h"
32 #include "chrome/browser/ui/views/autofill/save_card_bubble_views.h"
32 #include "chrome/browser/ui/views/autofill/save_card_icon_view.h" 33 #include "chrome/browser/ui/views/autofill/save_card_icon_view.h"
33 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" 34 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
34 #include "chrome/browser/ui/views/extensions/extension_popup.h" 35 #include "chrome/browser/ui/views/extensions/extension_popup.h"
35 #include "chrome/browser/ui/views/frame/browser_view.h" 36 #include "chrome/browser/ui/views/frame/browser_view.h"
36 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 37 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
37 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" 38 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
38 #include "chrome/browser/ui/views/location_bar/star_view.h" 39 #include "chrome/browser/ui/views/location_bar/star_view.h"
39 #include "chrome/browser/ui/views/outdated_upgrade_bubble_view.h" 40 #include "chrome/browser/ui/views/outdated_upgrade_bubble_view.h"
40 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" 41 #include "chrome/browser/ui/views/toolbar/app_menu_button.h"
41 #include "chrome/browser/ui/views/toolbar/back_button.h" 42 #include "chrome/browser/ui/views/toolbar/back_button.h"
42 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" 43 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
43 #include "chrome/browser/ui/views/toolbar/home_button.h" 44 #include "chrome/browser/ui/views/toolbar/home_button.h"
44 #include "chrome/browser/ui/views/toolbar/reload_button.h" 45 #include "chrome/browser/ui/views/toolbar/reload_button.h"
45 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" 46 #include "chrome/browser/ui/views/toolbar/toolbar_button.h"
47 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
46 #include "chrome/browser/ui/views/translate/translate_icon_view.h" 48 #include "chrome/browser/ui/views/translate/translate_icon_view.h"
47 #include "chrome/common/chrome_switches.h" 49 #include "chrome/common/chrome_switches.h"
48 #include "chrome/common/pref_names.h" 50 #include "chrome/common/pref_names.h"
49 #include "chrome/grit/chromium_strings.h" 51 #include "chrome/grit/chromium_strings.h"
50 #include "chrome/grit/generated_resources.h" 52 #include "chrome/grit/generated_resources.h"
51 #include "chrome/grit/theme_resources.h" 53 #include "chrome/grit/theme_resources.h"
52 #include "components/omnibox/browser/omnibox_view.h" 54 #include "components/omnibox/browser/omnibox_view.h"
53 #include "components/prefs/pref_service.h" 55 #include "components/prefs/pref_service.h"
54 #include "components/strings/grit/components_strings.h" 56 #include "components/strings/grit/components_strings.h"
55 #include "content/public/browser/browser_accessibility_state.h" 57 #include "content/public/browser/browser_accessibility_state.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 304
303 std::unique_ptr<BubbleSyncPromoDelegate> delegate; 305 std::unique_ptr<BubbleSyncPromoDelegate> delegate;
304 delegate.reset(new BookmarkBubbleSignInDelegate(browser_)); 306 delegate.reset(new BookmarkBubbleSignInDelegate(browser_));
305 views::Widget* bubble_widget = BookmarkBubbleView::ShowBubble( 307 views::Widget* bubble_widget = BookmarkBubbleView::ShowBubble(
306 anchor_view, gfx::Rect(), nullptr, observer, std::move(delegate), 308 anchor_view, gfx::Rect(), nullptr, observer, std::move(delegate),
307 browser_->profile(), url, already_bookmarked); 309 browser_->profile(), url, already_bookmarked);
308 if (bubble_widget && star_view) 310 if (bubble_widget && star_view)
309 bubble_widget->AddObserver(star_view); 311 bubble_widget->AddObserver(star_view);
310 } 312 }
311 313
312 views::View* ToolbarView::GetSaveCreditCardBubbleAnchor() { 314 autofill::SaveCardBubbleView* ToolbarView::ShowSaveCreditCardBubble(
313 views::View* save_credit_card_icon_view = 315 content::WebContents* web_contents,
314 location_bar()->save_credit_card_icon_view(); 316 autofill::SaveCardBubbleController* controller,
315 return (save_credit_card_icon_view && save_credit_card_icon_view->visible()) 317 bool is_user_gesture) {
316 ? save_credit_card_icon_view 318 views::View* anchor_view = location_bar();
317 : app_menu_button_; 319 BubbleIconView* card_view = location_bar()->save_credit_card_icon_view();
320 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) {
321 if (card_view && card_view->visible())
322 anchor_view = card_view;
323 else
324 anchor_view = app_menu_button_;
325 }
326
327 autofill::SaveCardBubbleViews* bubble = new autofill::SaveCardBubbleViews(
328 anchor_view, web_contents, controller);
329 if (card_view)
330 bubble->GetWidget()->AddObserver(card_view);
331 bubble->Show(is_user_gesture ? autofill::SaveCardBubbleViews::USER_GESTURE
332 : autofill::SaveCardBubbleViews::AUTOMATIC);
333 return bubble;
318 } 334 }
319 335
320 views::View* ToolbarView::GetTranslateBubbleAnchor() { 336 void ToolbarView::ShowTranslateBubble(
321 views::View* translate_icon_view = location_bar()->translate_icon_view(); 337 content::WebContents* web_contents,
322 return (translate_icon_view && translate_icon_view->visible()) 338 translate::TranslateStep step,
323 ? translate_icon_view 339 translate::TranslateErrors::Type error_type,
324 : app_menu_button_; 340 bool is_user_gesture) {
325 } 341 views::View* anchor_view = location_bar();
342 BubbleIconView* translate_icon_view = location_bar()->translate_icon_view();
343 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) {
344 if (translate_icon_view && translate_icon_view->visible())
345 anchor_view = translate_icon_view;
346 else
347 anchor_view = app_menu_button_;
348 }
326 349
327 void ToolbarView::OnBubbleCreatedForAnchor(views::View* anchor_view, 350 views::Widget* bubble_widget = TranslateBubbleView::ShowBubble(
328 views::Widget* bubble_widget) { 351 anchor_view, web_contents, step,
329 if (bubble_widget && 352 error_type, is_user_gesture ? TranslateBubbleView::USER_GESTURE
330 (anchor_view == location_bar()->save_credit_card_icon_view() || 353 : TranslateBubbleView::AUTOMATIC);
331 anchor_view == location_bar()->translate_icon_view())) { 354 if (bubble_widget && translate_icon_view)
332 DCHECK(anchor_view); 355 bubble_widget->AddObserver(translate_icon_view);
333 bubble_widget->AddObserver(static_cast<BubbleIconView*>(anchor_view));
334 }
335 } 356 }
336 357
337 int ToolbarView::GetMaxBrowserActionsWidth() const { 358 int ToolbarView::GetMaxBrowserActionsWidth() const {
338 // The browser actions container is allowed to grow, but only up until the 359 // The browser actions container is allowed to grow, but only up until the
339 // omnibox reaches its minimum size. So its maximum allowed width is its 360 // omnibox reaches its minimum size. So its maximum allowed width is its
340 // current size, plus any that the omnibox could give up. 361 // current size, plus any that the omnibox could give up.
341 return browser_actions_->width() + 362 return browser_actions_->width() +
342 (location_bar_->width() - location_bar_->GetMinimumSize().width()); 363 (location_bar_->width() - location_bar_->GetMinimumSize().width());
343 } 364 }
344 365
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 if (OutdatedUpgradeBubbleView::IsAvailable()) { 778 if (OutdatedUpgradeBubbleView::IsAvailable()) {
758 OutdatedUpgradeBubbleView::ShowBubble(app_menu_button_, browser_, 779 OutdatedUpgradeBubbleView::ShowBubble(app_menu_button_, browser_,
759 auto_update_enabled); 780 auto_update_enabled);
760 } 781 }
761 } 782 }
762 783
763 void ToolbarView::OnShowHomeButtonChanged() { 784 void ToolbarView::OnShowHomeButtonChanged() {
764 Layout(); 785 Layout();
765 SchedulePaint(); 786 SchedulePaint();
766 } 787 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698