| OLD | NEW |
| 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 "apps/app_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "apps/ui/native_app_window.h" | 8 #include "apps/ui/native_app_window.h" |
| 9 #include "ash/shelf/shelf_model.h" | 9 #include "ash/shelf/shelf_model.h" |
| 10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
| 11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
| 12 #include "chrome/browser/extensions/webstore_install_prompt.h" |
| 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" | 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h" |
| 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" | 14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_v2app.h" |
| 14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 15 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 16 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
| 16 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" | 17 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" |
| 17 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 18 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 19 #include "skia/ext/image_operations.h" | 20 #include "skia/ext/image_operations.h" |
| 20 #include "ui/aura/client/aura_constants.h" | 21 #include "ui/aura/client/aura_constants.h" |
| 21 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 145 } |
| 145 | 146 |
| 146 void AppWindowLauncherItemController::ActivateIndexedApp(size_t index) { | 147 void AppWindowLauncherItemController::ActivateIndexedApp(size_t index) { |
| 147 if (index >= app_windows_.size()) | 148 if (index >= app_windows_.size()) |
| 148 return; | 149 return; |
| 149 AppWindowList::iterator it = app_windows_.begin(); | 150 AppWindowList::iterator it = app_windows_.begin(); |
| 150 std::advance(it, index); | 151 std::advance(it, index); |
| 151 ShowAndActivateOrMinimize(*it); | 152 ShowAndActivateOrMinimize(*it); |
| 152 } | 153 } |
| 153 | 154 |
| 155 void AppWindowLauncherItemController::InstallApp() { |
| 156 AppWindow* parent_window = |
| 157 last_active_app_window_ ? last_active_app_window_ : app_windows_.back(); |
| 158 scoped_refptr<extensions::WebstoreInstallPrompt> installer = |
| 159 new extensions::WebstoreInstallPrompt( |
| 160 app_id(), |
| 161 launcher_controller()->profile(), |
| 162 parent_window ? parent_window->GetNativeWindow() : NULL, |
| 163 extensions::WebstoreInstallPrompt::Callback()); |
| 164 installer->BeginInstall(); |
| 165 } |
| 166 |
| 154 ChromeLauncherAppMenuItems AppWindowLauncherItemController::GetApplicationList( | 167 ChromeLauncherAppMenuItems AppWindowLauncherItemController::GetApplicationList( |
| 155 int event_flags) { | 168 int event_flags) { |
| 156 ChromeLauncherAppMenuItems items; | 169 ChromeLauncherAppMenuItems items; |
| 157 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false)); | 170 items.push_back(new ChromeLauncherAppMenuItem(GetTitle(), NULL, false)); |
| 158 int index = 0; | 171 int index = 0; |
| 159 for (AppWindowList::iterator iter = app_windows_.begin(); | 172 for (AppWindowList::iterator iter = app_windows_.begin(); |
| 160 iter != app_windows_.end(); | 173 iter != app_windows_.end(); |
| 161 ++iter) { | 174 ++iter) { |
| 162 AppWindow* app_window = *iter; | 175 AppWindow* app_window = *iter; |
| 163 scoped_ptr<gfx::Image> image(GetAppListIcon(app_window)); | 176 scoped_ptr<gfx::Image> image(GetAppListIcon(app_window)); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 292 } |
| 280 if (window_to_show->GetBaseWindow()->IsActive()) { | 293 if (window_to_show->GetBaseWindow()->IsActive()) { |
| 281 // Coming here, only a single window is active. For keyboard activations | 294 // Coming here, only a single window is active. For keyboard activations |
| 282 // the window gets animated. | 295 // the window gets animated. |
| 283 AnimateWindow(window_to_show->GetNativeWindow(), | 296 AnimateWindow(window_to_show->GetNativeWindow(), |
| 284 wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 297 wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
| 285 } else { | 298 } else { |
| 286 ShowAndActivateOrMinimize(window_to_show); | 299 ShowAndActivateOrMinimize(window_to_show); |
| 287 } | 300 } |
| 288 } | 301 } |
| OLD | NEW |