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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 #include <algorithm> 9 #include <algorithm>
10 #include <memory>
9 #include <utility> 11 #include <utility>
10 12
11 #include "base/auto_reset.h" 13 #include "base/auto_reset.h"
12 #include "base/command_line.h" 14 #include "base/command_line.h"
13 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
14 #include "base/location.h" 16 #include "base/location.h"
15 #include "base/macros.h" 17 #include "base/macros.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
18 #include "base/profiler/scoped_tracker.h" 19 #include "base/profiler/scoped_tracker.h"
19 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
20 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
21 #include "base/thread_task_runner_handle.h" 22 #include "base/thread_task_runner_handle.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "chrome/app/chrome_command_ids.h" 24 #include "chrome/app/chrome_command_ids.h"
24 #include "chrome/app/chrome_dll_resource.h" 25 #include "chrome/app/chrome_dll_resource.h"
25 #include "chrome/browser/app_mode/app_mode_utils.h" 26 #include "chrome/browser/app_mode/app_mode_utils.h"
26 #include "chrome/browser/bookmarks/bookmark_stats.h" 27 #include "chrome/browser/bookmarks/bookmark_stats.h"
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 // window isn't active. 1038 // window isn't active.
1038 #if defined(OS_WIN) || defined(OS_CHROMEOS) 1039 #if defined(OS_WIN) || defined(OS_CHROMEOS)
1039 if (!force_location_bar_focus_ && !IsActive()) 1040 if (!force_location_bar_focus_ && !IsActive())
1040 return; 1041 return;
1041 #endif 1042 #endif
1042 1043
1043 // Temporarily reveal the top-of-window views (if not already revealed) so 1044 // Temporarily reveal the top-of-window views (if not already revealed) so
1044 // that the location bar view is visible and is considered focusable. If the 1045 // that the location bar view is visible and is considered focusable. If the
1045 // location bar view gains focus, |immersive_mode_controller_| will keep the 1046 // location bar view gains focus, |immersive_mode_controller_| will keep the
1046 // top-of-window views revealed. 1047 // top-of-window views revealed.
1047 scoped_ptr<ImmersiveRevealedLock> focus_reveal_lock( 1048 std::unique_ptr<ImmersiveRevealedLock> focus_reveal_lock(
1048 immersive_mode_controller_->GetRevealedLock( 1049 immersive_mode_controller_->GetRevealedLock(
1049 ImmersiveModeController::ANIMATE_REVEAL_YES)); 1050 ImmersiveModeController::ANIMATE_REVEAL_YES));
1050 1051
1051 LocationBarView* location_bar = GetLocationBarView(); 1052 LocationBarView* location_bar = GetLocationBarView();
1052 if (location_bar->omnibox_view()->IsFocusable()) { 1053 if (location_bar->omnibox_view()->IsFocusable()) {
1053 // Location bar got focus. 1054 // Location bar got focus.
1054 location_bar->FocusLocation(select_all); 1055 location_bar->FocusLocation(select_all);
1055 } else { 1056 } else {
1056 // If none of location bar got focus, then clear focus. 1057 // If none of location bar got focus, then clear focus.
1057 views::FocusManager* focus_manager = GetFocusManager(); 1058 views::FocusManager* focus_manager = GetFocusManager();
(...skipping 21 matching lines...) Expand all
1079 // We may end up here during destruction. 1080 // We may end up here during destruction.
1080 if (toolbar_) 1081 if (toolbar_)
1081 toolbar_->ResetTabState(contents); 1082 toolbar_->ResetTabState(contents);
1082 } 1083 }
1083 1084
1084 void BrowserView::FocusToolbar() { 1085 void BrowserView::FocusToolbar() {
1085 // Temporarily reveal the top-of-window views (if not already revealed) so 1086 // Temporarily reveal the top-of-window views (if not already revealed) so
1086 // that the toolbar is visible and is considered focusable. If the 1087 // that the toolbar is visible and is considered focusable. If the
1087 // toolbar gains focus, |immersive_mode_controller_| will keep the 1088 // toolbar gains focus, |immersive_mode_controller_| will keep the
1088 // top-of-window views revealed. 1089 // top-of-window views revealed.
1089 scoped_ptr<ImmersiveRevealedLock> focus_reveal_lock( 1090 std::unique_ptr<ImmersiveRevealedLock> focus_reveal_lock(
1090 immersive_mode_controller_->GetRevealedLock( 1091 immersive_mode_controller_->GetRevealedLock(
1091 ImmersiveModeController::ANIMATE_REVEAL_YES)); 1092 ImmersiveModeController::ANIMATE_REVEAL_YES));
1092 1093
1093 // Start the traversal within the main toolbar. SetPaneFocus stores 1094 // Start the traversal within the main toolbar. SetPaneFocus stores
1094 // the current focused view before changing focus. 1095 // the current focused view before changing focus.
1095 toolbar_->SetPaneFocus(nullptr); 1096 toolbar_->SetPaneFocus(nullptr);
1096 } 1097 }
1097 1098
1098 ToolbarActionsBar* BrowserView::GetToolbarActionsBar() { 1099 ToolbarActionsBar* BrowserView::GetToolbarActionsBar() {
1099 return toolbar_ && toolbar_->browser_actions() ? 1100 return toolbar_ && toolbar_->browser_actions() ?
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 Profile* profile) { 1230 Profile* profile) {
1230 EditSearchEngineDialog::Show(GetNativeWindow(), template_url, nullptr, 1231 EditSearchEngineDialog::Show(GetNativeWindow(), template_url, nullptr,
1231 profile); 1232 profile);
1232 } 1233 }
1233 1234
1234 void BrowserView::ShowUpdateChromeDialog() { 1235 void BrowserView::ShowUpdateChromeDialog() {
1235 UpdateRecommendedMessageBox::Show(GetNativeWindow()); 1236 UpdateRecommendedMessageBox::Show(GetNativeWindow());
1236 } 1237 }
1237 1238
1238 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) { 1239 void BrowserView::ShowBookmarkBubble(const GURL& url, bool already_bookmarked) {
1239 scoped_ptr<BubbleSyncPromoDelegate> delegate; 1240 std::unique_ptr<BubbleSyncPromoDelegate> delegate;
1240 delegate.reset(new BookmarkBubbleSignInDelegate(browser_.get())); 1241 delegate.reset(new BookmarkBubbleSignInDelegate(browser_.get()));
1241 1242
1242 views::View* anchor_view = GetToolbarView()->GetBookmarkBubbleAnchor(); 1243 views::View* anchor_view = GetToolbarView()->GetBookmarkBubbleAnchor();
1243 views::Widget* bubble_widget = BookmarkBubbleView::ShowBubble( 1244 views::Widget* bubble_widget = BookmarkBubbleView::ShowBubble(
1244 anchor_view, gfx::Rect(), nullptr, bookmark_bar_view_.get(), 1245 anchor_view, gfx::Rect(), nullptr, bookmark_bar_view_.get(),
1245 std::move(delegate), browser_->profile(), url, already_bookmarked); 1246 std::move(delegate), browser_->profile(), url, already_bookmarked);
1246 GetToolbarView()->OnBubbleCreatedForAnchor(anchor_view, bubble_widget); 1247 GetToolbarView()->OnBubbleCreatedForAnchor(anchor_view, bubble_widget);
1247 } 1248 }
1248 1249
1249 void BrowserView::ShowBookmarkAppBubble( 1250 void BrowserView::ShowBookmarkAppBubble(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 : TranslateBubbleView::AUTOMATIC); 1294 : TranslateBubbleView::AUTOMATIC);
1294 GetToolbarView()->OnBubbleCreatedForAnchor(anchor_view, bubble_widget); 1295 GetToolbarView()->OnBubbleCreatedForAnchor(anchor_view, bubble_widget);
1295 } 1296 }
1296 1297
1297 #if BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN) 1298 #if BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN)
1298 void BrowserView::ShowOneClickSigninBubble( 1299 void BrowserView::ShowOneClickSigninBubble(
1299 OneClickSigninBubbleType type, 1300 OneClickSigninBubbleType type,
1300 const base::string16& email, 1301 const base::string16& email,
1301 const base::string16& error_message, 1302 const base::string16& error_message,
1302 const StartSyncCallback& start_sync_callback) { 1303 const StartSyncCallback& start_sync_callback) {
1303 scoped_ptr<OneClickSigninBubbleDelegate> delegate; 1304 std::unique_ptr<OneClickSigninBubbleDelegate> delegate;
1304 delegate.reset(new OneClickSigninBubbleLinksDelegate(browser())); 1305 delegate.reset(new OneClickSigninBubbleLinksDelegate(browser()));
1305 1306
1306 views::View* anchor_view = nullptr; 1307 views::View* anchor_view = nullptr;
1307 if (type == BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE) 1308 if (type == BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE)
1308 anchor_view = toolbar_->app_menu_button(); 1309 anchor_view = toolbar_->app_menu_button();
1309 if (!anchor_view) 1310 if (!anchor_view)
1310 anchor_view = toolbar_->location_bar(); 1311 anchor_view = toolbar_->location_bar();
1311 DCHECK(anchor_view); 1312 DCHECK(anchor_view);
1312 1313
1313 OneClickSigninBubbleView::ShowBubble(type, email, error_message, 1314 OneClickSigninBubbleView::ShowBubble(type, email, error_message,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 1368
1368 WebsiteSettingsPopupView::ShowPopup(popup_anchor, gfx::Rect(), profile, 1369 WebsiteSettingsPopupView::ShowPopup(popup_anchor, gfx::Rect(), profile,
1369 web_contents, url, security_info); 1370 web_contents, url, security_info);
1370 } 1371 }
1371 1372
1372 void BrowserView::ShowAppMenu() { 1373 void BrowserView::ShowAppMenu() {
1373 if (!toolbar_->app_menu_button()) 1374 if (!toolbar_->app_menu_button())
1374 return; 1375 return;
1375 1376
1376 // Keep the top-of-window views revealed as long as the app menu is visible. 1377 // Keep the top-of-window views revealed as long as the app menu is visible.
1377 scoped_ptr<ImmersiveRevealedLock> revealed_lock( 1378 std::unique_ptr<ImmersiveRevealedLock> revealed_lock(
1378 immersive_mode_controller_->GetRevealedLock( 1379 immersive_mode_controller_->GetRevealedLock(
1379 ImmersiveModeController::ANIMATE_REVEAL_NO)); 1380 ImmersiveModeController::ANIMATE_REVEAL_NO));
1380 1381
1381 toolbar_->app_menu_button()->Activate(nullptr); 1382 toolbar_->app_menu_button()->Activate(nullptr);
1382 } 1383 }
1383 1384
1384 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 1385 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
1385 bool* is_keyboard_shortcut) { 1386 bool* is_keyboard_shortcut) {
1386 *is_keyboard_shortcut = false; 1387 *is_keyboard_shortcut = false;
1387 1388
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
2666 } 2667 }
2667 2668
2668 extensions::ActiveTabPermissionGranter* 2669 extensions::ActiveTabPermissionGranter*
2669 BrowserView::GetActiveTabPermissionGranter() { 2670 BrowserView::GetActiveTabPermissionGranter() {
2670 content::WebContents* web_contents = GetActiveWebContents(); 2671 content::WebContents* web_contents = GetActiveWebContents();
2671 if (!web_contents) 2672 if (!web_contents)
2672 return nullptr; 2673 return nullptr;
2673 return extensions::TabHelper::FromWebContents(web_contents) 2674 return extensions::TabHelper::FromWebContents(web_contents)
2674 ->active_tab_permission_granter(); 2675 ->active_tab_permission_granter();
2675 } 2676 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/frame/browser_view_layout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698