15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
70529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "base/logging.h"
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/extensions/extension_service.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile_manager.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/extensions/application_launch.h"
120529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "chrome/common/extensions/extension_constants.h"
135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "extensions/browser/extension_system.h"
140529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "extensions/common/extension.h"
150529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "ui/base/window_open_disposition.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace wallpaper_manager_util {
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void OpenWallpaperManager() {
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  Profile* profile = ProfileManager::GetActiveUserProfile();
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DCHECK(profile);
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ExtensionService* service =
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      extensions::ExtensionSystem::Get(profile)->extension_service();
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!service)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const extensions::Extension* extension =
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      service->GetExtensionById(extension_misc::kWallpaperManagerId, false);
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!extension)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return;
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
33a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  OpenApplication(AppLaunchParams(profile, extension,
34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                  extensions::LAUNCH_CONTAINER_WINDOW,
35f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)                                  NEW_WINDOW));
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace wallpaper_manager_util
39