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

Side by Side Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 8662051: retry r112077 - recently closed menu: respect middle click (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/extensions/extension_prefs.h" 23 #include "chrome/browser/extensions/extension_prefs.h"
24 #include "chrome/browser/extensions/extension_service.h" 24 #include "chrome/browser/extensions/extension_service.h"
25 #include "chrome/browser/prefs/pref_service.h" 25 #include "chrome/browser/prefs/pref_service.h"
26 #include "chrome/browser/prefs/scoped_user_pref_update.h" 26 #include "chrome/browser/prefs/scoped_user_pref_update.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_list.h" 29 #include "chrome/browser/ui/browser_list.h"
30 #include "chrome/browser/ui/browser_window.h" 30 #include "chrome/browser/ui/browser_window.h"
31 #include "chrome/browser/ui/webui/extension_icon_source.h" 31 #include "chrome/browser/ui/webui/extension_icon_source.h"
32 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 32 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
33 #include "chrome/browser/ui/webui/web_ui_util.h"
33 #include "chrome/common/chrome_notification_types.h" 34 #include "chrome/common/chrome_notification_types.h"
34 #include "chrome/common/extensions/extension.h" 35 #include "chrome/common/extensions/extension.h"
35 #include "chrome/common/extensions/extension_constants.h" 36 #include "chrome/common/extensions/extension_constants.h"
36 #include "chrome/common/extensions/extension_icon_set.h" 37 #include "chrome/common/extensions/extension_icon_set.h"
37 #include "chrome/common/extensions/extension_resource.h" 38 #include "chrome/common/extensions/extension_resource.h"
38 #include "chrome/common/favicon_url.h" 39 #include "chrome/common/favicon_url.h"
39 #include "chrome/common/pref_names.h" 40 #include "chrome/common/pref_names.h"
40 #include "chrome/common/url_constants.h" 41 #include "chrome/common/url_constants.h"
41 #include "chrome/common/web_apps.h" 42 #include "chrome/common/web_apps.h"
42 #include "content/browser/disposition_utils.h"
43 #include "content/browser/tab_contents/tab_contents.h" 43 #include "content/browser/tab_contents/tab_contents.h"
44 #include "content/public/browser/notification_service.h" 44 #include "content/public/browser/notification_service.h"
45 #include "googleurl/src/gurl.h" 45 #include "googleurl/src/gurl.h"
46 #include "grit/browser_resources.h" 46 #include "grit/browser_resources.h"
47 #include "grit/generated_resources.h" 47 #include "grit/generated_resources.h"
48 #include "net/base/escape.h" 48 #include "net/base/escape.h"
49 #include "ui/base/animation/animation.h" 49 #include "ui/base/animation/animation.h"
50 #include "ui/base/l10n/l10n_util.h" 50 #include "ui/base/l10n/l10n_util.h"
51 #include "ui/gfx/codec/png_codec.h" 51 #include "ui/gfx/codec/png_codec.h"
52 #include "webkit/glue/window_open_disposition.h"
53 52
54 namespace { 53 namespace {
55 54
56 const net::UnescapeRule::Type kUnescapeRules = 55 const net::UnescapeRule::Type kUnescapeRules =
57 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS; 56 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS;
58 57
59 extension_misc::AppLaunchBucket ParseLaunchSource( 58 extension_misc::AppLaunchBucket ParseLaunchSource(
60 const std::string& launch_source) { 59 const std::string& launch_source) {
61 int bucket_num = extension_misc::APP_LAUNCH_BUCKET_INVALID; 60 int bucket_num = extension_misc::APP_LAUNCH_BUCKET_INVALID;
62 base::StringToInt(launch_source, &bucket_num); 61 base::StringToInt(launch_source, &bucket_num);
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 content::Source<CrxInstaller>(NULL)); 501 content::Source<CrxInstaller>(NULL));
503 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOAD_ERROR, 502 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOAD_ERROR,
504 content::Source<Profile>(profile)); 503 content::Source<Profile>(profile));
505 } 504 }
506 505
507 has_loaded_apps_ = true; 506 has_loaded_apps_ = true;
508 } 507 }
509 508
510 void AppLauncherHandler::HandleLaunchApp(const ListValue* args) { 509 void AppLauncherHandler::HandleLaunchApp(const ListValue* args) {
511 std::string extension_id; 510 std::string extension_id;
511 CHECK(args->GetString(0, &extension_id));
512 double source = -1.0; 512 double source = -1.0;
513 CHECK(args->GetDouble(1, &source));
513 std::string url; 514 std::string url;
514 bool alt_key = false;
515 bool ctrl_key = false;
516 bool meta_key = false;
517 bool shift_key = false;
518 double button = 0.0;
519
520 CHECK(args->GetString(0, &extension_id));
521 CHECK(args->GetDouble(1, &source));
522 if (args->GetSize() > 2) 515 if (args->GetSize() > 2)
523 CHECK(args->GetString(2, &url)); 516 CHECK(args->GetString(2, &url));
524 if (args->GetSize() > 3) {
525 CHECK(args->GetBoolean(3, &alt_key));
526 CHECK(args->GetBoolean(4, &ctrl_key));
527 CHECK(args->GetBoolean(5, &meta_key));
528 CHECK(args->GetBoolean(6, &shift_key));
529 CHECK(args->GetDouble(7, &button));
530 }
531 517
532 extension_misc::AppLaunchBucket launch_bucket = 518 extension_misc::AppLaunchBucket launch_bucket =
533 static_cast<extension_misc::AppLaunchBucket>( 519 static_cast<extension_misc::AppLaunchBucket>(
534 static_cast<int>(source)); 520 static_cast<int>(source));
535 CHECK(launch_bucket >= 0 && 521 CHECK(launch_bucket >= 0 &&
536 launch_bucket < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY); 522 launch_bucket < extension_misc::APP_LAUNCH_BUCKET_BOUNDARY);
537 523
538 const Extension* extension = 524 const Extension* extension =
539 extension_service_->GetExtensionById(extension_id, false); 525 extension_service_->GetExtensionById(extension_id, false);
540 526
541 // Prompt the user to re-enable the application if disabled. 527 // Prompt the user to re-enable the application if disabled.
542 if (!extension) { 528 if (!extension) {
543 PromptToEnableApp(extension_id); 529 PromptToEnableApp(extension_id);
544 return; 530 return;
545 } 531 }
546 532
547 Profile* profile = extension_service_->profile(); 533 Profile* profile = extension_service_->profile();
548 534
549 // If the user pressed special keys when clicking, override the saved 535 WindowOpenDisposition disposition = args->GetSize() > 3 ?
550 // preference for launch container. 536 web_ui_util::GetDispositionFromClick(args, 3) : CURRENT_TAB;
551 bool middle_button = (button == 1.0);
552 WindowOpenDisposition disposition =
553 disposition_utils::DispositionFromClick(middle_button, alt_key,
554 ctrl_key, meta_key, shift_key);
555
556 if (extension_id != extension_misc::kWebStoreAppId) { 537 if (extension_id != extension_misc::kWebStoreAppId) {
557 RecordAppLaunchByID(launch_bucket); 538 RecordAppLaunchByID(launch_bucket);
558 extension_service_->apps_promo()->ExpireDefaultApps(); 539 extension_service_->apps_promo()->ExpireDefaultApps();
559 } else if (NewTabUI::NTP4Enabled()) { 540 } else if (NewTabUI::NTP4Enabled()) {
560 RecordWebStoreLaunch(url.find("chrome-ntp-promo") != std::string::npos); 541 RecordWebStoreLaunch(url.find("chrome-ntp-promo") != std::string::npos);
561 } 542 }
562 543
563 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { 544 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) {
564 // TODO(jamescook): Proper support for background tabs. 545 // TODO(jamescook): Proper support for background tabs.
565 Browser::OpenApplication( 546 Browser::OpenApplication(
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 976
996 void AppLauncherHandler::UninstallDefaultApps() { 977 void AppLauncherHandler::UninstallDefaultApps() {
997 AppsPromo* apps_promo = extension_service_->apps_promo(); 978 AppsPromo* apps_promo = extension_service_->apps_promo();
998 const ExtensionIdSet& app_ids = apps_promo->old_default_apps(); 979 const ExtensionIdSet& app_ids = apps_promo->old_default_apps();
999 for (ExtensionIdSet::const_iterator iter = app_ids.begin(); 980 for (ExtensionIdSet::const_iterator iter = app_ids.begin();
1000 iter != app_ids.end(); ++iter) { 981 iter != app_ids.end(); ++iter) {
1001 if (extension_service_->GetExtensionById(*iter, true)) 982 if (extension_service_->GetExtensionById(*iter, true))
1002 extension_service_->UninstallExtension(*iter, false, NULL); 983 extension_service_->UninstallExtension(*iter, false, NULL);
1003 } 984 }
1004 } 985 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/global_history_menu.cc ('k') | chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698