OLD | NEW |
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/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
6 | 6 |
7 #include "ash/multi_profile_uma.h" | 7 #include "ash/multi_profile_uma.h" |
8 #include "ash/public/cpp/shelf_item.h" | 8 #include "ash/public/cpp/shelf_item.h" |
9 #include "ash/public/interfaces/constants.mojom.h" | 9 #include "ash/public/interfaces/constants.mojom.h" |
10 #include "ash/resources/grit/ash_resources.h" | 10 #include "ash/resources/grit/ash_resources.h" |
| 11 #include "ash/shelf/shelf.h" |
11 #include "ash/shelf/shelf_model.h" | 12 #include "ash/shelf/shelf_model.h" |
12 #include "ash/shelf/wm_shelf.h" | |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/shell_port.h" | 14 #include "ash/shell_port.h" |
15 #include "ash/strings/grit/ash_strings.h" | 15 #include "ash/strings/grit/ash_strings.h" |
16 #include "ash/system/tray/system_tray_delegate.h" | 16 #include "ash/system/tray/system_tray_delegate.h" |
17 #include "ash/wm_window.h" | 17 #include "ash/wm_window.h" |
18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
19 #include "base/strings/pattern.h" | 19 #include "base/strings/pattern.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 #include "ui/display/screen.h" | 73 #include "ui/display/screen.h" |
74 #include "ui/display/types/display_constants.h" | 74 #include "ui/display/types/display_constants.h" |
75 #include "ui/keyboard/keyboard_util.h" | 75 #include "ui/keyboard/keyboard_util.h" |
76 #include "ui/resources/grit/ui_resources.h" | 76 #include "ui/resources/grit/ui_resources.h" |
77 | 77 |
78 using extension_misc::kChromeAppId; | 78 using extension_misc::kChromeAppId; |
79 using extension_misc::kGmailAppId; | 79 using extension_misc::kGmailAppId; |
80 | 80 |
81 namespace { | 81 namespace { |
82 | 82 |
83 int64_t GetDisplayIDForShelf(ash::WmShelf* shelf) { | 83 int64_t GetDisplayIDForShelf(ash::Shelf* shelf) { |
84 display::Display display = | 84 display::Display display = |
85 shelf->GetWindow()->GetRootWindow()->GetDisplayNearestWindow(); | 85 shelf->GetWindow()->GetRootWindow()->GetDisplayNearestWindow(); |
86 DCHECK(display.is_valid()); | 86 DCHECK(display.is_valid()); |
87 return display.id(); | 87 return display.id(); |
88 } | 88 } |
89 | 89 |
90 // A callback that does nothing after shelf item selection handling. | 90 // A callback that does nothing after shelf item selection handling. |
91 void NoopCallback(ash::ShelfAction, base::Optional<ash::MenuItemList>) {} | 91 void NoopCallback(ash::ShelfAction, base::Optional<ash::MenuItemList>) {} |
92 | 92 |
93 // Calls ItemSelected with |source|, default arguments, and no callback. | 93 // Calls ItemSelected with |source|, default arguments, and no callback. |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 646 |
647 BrowserShortcutLauncherItemController* | 647 BrowserShortcutLauncherItemController* |
648 ChromeLauncherController::GetBrowserShortcutLauncherItemController() { | 648 ChromeLauncherController::GetBrowserShortcutLauncherItemController() { |
649 ash::ShelfID id(kChromeAppId); | 649 ash::ShelfID id(kChromeAppId); |
650 ash::mojom::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id); | 650 ash::mojom::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id); |
651 DCHECK(delegate) << "There should be always be a browser shortcut item."; | 651 DCHECK(delegate) << "There should be always be a browser shortcut item."; |
652 return static_cast<BrowserShortcutLauncherItemController*>(delegate); | 652 return static_cast<BrowserShortcutLauncherItemController*>(delegate); |
653 } | 653 } |
654 | 654 |
655 bool ChromeLauncherController::ShelfBoundsChangesProbablyWithUser( | 655 bool ChromeLauncherController::ShelfBoundsChangesProbablyWithUser( |
656 ash::WmShelf* shelf, | 656 ash::Shelf* shelf, |
657 const AccountId& account_id) const { | 657 const AccountId& account_id) const { |
658 Profile* other_profile = multi_user_util::GetProfileFromAccountId(account_id); | 658 Profile* other_profile = multi_user_util::GetProfileFromAccountId(account_id); |
659 if (!other_profile || other_profile == profile()) | 659 if (!other_profile || other_profile == profile()) |
660 return false; | 660 return false; |
661 | 661 |
662 // Note: The Auto hide state from preferences is not the same as the actual | 662 // Note: The Auto hide state from preferences is not the same as the actual |
663 // visibility of the shelf. Depending on all the various states (full screen, | 663 // visibility of the shelf. Depending on all the various states (full screen, |
664 // no window on desktop, multi user, ..) the shelf could be shown - or not. | 664 // no window on desktop, multi user, ..) the shelf could be shown - or not. |
665 PrefService* prefs = profile()->GetPrefs(); | 665 PrefService* prefs = profile()->GetPrefs(); |
666 PrefService* other_prefs = other_profile->GetPrefs(); | 666 PrefService* other_prefs = other_profile->GetPrefs(); |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 RemovePinPosition(profile(), old_item.id); | 1351 RemovePinPosition(profile(), old_item.id); |
1352 } | 1352 } |
1353 | 1353 |
1354 /////////////////////////////////////////////////////////////////////////////// | 1354 /////////////////////////////////////////////////////////////////////////////// |
1355 // ash::WindowTreeHostManager::Observer: | 1355 // ash::WindowTreeHostManager::Observer: |
1356 | 1356 |
1357 void ChromeLauncherController::OnDisplayConfigurationChanged() { | 1357 void ChromeLauncherController::OnDisplayConfigurationChanged() { |
1358 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs. | 1358 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs. |
1359 // Because it might be called by some operations, like crbug.com/627040 | 1359 // Because it might be called by some operations, like crbug.com/627040 |
1360 // rotating screen. | 1360 // rotating screen. |
1361 ash::WmShelf* shelf = | 1361 ash::Shelf* shelf = ash::Shelf::ForWindow(ash::Shell::GetPrimaryRootWindow()); |
1362 ash::WmShelf::ForWindow(ash::Shell::GetPrimaryRootWindow()); | |
1363 if (shelf->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) | 1362 if (shelf->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) |
1364 SetShelfBehaviorsFromPrefs(); | 1363 SetShelfBehaviorsFromPrefs(); |
1365 } | 1364 } |
1366 | 1365 |
1367 /////////////////////////////////////////////////////////////////////////////// | 1366 /////////////////////////////////////////////////////////////////////////////// |
1368 // AppSyncUIStateObserver: | 1367 // AppSyncUIStateObserver: |
1369 | 1368 |
1370 void ChromeLauncherController::OnAppSyncUIStatusChanged() { | 1369 void ChromeLauncherController::OnAppSyncUIStatusChanged() { |
1371 // Update the app list button title to reflect the syncing status. | 1370 // Update the app list button title to reflect the syncing status. |
1372 base::string16 title = l10n_util::GetStringUTF16( | 1371 base::string16 title = l10n_util::GetStringUTF16( |
1373 app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING | 1372 app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING |
1374 ? IDS_ASH_SHELF_APP_LIST_LAUNCHER_SYNCING_TITLE | 1373 ? IDS_ASH_SHELF_APP_LIST_LAUNCHER_SYNCING_TITLE |
1375 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); | 1374 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); |
1376 | 1375 |
1377 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); | 1376 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); |
1378 DCHECK_GE(app_list_index, 0); | 1377 DCHECK_GE(app_list_index, 0); |
1379 ash::ShelfItem item = model_->items()[app_list_index]; | 1378 ash::ShelfItem item = model_->items()[app_list_index]; |
1380 if (item.title != title) { | 1379 if (item.title != title) { |
1381 item.title = title; | 1380 item.title = title; |
1382 model_->Set(app_list_index, item); | 1381 model_->Set(app_list_index, item); |
1383 } | 1382 } |
1384 } | 1383 } |
OLD | NEW |