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

Side by Side Diff: chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc

Issue 2484413002: Enhance chrome.app.window API with title property
Patch Set: Created 4 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/ash/launcher/app_shortcut_launcher_item_controller.h " 5 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h "
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/arc/arc_support_host.h" 11 #include "chrome/browser/chromeos/arc/arc_support_host.h"
11 #include "chrome/browser/extensions/launch_util.h" 12 #include "chrome/browser/extensions/launch_util.h"
12 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 13 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
13 #include "chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_co ntroller.h" 14 #include "chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_co ntroller.h"
14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h"
16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" 18 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
18 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" 19 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h"
19 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" 20 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return true; 60 return true;
60 return multi_user_util::IsProfileFromActiveUser(browser->profile()); 61 return multi_user_util::IsProfileFromActiveUser(browser->profile());
61 } 62 }
62 63
63 } // namespace 64 } // namespace
64 65
65 // static 66 // static
66 AppShortcutLauncherItemController* AppShortcutLauncherItemController::Create( 67 AppShortcutLauncherItemController* AppShortcutLauncherItemController::Create(
67 const std::string& app_id, 68 const std::string& app_id,
68 const std::string& launch_id, 69 const std::string& launch_id,
70 const std::string& title,
69 ChromeLauncherController* controller) { 71 ChromeLauncherController* controller) {
70 if (app_id == ArcSupportHost::kHostAppId || app_id == arc::kPlayStoreAppId) 72 if (app_id == ArcSupportHost::kHostAppId || app_id == arc::kPlayStoreAppId)
71 return new ArcPlaystoreShortcutLauncherItemController(controller); 73 return new ArcPlaystoreShortcutLauncherItemController(controller);
72 return new AppShortcutLauncherItemController(app_id, launch_id, controller); 74 return new AppShortcutLauncherItemController(app_id, launch_id, title,
75 controller);
73 } 76 }
74 77
75 // Item controller for an app shortcut. Shortcuts track app and launcher ids, 78 // Item controller for an app shortcut. Shortcuts track app and launcher ids,
76 // but do not have any associated windows (opening a shortcut will replace the 79 // but do not have any associated windows (opening a shortcut will replace the
77 // item with the appropriate LauncherItemController type). 80 // item with the appropriate LauncherItemController type).
78 AppShortcutLauncherItemController::AppShortcutLauncherItemController( 81 AppShortcutLauncherItemController::AppShortcutLauncherItemController(
79 const std::string& app_id, 82 const std::string& app_id,
80 const std::string& launch_id, 83 const std::string& launch_id,
84 const std::string& title,
81 ChromeLauncherController* controller) 85 ChromeLauncherController* controller)
82 : LauncherItemController(TYPE_SHORTCUT, app_id, launch_id, controller), 86 : LauncherItemController(TYPE_SHORTCUT,
87 app_id,
88 launch_id,
89 title,
90 controller),
83 chrome_launcher_controller_(controller), 91 chrome_launcher_controller_(controller),
84 app_id_(app_id), 92 app_id_(app_id),
85 launch_id_(launch_id) { 93 launch_id_(launch_id),
94 title_(title) {
86 // To detect V1 applications we use their domain and match them against the 95 // To detect V1 applications we use their domain and match them against the
87 // used URL. This will also work with applications like Google Drive. 96 // used URL. This will also work with applications like Google Drive.
88 const Extension* extension = 97 const Extension* extension =
89 GetExtensionForAppID(app_id, controller->profile()); 98 GetExtensionForAppID(app_id, controller->profile());
90 // Some unit tests have no real extension. 99 // Some unit tests have no real extension.
91 if (extension) { 100 if (extension) {
92 set_refocus_url(GURL( 101 set_refocus_url(GURL(
93 extensions::AppLaunchInfo::GetLaunchWebURL(extension).spec() + "*")); 102 extensions::AppLaunchInfo::GetLaunchWebURL(extension).spec() + "*"));
94 } 103 }
95 } 104 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // In case of a keyboard event, we were called by a hotkey. In that case we 220 // In case of a keyboard event, we were called by a hotkey. In that case we
212 // activate the next item in line if an item of our list is already active. 221 // activate the next item in line if an item of our list is already active.
213 if (event.type() == ui::ET_KEY_RELEASED) { 222 if (event.type() == ui::ET_KEY_RELEASED) {
214 if (AdvanceToNextApp()) 223 if (AdvanceToNextApp())
215 return kExistingWindowActivated; 224 return kExistingWindowActivated;
216 } 225 }
217 return Activate(ash::LAUNCH_FROM_UNKNOWN); 226 return Activate(ash::LAUNCH_FROM_UNKNOWN);
218 } 227 }
219 228
220 base::string16 AppShortcutLauncherItemController::GetTitle() { 229 base::string16 AppShortcutLauncherItemController::GetTitle() {
221 return LauncherControllerHelper::GetAppTitle(launcher_controller()->profile(), 230 if (!title().empty())
222 app_id()); 231 return base::UTF8ToUTF16(title());
232 else
233 return LauncherControllerHelper::GetAppTitle(
234 launcher_controller()->profile(), app_id());
223 } 235 }
224 236
225 ash::ShelfMenuModel* AppShortcutLauncherItemController::CreateApplicationMenu( 237 ash::ShelfMenuModel* AppShortcutLauncherItemController::CreateApplicationMenu(
226 int event_flags) { 238 int event_flags) {
227 return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags)); 239 return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags));
228 } 240 }
229 241
230 bool AppShortcutLauncherItemController::IsDraggable() { 242 bool AppShortcutLauncherItemController::IsDraggable() {
231 return true; 243 return true;
232 } 244 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 391
380 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { 392 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() {
381 if (last_launch_attempt_.is_null() || 393 if (last_launch_attempt_.is_null() ||
382 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( 394 last_launch_attempt_ + base::TimeDelta::FromMilliseconds(
383 kClickSuppressionInMS) < base::Time::Now()) { 395 kClickSuppressionInMS) < base::Time::Now()) {
384 last_launch_attempt_ = base::Time::Now(); 396 last_launch_attempt_ = base::Time::Now();
385 return true; 397 return true;
386 } 398 }
387 return false; 399 return false;
388 } 400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698