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

Side by Side Diff: chrome/browser/dom_ui/app_launcher_handler.cc

Issue 5019005: Add "open as window" menu item to NTP app menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/dom_ui/app_launcher_handler.h" 5 #include "chrome/browser/dom_ui/app_launcher_handler.h"
6 6
7 #include "app/animation.h" 7 #include "app/animation.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 default_apps->DidShowPromo(); 183 default_apps->DidShowPromo();
184 promo_active_ = true; 184 promo_active_ = true;
185 } else { 185 } else {
186 dictionary->SetBoolean("showPromo", false); 186 dictionary->SetBoolean("showPromo", false);
187 promo_active_ = false; 187 promo_active_ = false;
188 } 188 }
189 189
190 bool showLauncher = 190 bool showLauncher =
191 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppLauncher); 191 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppLauncher);
192 dictionary->SetBoolean("showLauncher", showLauncher); 192 dictionary->SetBoolean("showLauncher", showLauncher);
193
194 #if defined(OS_MACOSX)
195 // App windows are not yet implemented on mac.
196 bool disable_app_window_launch = true;
197 #else
198 bool disable_app_window_launch = false;
199 #endif
200 dictionary->SetBoolean("disableAppWindowLaunch", disable_app_window_launch);
193 } 201 }
194 202
195 void AppLauncherHandler::HandleGetApps(const ListValue* args) { 203 void AppLauncherHandler::HandleGetApps(const ListValue* args) {
196 DictionaryValue dictionary; 204 DictionaryValue dictionary;
197 FillAppDictionary(&dictionary); 205 FillAppDictionary(&dictionary);
198 dom_ui_->CallJavascriptFunction(L"getAppsCallback", dictionary); 206 dom_ui_->CallJavascriptFunction(L"getAppsCallback", dictionary);
199 207
200 // First time we get here we set up the observer so that we can tell update 208 // First time we get here we set up the observer so that we can tell update
201 // the apps as they change. 209 // the apps as they change.
202 if (registrar_.IsEmpty()) { 210 if (registrar_.IsEmpty()) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 Profile* profile = extensions_service_->profile(); 249 Profile* profile = extensions_service_->profile();
242 250
243 // To give a more "launchy" experience when using the NTP launcher, we close 251 // To give a more "launchy" experience when using the NTP launcher, we close
244 // it automatically. 252 // it automatically.
245 Browser* browser = BrowserList::GetLastActive(); 253 Browser* browser = BrowserList::GetLastActive();
246 TabContents* old_contents = NULL; 254 TabContents* old_contents = NULL;
247 if (browser) 255 if (browser)
248 old_contents = browser->GetSelectedTabContents(); 256 old_contents = browser->GetSelectedTabContents();
249 257
250 AnimateAppIcon(extension, rect); 258 AnimateAppIcon(extension, rect);
259
260 extension_misc::LaunchContainer launch_container =
261 extension->launch_container();
262 ExtensionPrefs::LaunchType prefs_launch_type =
263 extensions_service_->extension_prefs()->GetLaunchType(extension_id);
264
265 // If the user chose to open in a window, change the container type.
266 if (prefs_launch_type == ExtensionPrefs::LAUNCH_WINDOW) {
Aaron Boodman 2010/11/18 07:49:03 Nit: no need for braces here and omitting them wou
Sam Kerner (Chrome) 2010/11/18 15:34:01 Done.
267 launch_container = extension_misc::LAUNCH_WINDOW;
268 }
269
251 TabContents* new_contents = Browser::OpenApplication( 270 TabContents* new_contents = Browser::OpenApplication(
252 profile, extension, extension->launch_container(), old_contents); 271 profile, extension, launch_container, old_contents);
253 272
254 if (new_contents != old_contents && browser->tab_count() > 1) 273 if (new_contents != old_contents && browser->tab_count() > 1)
255 browser->CloseTabContents(old_contents); 274 browser->CloseTabContents(old_contents);
256 275
257 if (extension_id != extension_misc::kWebStoreAppId) 276 if (extension_id != extension_misc::kWebStoreAppId)
258 RecordAppLaunch(promo_active_); 277 RecordAppLaunch(promo_active_);
259 } 278 }
260 279
261 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) { 280 void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) {
262 std::string extension_id; 281 std::string extension_id;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 322
304 for (ExtensionIdSet::const_iterator iter = app_ids->begin(); 323 for (ExtensionIdSet::const_iterator iter = app_ids->begin();
305 iter != app_ids->end(); ++iter) { 324 iter != app_ids->end(); ++iter) {
306 if (extensions_service_->GetExtensionById(*iter, true)) 325 if (extensions_service_->GetExtensionById(*iter, true))
307 extensions_service_->UninstallExtension(*iter, false); 326 extensions_service_->UninstallExtension(*iter, false);
308 } 327 }
309 328
310 extensions_service_->default_apps()->SetPromoHidden(); 329 extensions_service_->default_apps()->SetPromoHidden();
311 } 330 }
312 331
313 //static 332 // static
314 void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) { 333 void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) {
315 if (!promo_active) return; 334 if (!promo_active) return;
316 335
317 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, 336 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
318 extension_misc::PROMO_LAUNCH_WEB_STORE, 337 extension_misc::PROMO_LAUNCH_WEB_STORE,
319 extension_misc::PROMO_BUCKET_BOUNDARY); 338 extension_misc::PROMO_BUCKET_BOUNDARY);
320 } 339 }
321 340
322 //static 341 // static
323 void AppLauncherHandler::RecordAppLaunch(bool promo_active) { 342 void AppLauncherHandler::RecordAppLaunch(bool promo_active) {
324 // TODO(jstritar): record app launches that occur when the promo is not 343 // TODO(jstritar): record app launches that occur when the promo is not
325 // active using a different histogram. 344 // active using a different histogram.
326 345
327 if (!promo_active) return; 346 if (!promo_active) return;
328 347
329 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram, 348 UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
330 extension_misc::PROMO_LAUNCH_APP, 349 extension_misc::PROMO_LAUNCH_APP,
331 extension_misc::PROMO_BUCKET_BOUNDARY); 350 extension_misc::PROMO_BUCKET_BOUNDARY);
332 } 351 }
(...skipping 28 matching lines...) Expand all
361 // We make this check for the case of minimized windows, unit tests, etc. 380 // We make this check for the case of minimized windows, unit tests, etc.
362 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) && 381 if (platform_util::IsVisible(dom_ui_->tab_contents()->GetNativeView()) &&
363 Animation::ShouldRenderRichAnimation()) { 382 Animation::ShouldRenderRichAnimation()) {
364 #if defined(OS_WIN) 383 #if defined(OS_WIN)
365 AppLaunchedAnimation::Show(extension, rect); 384 AppLaunchedAnimation::Show(extension, rect);
366 #else 385 #else
367 NOTIMPLEMENTED(); 386 NOTIMPLEMENTED();
368 #endif 387 #endif
369 } 388 }
370 } 389 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698