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

Side by Side Diff: chrome/browser/ui/views/frame/browser_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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 28 matching lines...) Expand all
39 #include "chrome/browser/profiles/profile_manager.h" 39 #include "chrome/browser/profiles/profile_manager.h"
40 #include "chrome/browser/profiles/profile_window.h" 40 #include "chrome/browser/profiles/profile_window.h"
41 #include "chrome/browser/profiles/profiles_state.h" 41 #include "chrome/browser/profiles/profiles_state.h"
42 #include "chrome/browser/search/search.h" 42 #include "chrome/browser/search/search.h"
43 #include "chrome/browser/sessions/tab_restore_service_factory.h" 43 #include "chrome/browser/sessions/tab_restore_service_factory.h"
44 #include "chrome/browser/signin/chrome_signin_helper.h" 44 #include "chrome/browser/signin/chrome_signin_helper.h"
45 #include "chrome/browser/themes/theme_properties.h" 45 #include "chrome/browser/themes/theme_properties.h"
46 #include "chrome/browser/themes/theme_service.h" 46 #include "chrome/browser/themes/theme_service.h"
47 #include "chrome/browser/translate/chrome_translate_client.h" 47 #include "chrome/browser/translate/chrome_translate_client.h"
48 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" 48 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h"
49 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h"
50 #include "chrome/browser/ui/browser.h" 49 #include "chrome/browser/ui/browser.h"
51 #include "chrome/browser/ui/browser_command_controller.h" 50 #include "chrome/browser/ui/browser_command_controller.h"
52 #include "chrome/browser/ui/browser_commands.h" 51 #include "chrome/browser/ui/browser_commands.h"
53 #include "chrome/browser/ui/browser_dialogs.h" 52 #include "chrome/browser/ui/browser_dialogs.h"
54 #include "chrome/browser/ui/browser_finder.h" 53 #include "chrome/browser/ui/browser_finder.h"
55 #include "chrome/browser/ui/browser_list.h" 54 #include "chrome/browser/ui/browser_list.h"
56 #include "chrome/browser/ui/browser_window_state.h" 55 #include "chrome/browser/ui/browser_window_state.h"
57 #include "chrome/browser/ui/search/search_delegate.h" 56 #include "chrome/browser/ui/search/search_delegate.h"
58 #include "chrome/browser/ui/search/search_model.h" 57 #include "chrome/browser/ui/search/search_model.h"
59 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" 58 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h"
(...skipping 14 matching lines...) Expand all
74 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 73 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
75 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" 74 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
76 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" 75 #include "chrome/browser/ui/views/frame/contents_layout_manager.h"
77 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 76 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
78 #include "chrome/browser/ui/views/frame/top_container_view.h" 77 #include "chrome/browser/ui/views/frame/top_container_view.h"
79 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" 78 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h"
80 #include "chrome/browser/ui/views/ime/ime_warning_bubble_view.h" 79 #include "chrome/browser/ui/views/ime/ime_warning_bubble_view.h"
81 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 80 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
82 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 81 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
83 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 82 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
83 #include "chrome/browser/ui/views/location_bar/star_view.h"
84 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" 84 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
85 #include "chrome/browser/ui/views/new_back_shortcut_bubble.h" 85 #include "chrome/browser/ui/views/new_back_shortcut_bubble.h"
86 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" 86 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
87 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h" 87 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h"
88 #include "chrome/browser/ui/views/session_crashed_bubble_view.h" 88 #include "chrome/browser/ui/views/session_crashed_bubble_view.h"
89 #include "chrome/browser/ui/views/status_bubble_views.h" 89 #include "chrome/browser/ui/views/status_bubble_views.h"
90 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" 90 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h"
91 #include "chrome/browser/ui/views/tabs/tab.h" 91 #include "chrome/browser/ui/views/tabs/tab.h"
92 #include "chrome/browser/ui/views/tabs/tab_strip.h" 92 #include "chrome/browser/ui/views/tabs/tab_strip.h"
93 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" 93 #include "chrome/browser/ui/views/toolbar/app_menu_button.h"
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 // Views does not support resizer rects because they caused page cycler 1233 // Views does not support resizer rects because they caused page cycler
1234 // performance regressions when they were added. See crrev.com/9654 1234 // performance regressions when they were added. See crrev.com/9654
1235 return gfx::Rect(); 1235 return gfx::Rect();
1236 } 1236 }
1237 1237
1238 void BrowserView::ShowUpdateChromeDialog() { 1238 void BrowserView::ShowUpdateChromeDialog() {
1239 UpdateRecommendedMessageBox::Show(GetNativeWindow()); 1239 UpdateRecommendedMessageBox::Show(GetNativeWindow());
1240 } 1240 }
1241 1241
1242 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { 1242 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) {
1243 std::unique_ptr<BubbleSyncPromoDelegate> delegate; 1243 toolbar_->ShowBookmarkBubble(url, already_bookmarked,
1244 delegate.reset(new BookmarkBubbleSignInDelegate(browser_.get())); 1244 bookmark_bar_view_.get());
1245
1246 views::View* anchor_view = GetToolbarView()->GetBookmarkBubbleAnchor();
1247 views::Widget* bubble_widget = BookmarkBubbleView::ShowBubble(
1248 anchor_view, gfx::Rect(), nullptr, bookmark_bar_view_.get(),
1249 std::move(delegate), browser_->profile(), url, already_bookmarked);
1250 GetToolbarView()->OnBubbleCreatedForAnchor(anchor_view, bubble_widget);
1251 } 1245 }
1252 1246
1253 void BrowserView::ShowBookmarkAppBubble( 1247 void BrowserView::ShowBookmarkAppBubble(
1254 const WebApplicationInfo& web_app_info, 1248 const WebApplicationInfo& web_app_info,
1255 const ShowBookmarkAppBubbleCallback& callback) { 1249 const ShowBookmarkAppBubbleCallback& callback) {
1256 BookmarkAppConfirmationView::CreateAndShow(GetNativeWindow(), web_app_info, 1250 BookmarkAppConfirmationView::CreateAndShow(GetNativeWindow(), web_app_info,
1257 callback); 1251 callback);
1258 } 1252 }
1259 1253
1260 autofill::SaveCardBubbleView* BrowserView::ShowSaveCreditCardBubble( 1254 autofill::SaveCardBubbleView* BrowserView::ShowSaveCreditCardBubble(
1261 content::WebContents* web_contents, 1255 content::WebContents* web_contents,
1262 autofill::SaveCardBubbleController* controller, 1256 autofill::SaveCardBubbleController* controller,
1263 bool is_user_gesture) { 1257 bool is_user_gesture) {
1264 views::View* anchor_view = GetToolbarView()->GetSaveCreditCardBubbleAnchor(); 1258 views::View* anchor_view = toolbar_->GetSaveCreditCardBubbleAnchor();
1265 autofill::SaveCardBubbleViews* view = new autofill::SaveCardBubbleViews( 1259 autofill::SaveCardBubbleViews* view = new autofill::SaveCardBubbleViews(
1266 anchor_view, web_contents, controller); 1260 anchor_view, web_contents, controller);
1267 GetToolbarView()->OnBubbleCreatedForAnchor(anchor_view, view->GetWidget()); 1261 toolbar_->OnBubbleCreatedForAnchor(anchor_view, view->GetWidget());
1268 view->Show(is_user_gesture ? autofill::SaveCardBubbleViews::USER_GESTURE 1262 view->Show(is_user_gesture ? autofill::SaveCardBubbleViews::USER_GESTURE
1269 : autofill::SaveCardBubbleViews::AUTOMATIC); 1263 : autofill::SaveCardBubbleViews::AUTOMATIC);
1270 return view; 1264 return view;
1271 } 1265 }
1272 1266
1273 void BrowserView::ShowTranslateBubble( 1267 void BrowserView::ShowTranslateBubble(
1274 content::WebContents* web_contents, 1268 content::WebContents* web_contents,
1275 translate::TranslateStep step, 1269 translate::TranslateStep step,
1276 translate::TranslateErrors::Type error_type, 1270 translate::TranslateErrors::Type error_type,
1277 bool is_user_gesture) { 1271 bool is_user_gesture) {
1278 if (contents_web_view_->HasFocus() && 1272 if (contents_web_view_->HasFocus() &&
1279 !GetLocationBarView()->IsMouseHovered()) { 1273 !GetLocationBarView()->IsMouseHovered()) {
1280 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); 1274 content::RenderViewHost* rvh = web_contents->GetRenderViewHost();
1281 if (rvh->IsFocusedElementEditable()) 1275 if (rvh->IsFocusedElementEditable())
1282 return; 1276 return;
1283 } 1277 }
1284 1278
1285 ChromeTranslateClient* chrome_translate_client = 1279 ChromeTranslateClient* chrome_translate_client =
1286 ChromeTranslateClient::FromWebContents(web_contents); 1280 ChromeTranslateClient::FromWebContents(web_contents);
1287 translate::LanguageState& language_state = 1281 translate::LanguageState& language_state =
1288 chrome_translate_client->GetLanguageState(); 1282 chrome_translate_client->GetLanguageState();
1289 language_state.SetTranslateEnabled(true); 1283 language_state.SetTranslateEnabled(true);
1290 1284
1291 if (IsMinimized()) 1285 if (IsMinimized())
1292 return; 1286 return;
1293 1287
1294 views::View* anchor_view = GetToolbarView()->GetTranslateBubbleAnchor(); 1288 views::View* anchor_view = toolbar_->GetTranslateBubbleAnchor();
1295 views::Widget* bubble_widget = TranslateBubbleView::ShowBubble( 1289 views::Widget* bubble_widget = TranslateBubbleView::ShowBubble(
1296 anchor_view, web_contents, step, 1290 anchor_view, web_contents, step,
1297 error_type, is_user_gesture ? TranslateBubbleView::USER_GESTURE 1291 error_type, is_user_gesture ? TranslateBubbleView::USER_GESTURE
1298 : TranslateBubbleView::AUTOMATIC); 1292 : TranslateBubbleView::AUTOMATIC);
1299 GetToolbarView()->OnBubbleCreatedForAnchor(anchor_view, bubble_widget); 1293 toolbar_->OnBubbleCreatedForAnchor(anchor_view, bubble_widget);
1300 } 1294 }
1301 1295
1302 #if BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN) 1296 #if BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN)
1303 void BrowserView::ShowOneClickSigninConfirmation( 1297 void BrowserView::ShowOneClickSigninConfirmation(
1304 const base::string16& email, 1298 const base::string16& email,
1305 const StartSyncCallback& start_sync_callback) { 1299 const StartSyncCallback& start_sync_callback) {
1306 std::unique_ptr<OneClickSigninLinksDelegate> delegate( 1300 std::unique_ptr<OneClickSigninLinksDelegate> delegate(
1307 new OneClickSigninLinksDelegateImpl(browser())); 1301 new OneClickSigninLinksDelegateImpl(browser()));
1308 OneClickSigninDialogView::ShowDialog(email, std::move(delegate), 1302 OneClickSigninDialogView::ShowDialog(email, std::move(delegate),
1309 GetNativeWindow(), start_sync_callback); 1303 GetNativeWindow(), start_sync_callback);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 } 1520 }
1527 1521
1528 LocationBarView* BrowserView::GetLocationBarView() const { 1522 LocationBarView* BrowserView::GetLocationBarView() const {
1529 return toolbar_ ? toolbar_->location_bar() : nullptr; 1523 return toolbar_ ? toolbar_->location_bar() : nullptr;
1530 } 1524 }
1531 1525
1532 views::View* BrowserView::GetTabContentsContainerView() const { 1526 views::View* BrowserView::GetTabContentsContainerView() const {
1533 return contents_web_view_; 1527 return contents_web_view_;
1534 } 1528 }
1535 1529
1536 ToolbarView* BrowserView::GetToolbarView() const {
1537 return toolbar_;
1538 }
1539
1540 /////////////////////////////////////////////////////////////////////////////// 1530 ///////////////////////////////////////////////////////////////////////////////
1541 // BrowserView, TabStripModelObserver implementation: 1531 // BrowserView, TabStripModelObserver implementation:
1542 1532
1543 void BrowserView::TabInsertedAt(TabStripModel* tab_strip_model, 1533 void BrowserView::TabInsertedAt(TabStripModel* tab_strip_model,
1544 WebContents* contents, 1534 WebContents* contents,
1545 int index, 1535 int index,
1546 bool foreground) { 1536 bool foreground) {
1547 #if defined(USE_AURA) 1537 #if defined(USE_AURA)
1548 // WebContents inserted in tabs might not have been added to the root 1538 // WebContents inserted in tabs might not have been added to the root
1549 // window yet. Per http://crbug/342672 add them now since drawing the 1539 // window yet. Per http://crbug/342672 add them now since drawing the
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 } 2652 }
2663 2653
2664 extensions::ActiveTabPermissionGranter* 2654 extensions::ActiveTabPermissionGranter*
2665 BrowserView::GetActiveTabPermissionGranter() { 2655 BrowserView::GetActiveTabPermissionGranter() {
2666 content::WebContents* web_contents = GetActiveWebContents(); 2656 content::WebContents* web_contents = GetActiveWebContents();
2667 if (!web_contents) 2657 if (!web_contents)
2668 return nullptr; 2658 return nullptr;
2669 return extensions::TabHelper::FromWebContents(web_contents) 2659 return extensions::TabHelper::FromWebContents(web_contents)
2670 ->active_tab_permission_granter(); 2660 ->active_tab_permission_granter();
2671 } 2661 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/ime/ime_warning_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698