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

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

Issue 2484413002: Enhance chrome.app.window API with title property
Patch Set: Rebase Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/extension_app_window_launcher_controlle r.h" 5 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_controlle r.h"
6 6
7 #include "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/shelf/shelf_delegate.h" 8 #include "ash/common/shelf/shelf_delegate.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/common/wm_window_property.h" 10 #include "ash/common/wm_window_property.h"
(...skipping 23 matching lines...) Expand all
34 std::string launch_id; 34 std::string launch_id;
35 if (app_window->show_in_shelf() || app_window->window_type_is_panel()) { 35 if (app_window->show_in_shelf() || app_window->window_type_is_panel()) {
36 if (!app_window->window_key().empty()) 36 if (!app_window->window_key().empty())
37 launch_id = app_window->window_key(); 37 launch_id = app_window->window_key();
38 else 38 else
39 launch_id = base::StringPrintf("%d", app_window->session_id().id()); 39 launch_id = base::StringPrintf("%d", app_window->session_id().id());
40 } 40 }
41 return launch_id; 41 return launch_id;
42 } 42 }
43 43
44 std::string GetTitle(AppWindow* app_window) {
45 if (app_window->show_in_shelf())
46 return app_window->title();
47 else
48 return base::EmptyString();
49 }
50
44 std::string GetAppShelfId(AppWindow* app_window) { 51 std::string GetAppShelfId(AppWindow* app_window) {
45 // Set app_shelf_id value to app_id and then append launch_id. 52 // Set app_shelf_id value to app_id and then append launch_id.
46 std::string app_id = app_window->extension_id(); 53 std::string app_id = app_window->extension_id();
47 std::string launch_id = GetLaunchId(app_window); 54 std::string launch_id = GetLaunchId(app_window);
48 return app_id + launch_id; 55 return app_id + launch_id;
49 } 56 }
50 57
51 } // namespace 58 } // namespace
52 59
53 ExtensionAppWindowLauncherController::ExtensionAppWindowLauncherController( 60 ExtensionAppWindowLauncherController::ExtensionAppWindowLauncherController(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 167
161 if (app_controller_iter != app_controller_map_.end()) { 168 if (app_controller_iter != app_controller_map_.end()) {
162 ExtensionAppWindowLauncherItemController* controller = 169 ExtensionAppWindowLauncherItemController* controller =
163 app_controller_iter->second; 170 app_controller_iter->second;
164 DCHECK(controller->app_id() == app_id); 171 DCHECK(controller->app_id() == app_id);
165 shelf_id = controller->shelf_id(); 172 shelf_id = controller->shelf_id();
166 controller->AddAppWindow(app_window); 173 controller->AddAppWindow(app_window);
167 } else { 174 } else {
168 LauncherItemController::Type type = LauncherItemController::TYPE_APP; 175 LauncherItemController::Type type = LauncherItemController::TYPE_APP;
169 std::string launch_id = GetLaunchId(app_window); 176 std::string launch_id = GetLaunchId(app_window);
177 std::string title = GetTitle(app_window);
170 ExtensionAppWindowLauncherItemController* controller = 178 ExtensionAppWindowLauncherItemController* controller =
171 new ExtensionAppWindowLauncherItemController(type, app_id, launch_id, 179 new ExtensionAppWindowLauncherItemController(type, app_id, launch_id,
172 owner()); 180 title, owner());
173 controller->AddAppWindow(app_window); 181 controller->AddAppWindow(app_window);
174 // If there is already a shelf id mapped to this app_shelf_id (e.g. pinned), 182 // If there is already a shelf id mapped to this app_shelf_id (e.g. pinned),
175 // use that shelf item. 183 // use that shelf item.
176 shelf_id = 184 shelf_id =
177 ash::WmShell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID( 185 ash::WmShell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID(
178 app_id, launch_id); 186 app_id, launch_id);
179 187
180 if (shelf_id == 0) { 188 if (shelf_id == 0) {
181 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, status); 189 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, status);
182 // Restore any existing app icon and flag as set. 190 // Restore any existing app icon and flag as set.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 WindowToAppShelfIdMap::iterator window_iter = 243 WindowToAppShelfIdMap::iterator window_iter =
236 window_to_app_shelf_id_map_.find(window); 244 window_to_app_shelf_id_map_.find(window);
237 if (window_iter == window_to_app_shelf_id_map_.end()) 245 if (window_iter == window_to_app_shelf_id_map_.end())
238 return nullptr; 246 return nullptr;
239 AppControllerMap::iterator app_controller_iter = 247 AppControllerMap::iterator app_controller_iter =
240 app_controller_map_.find(window_iter->second); 248 app_controller_map_.find(window_iter->second);
241 if (app_controller_iter == app_controller_map_.end()) 249 if (app_controller_iter == app_controller_map_.end())
242 return nullptr; 250 return nullptr;
243 return app_controller_iter->second; 251 return app_controller_iter->second;
244 } 252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698