| Index: chrome/browser/chromeos/extensions/wallpaper_manager_util.cc
|
| diff --git a/chrome/browser/chromeos/extensions/wallpaper_manager_util.cc b/chrome/browser/chromeos/extensions/wallpaper_manager_util.cc
|
| index e9fb98d4a73d0e447264aee9152e1116630ff982..b639b17a4e5f07c5a2371d51a19507a4f0b94a0d 100644
|
| --- a/chrome/browser/chromeos/extensions/wallpaper_manager_util.cc
|
| +++ b/chrome/browser/chromeos/extensions/wallpaper_manager_util.cc
|
| @@ -10,13 +10,38 @@
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_finder.h"
|
| +#include "chrome/browser/ui/browser_list.h"
|
| +#include "chrome/browser/ui/browser_tabstrip.h"
|
| +#include "chrome/browser/ui/browser_window.h"
|
| #include "chrome/browser/ui/chrome_pages.h"
|
| -#include "chrome/browser/ui/extensions/application_launch.h"
|
| +#include "chrome/browser/ui/tab_contents/tab_contents.h"
|
| +#include "chrome/browser/ui/tabs/tab_strip_model.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/extensions/extension_constants.h"
|
| #include "chrome/common/url_constants.h"
|
| +#include "content/public/browser/web_contents.h"
|
| +#include "ui/gfx/screen.h"
|
|
|
| namespace wallpaper_manager_util {
|
| +namespace {
|
| +
|
| +Browser* GetBrowserForUrl(GURL target_url) {
|
| + for (BrowserList::const_iterator browser_iterator = BrowserList::begin();
|
| + browser_iterator != BrowserList::end(); ++browser_iterator) {
|
| + Browser* browser = *browser_iterator;
|
| + TabStripModel* tab_strip = browser->tab_strip_model();
|
| + for (int idx = 0; idx < tab_strip->count(); idx++) {
|
| + content::WebContents* web_contents =
|
| + tab_strip->GetTabContentsAt(idx)->web_contents();
|
| + const GURL& url = web_contents->GetURL();
|
| + if (url == target_url)
|
| + return browser;
|
| + }
|
| + }
|
| + return NULL;
|
| +}
|
| +
|
| +} // namespace
|
|
|
| void OpenWallpaperManager() {
|
| Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
|
| @@ -33,11 +58,28 @@ void OpenWallpaperManager() {
|
| if (!extension)
|
| return;
|
|
|
| - application_launch::LaunchParams params(profile, extension,
|
| - extension_misc::LAUNCH_WINDOW,
|
| - NEW_FOREGROUND_TAB);
|
| - params.override_url = GURL(url);
|
| - application_launch::OpenApplication(params);
|
| + GURL wallpaper_picker_url(url);
|
| + int width = extension->launch_width();
|
| + int height = extension->launch_height();
|
| + const gfx::Size screen = gfx::Screen::GetPrimaryDisplay().size();
|
| + const gfx::Rect bounds((screen.width() - width) / 2,
|
| + (screen.height() - height) / 2,
|
| + width,
|
| + height);
|
| +
|
| + Browser* browser = GetBrowserForUrl(wallpaper_picker_url);
|
| +
|
| + if (!browser) {
|
| + browser = new Browser(
|
| + Browser::CreateParams::CreateForApp(Browser::TYPE_POPUP,
|
| + extension->name(),
|
| + bounds,
|
| + profile));
|
| +
|
| + chrome::AddSelectedTabWithURL(browser, wallpaper_picker_url,
|
| + content::PAGE_TRANSITION_LINK);
|
| + }
|
| + browser->window()->Show();
|
| } else {
|
| Browser* browser = browser::FindOrCreateTabbedBrowser(
|
| ProfileManager::GetDefaultProfileOrOffTheRecord());
|
|
|