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

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: 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 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 app_controller_iter->second; 156 app_controller_iter->second;
150 DCHECK(controller->app_id() == app_id); 157 DCHECK(controller->app_id() == app_id);
151 shelf_id = controller->shelf_id(); 158 shelf_id = controller->shelf_id();
152 controller->AddAppWindow(app_window); 159 controller->AddAppWindow(app_window);
153 } else { 160 } else {
154 LauncherItemController::Type type = 161 LauncherItemController::Type type =
155 app_window->window_type_is_panel() 162 app_window->window_type_is_panel()
156 ? LauncherItemController::TYPE_APP_PANEL 163 ? LauncherItemController::TYPE_APP_PANEL
157 : LauncherItemController::TYPE_APP; 164 : LauncherItemController::TYPE_APP;
158 std::string launch_id = GetLaunchId(app_window); 165 std::string launch_id = GetLaunchId(app_window);
166 std::string title = GetTitle(app_window);
159 ExtensionAppWindowLauncherItemController* controller = 167 ExtensionAppWindowLauncherItemController* controller =
160 new ExtensionAppWindowLauncherItemController(type, app_id, launch_id, 168 new ExtensionAppWindowLauncherItemController(type, app_id, launch_id,
161 owner()); 169 title, owner());
162 controller->AddAppWindow(app_window); 170 controller->AddAppWindow(app_window);
163 // If there is already a shelf id mapped to this app_shelf_id (e.g. pinned), 171 // If there is already a shelf id mapped to this app_shelf_id (e.g. pinned),
164 // use that shelf item. 172 // use that shelf item.
165 shelf_id = 173 shelf_id =
166 ash::WmShell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID( 174 ash::WmShell::Get()->shelf_delegate()->GetShelfIDForAppIDAndLaunchID(
167 app_id, launch_id); 175 app_id, launch_id);
168 176
169 if (shelf_id == 0) { 177 if (shelf_id == 0) {
170 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, status); 178 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, status);
171 // Restore any existing app icon and flag as set. 179 // Restore any existing app icon and flag as set.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 WindowToAppShelfIdMap::iterator window_iter = 232 WindowToAppShelfIdMap::iterator window_iter =
225 window_to_app_shelf_id_map_.find(window); 233 window_to_app_shelf_id_map_.find(window);
226 if (window_iter == window_to_app_shelf_id_map_.end()) 234 if (window_iter == window_to_app_shelf_id_map_.end())
227 return nullptr; 235 return nullptr;
228 AppControllerMap::iterator app_controller_iter = 236 AppControllerMap::iterator app_controller_iter =
229 app_controller_map_.find(window_iter->second); 237 app_controller_map_.find(window_iter->second);
230 if (app_controller_iter == app_controller_map_.end()) 238 if (app_controller_iter == app_controller_map_.end())
231 return nullptr; 239 return nullptr;
232 return app_controller_iter->second; 240 return app_controller_iter->second;
233 } 241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698