Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/wallpaper_manager_api.cc |
| diff --git a/chrome/browser/chromeos/extensions/wallpaper_manager_api.cc b/chrome/browser/chromeos/extensions/wallpaper_manager_api.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bb9eee618f0e2297924f7fd8dd981c7b3b0c2d9c |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/extensions/wallpaper_manager_api.cc |
| @@ -0,0 +1,56 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/extensions/wallpaper_manager_api.h" |
| + |
| +#include "base/command_line.h" |
| +#include "base/file_util.h" |
| +#include "base/path_service.h" |
| +#include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/chromeos/login/user_manager.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/profiles/profile_manager.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_finder.h" |
| +#include "chrome/browser/ui/chrome_pages.h" |
| +#include "chrome/browser/ui/extensions/application_launch.h" |
| +#include "chrome/common/chrome_paths.h" |
| +#include "chrome/common/chrome_switches.h" |
| +#include "chrome/common/url_constants.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +using content::BrowserThread; |
| + |
| +#define WALLPAPERMANAGER_EXTENSON_ID "obklkkbkpaoaejdabbfldmcfplpdgolj" |
| + |
| +const char kWallpaperManagerDomain[] = WALLPAPERMANAGER_EXTENSON_ID; |
|
flackr
2012/07/04 22:20:57
Why not just assign the extension ID directly?
bshe
2012/07/05 13:54:50
Done.
|
| + |
| +namespace wallpaper_manager_util { |
| + |
| +// Hide behind flag |
|
flackr
2012/07/04 22:20:57
Does this comment belong by the if statement?
bshe
2012/07/05 13:54:50
Done.
|
| +void OpenWallpaperManager() { |
| + Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
| + if (CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kExperimentalWallpaperUI)) { |
| + std::string url = chrome::kChromeUIWallpaperURL; |
| + ExtensionService* service = profile->GetExtensionService(); |
| + if (!service) |
| + return; |
| + |
| + const extensions::Extension* extension = |
| + service->GetExtensionById(kWallpaperManagerDomain, false); |
| + if (!extension) |
| + return; |
| + |
| + application_launch::OpenApplication(profile, extension, |
| + extension_misc::LAUNCH_WINDOW, GURL(url), NEW_FOREGROUND_TAB, NULL); |
| + } else { |
| + Browser* browser = browser::FindOrCreateTabbedBrowser( |
| + ProfileManager::GetDefaultProfileOrOffTheRecord()); |
| + chrome::ShowSettingsSubPage(browser, "setWallpaper"); |
| + } |
| +} |
| + |
| +} //namespace wallpaper_manager_util |