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

Unified Diff: chrome/browser/chromeos/extensions/wallpaper_manager_util.cc

Issue 10978022: Center wallpaper picker when open and open author's website in a new window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only allow one instance of wallpaper picker. Created 8 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/wallpaper_manager/js/wallpaper_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698