summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-04 15:38:36 +0000
committerrbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-04 15:38:36 +0000
commiteb5a70cfebc5e29669511add506e74bf38000cd1 (patch)
tree2f0f840fbccec664fabc775e30fe14c03c3ab236 /chrome
parent3fb815de6240e629ecad71911f93e4e369d9c9eb (diff)
downloadchromium_src-eb5a70cfebc5e29669511add506e74bf38000cd1.zip
chromium_src-eb5a70cfebc5e29669511add506e74bf38000cd1.tar.gz
chromium_src-eb5a70cfebc5e29669511add506e74bf38000cd1.tar.bz2
Remove the rectangle parameters which are no longer used anywhere.
Make the new button parameters optional - some NTP front-ends and some scenarios for the regular NTP don't provide this information. Pass the launch source as a number rather than converting it to a string and back. BUG=73859 TEST=just launch an app from the NTP, verify that ctrl-click still launches in new tab regardless of app settings. Review URL: http://codereview.chromium.org/6573003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76917 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/resources/ntp/apps.js55
-rw-r--r--chrome/browser/ui/webui/app_launcher_handler.cc51
2 files changed, 28 insertions, 78 deletions
diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js
index 25f2f53..4e9a38f 100644
--- a/chrome/browser/resources/ntp/apps.js
+++ b/chrome/browser/resources/ntp/apps.js
@@ -134,11 +134,7 @@ function appsPrefChangeCallback(data) {
// Launches the specified app using the APP_LAUNCH_NTP_APP_RE_ENABLE histogram.
// This should only be invoked from the AppLauncherHandler.
function launchAppAfterEnable(appId) {
- // TODO(jstritar): We can simplify the args to
- // [appId, APP_LAUNCH.NTP_APP_RE_ENABLE] once this CL
- // lands: http://codereview.chromium.org/6573003/
- chrome.send('launchApp', [appId, String(APP_LAUNCH.NTP_APP_RE_ENABLE), 0,
- 0, 0, 0, false, false, false, false, 0]);
+ chrome.send('launchApp', [appId, APP_LAUNCH.NTP_APP_RE_ENABLE]);
}
var apps = (function() {
@@ -165,50 +161,15 @@ var apps = (function() {
* the tab's disposition.
*/
function launchApp(appId, opt_mouseEvent) {
- var appsSection = $('apps');
- var expanded = !appsSection.classList.contains('collapsed');
- var element = document.querySelector(
- (expanded ? '.maxiview' : '.miniview') + ' a[app-id=' + appId + ']');
-
- // TODO(arv): Handle zoom?
- var rect = element.getBoundingClientRect();
- var cs = getComputedStyle(element);
- var size = cs.backgroundSize.split(/\s+/); // background-size has the
- // format '123px 456px'.
-
- var width = parseInt(size[0], 10);
- var height = parseInt(size[1], 10);
-
- var top, left;
- if (expanded) {
- // We are using background-position-x 50%.
- top = rect.top + parseInt(cs.backgroundPositionY, 10);
- left = rect.left + ((rect.width - width) >> 1); // Integer divide by 2.
-
- } else {
- // We are using background-position-y 50%.
- top = rect.top + ((rect.height - width) >> 1); // Integer divide by 2.
- if (getComputedStyle(element).direction == 'rtl')
- left = rect.left + rect.width - width;
- else
- left = rect.left;
- }
-
+ var args = [appId, getAppLaunchType()];
if (opt_mouseEvent) {
- // Launch came from a click.
- chrome.send('launchApp', [appId, String(getAppLaunchType()),
- left, top, width, height,
- opt_mouseEvent.altKey, opt_mouseEvent.ctrlKey,
- opt_mouseEvent.metaKey, opt_mouseEvent.shiftKey,
- opt_mouseEvent.button]);
- } else {
- // Launch came from 'command' event from elsewhere in UI.
- chrome.send('launchApp', [appId, String(getAppLaunchType()),
- left, top, width, height,
- false /* altKey */, false /* ctrlKey */,
- false /* metaKey */, false /* shiftKey */,
- 0 /* button */]);
+ // Launch came from a click - add details of the click
+ // Otherwise it came from a 'command' event from elsewhere in the UI.
+ args.push(opt_mouseEvent.altKey, opt_mouseEvent.ctrlKey,
+ opt_mouseEvent.metaKey, opt_mouseEvent.shiftKey,
+ opt_mouseEvent.button);
}
+ chrome.send('launchApp', args);
}
function isAppsMenu(node) {
diff --git a/chrome/browser/ui/webui/app_launcher_handler.cc b/chrome/browser/ui/webui/app_launcher_handler.cc
index 51cd4ac..172c6df 100644
--- a/chrome/browser/ui/webui/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/app_launcher_handler.cc
@@ -37,7 +37,6 @@
#include "grit/generated_resources.h"
#include "net/base/escape.h"
#include "ui/base/animation/animation.h"
-#include "ui/gfx/rect.h"
#include "webkit/glue/window_open_disposition.h"
namespace {
@@ -301,38 +300,28 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) {
void AppLauncherHandler::HandleLaunchApp(const ListValue* args) {
std::string extension_id;
- std::string source;
- double left;
- double top;
- double width;
- double height;
- bool alt_key;
- bool ctrl_key;
- bool meta_key;
- bool shift_key;
- double button;
+ double source = -1.0;
+ bool alt_key = false;
+ bool ctrl_key = false;
+ bool meta_key = false;
+ bool shift_key = false;
+ double button = 0.0;
CHECK(args->GetString(0, &extension_id));
- CHECK(args->GetString(1, &source));
- CHECK(args->GetDouble(2, &left));
- CHECK(args->GetDouble(3, &top));
- CHECK(args->GetDouble(4, &width));
- CHECK(args->GetDouble(5, &height));
- CHECK(args->GetBoolean(6, &alt_key));
- CHECK(args->GetBoolean(7, &ctrl_key));
- CHECK(args->GetBoolean(8, &meta_key));
- CHECK(args->GetBoolean(9, &shift_key));
- CHECK(args->GetDouble(10, &button));
-
- extension_misc::AppLaunchBucket launch_bucket = ParseLaunchSource(source);
-
- // The rect we get from the client is relative to the browser client viewport.
- // Offset the rect by the tab contents bounds.
- gfx::Rect rect(static_cast<int>(left), static_cast<int>(top),
- static_cast<int>(width), static_cast<int>(height));
- gfx::Rect tab_contents_bounds;
- web_ui_->tab_contents()->GetContainerBounds(&tab_contents_bounds);
- rect.Offset(tab_contents_bounds.origin());
+ CHECK(args->GetDouble(1, &source));
+ if (args->GetSize() > 2) {
+ CHECK(args->GetBoolean(2, &alt_key));
+ CHECK(args->GetBoolean(3, &ctrl_key));
+ CHECK(args->GetBoolean(4, &meta_key));
+ CHECK(args->GetBoolean(5, &shift_key));
+ CHECK(args->GetDouble(6, &button));
+ }
+
+ extension_misc::AppLaunchBucket launch_bucket =
+ static_cast<extension_misc::AppLaunchBucket>(
+ static_cast<int>(source));
+ CHECK(launch_bucket >= 0 &&
+ launch_bucket < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY);
const Extension* extension =
extensions_service_->GetExtensionById(extension_id, false);