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

Side by Side Diff: chrome/browser/ui/ash/launcher/app_window_launcher_item_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_window_launcher_item_controller.h" 5 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
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/ui/ash/launcher/chrome_launcher_controller.h" 11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
11 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
12 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 13 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
13 #include "ui/aura/client/aura_constants.h" 14 #include "ui/aura/client/aura_constants.h"
14 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
15 #include "ui/base/base_window.h" 16 #include "ui/base/base_window.h"
16 #include "ui/wm/core/window_animations.h" 17 #include "ui/wm/core/window_animations.h"
17 18
18 AppWindowLauncherItemController::AppWindowLauncherItemController( 19 AppWindowLauncherItemController::AppWindowLauncherItemController(
19 Type type, 20 Type type,
20 const std::string& app_id, 21 const std::string& app_id,
21 const std::string& launch_id, 22 const std::string& launch_id,
23 const std::string& title,
22 ChromeLauncherController* controller) 24 ChromeLauncherController* controller)
23 : LauncherItemController(type, app_id, launch_id, controller), 25 : LauncherItemController(type, app_id, launch_id, title, controller),
24 observed_windows_(this) {} 26 observed_windows_(this) {}
25 27
26 AppWindowLauncherItemController::~AppWindowLauncherItemController() {} 28 AppWindowLauncherItemController::~AppWindowLauncherItemController() {}
27 29
28 void AppWindowLauncherItemController::AddWindow(ui::BaseWindow* app_window) { 30 void AppWindowLauncherItemController::AddWindow(ui::BaseWindow* app_window) {
29 windows_.push_front(app_window); 31 windows_.push_front(app_window);
30 aura::Window* window = app_window->GetNativeWindow(); 32 aura::Window* window = app_window->GetNativeWindow();
31 if (window) 33 if (window)
32 observed_windows_.Add(window); 34 observed_windows_.Add(window);
33 } 35 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // item if the window we are trying to activate is already active. 129 // item if the window we are trying to activate is already active.
128 if (windows_.size() >= 1 && window_to_show->IsActive() && 130 if (windows_.size() >= 1 && window_to_show->IsActive() &&
129 event.type() == ui::ET_KEY_RELEASED) { 131 event.type() == ui::ET_KEY_RELEASED) {
130 return ActivateOrAdvanceToNextAppWindow(window_to_show); 132 return ActivateOrAdvanceToNextAppWindow(window_to_show);
131 } else { 133 } else {
132 return ShowAndActivateOrMinimize(window_to_show); 134 return ShowAndActivateOrMinimize(window_to_show);
133 } 135 }
134 } 136 }
135 137
136 base::string16 AppWindowLauncherItemController::GetTitle() { 138 base::string16 AppWindowLauncherItemController::GetTitle() {
137 return LauncherControllerHelper::GetAppTitle(launcher_controller()->profile(), 139 if (!title().empty())
138 app_id()); 140 return base::UTF8ToUTF16(title());
141 else
142 return LauncherControllerHelper::GetAppTitle(
143 launcher_controller()->profile(), app_id());
139 } 144 }
140 145
141 bool AppWindowLauncherItemController::IsDraggable() { 146 bool AppWindowLauncherItemController::IsDraggable() {
142 DCHECK_EQ(TYPE_APP, type()); 147 DCHECK_EQ(TYPE_APP, type());
143 return true; 148 return true;
144 } 149 }
145 150
146 bool AppWindowLauncherItemController::CanPin() const { 151 bool AppWindowLauncherItemController::CanPin() const {
147 return GetPinnableForAppID(app_id(), launcher_controller()->profile()) == 152 return GetPinnableForAppID(app_id(), launcher_controller()->profile()) ==
148 AppListControllerDelegate::PIN_EDITABLE; 153 AppListControllerDelegate::PIN_EDITABLE;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 if (window_to_show->IsActive()) { 197 if (window_to_show->IsActive()) {
193 // Coming here, only a single window is active. For keyboard activations 198 // Coming here, only a single window is active. For keyboard activations
194 // the window gets animated. 199 // the window gets animated.
195 AnimateWindow(window_to_show->GetNativeWindow(), 200 AnimateWindow(window_to_show->GetNativeWindow(),
196 wm::WINDOW_ANIMATION_TYPE_BOUNCE); 201 wm::WINDOW_ANIMATION_TYPE_BOUNCE);
197 } else { 202 } else {
198 return ShowAndActivateOrMinimize(window_to_show); 203 return ShowAndActivateOrMinimize(window_to_show);
199 } 204 }
200 return kNoAction; 205 return kNoAction;
201 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698