| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/browser_commands.h" | 5 #include "chrome/browser/ui/browser_commands.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_utils.h" | 14 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 17 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 18 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
| 19 #include "chrome/browser/chrome_page_zoom.h" | 19 #include "chrome/browser/chrome_page_zoom.h" |
| 20 #include "chrome/browser/devtools/devtools_window.h" | 20 #include "chrome/browser/devtools/devtools_window.h" |
| 21 #include "chrome/browser/extensions/api/commands/command_service.h" | 21 #include "chrome/browser/extensions/api/commands/command_service.h" |
| 22 #include "chrome/browser/extensions/extension_service.h" | |
| 23 #include "chrome/browser/extensions/tab_helper.h" | 22 #include "chrome/browser/extensions/tab_helper.h" |
| 24 #include "chrome/browser/favicon/favicon_tab_helper.h" | 23 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 25 #include "chrome/browser/google/google_util.h" | 24 #include "chrome/browser/google/google_util.h" |
| 26 #include "chrome/browser/lifetime/application_lifetime.h" | 25 #include "chrome/browser/lifetime/application_lifetime.h" |
| 27 #include "chrome/browser/platform_util.h" | 26 #include "chrome/browser/platform_util.h" |
| 28 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 27 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/rlz/rlz.h" | 29 #include "chrome/browser/rlz/rlz.h" |
| 31 #include "chrome/browser/search/search.h" | 30 #include "chrome/browser/search/search.h" |
| 32 #include "chrome/browser/sessions/session_service_factory.h" | 31 #include "chrome/browser/sessions/session_service_factory.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 #include "content/public/browser/page_navigator.h" | 70 #include "content/public/browser/page_navigator.h" |
| 72 #include "content/public/browser/render_view_host.h" | 71 #include "content/public/browser/render_view_host.h" |
| 73 #include "content/public/browser/render_widget_host_view.h" | 72 #include "content/public/browser/render_widget_host_view.h" |
| 74 #include "content/public/browser/user_metrics.h" | 73 #include "content/public/browser/user_metrics.h" |
| 75 #include "content/public/browser/web_contents.h" | 74 #include "content/public/browser/web_contents.h" |
| 76 #include "content/public/browser/web_contents_view.h" | 75 #include "content/public/browser/web_contents_view.h" |
| 77 #include "content/public/common/renderer_preferences.h" | 76 #include "content/public/common/renderer_preferences.h" |
| 78 #include "content/public/common/url_constants.h" | 77 #include "content/public/common/url_constants.h" |
| 79 #include "content/public/common/url_utils.h" | 78 #include "content/public/common/url_utils.h" |
| 80 #include "content/public/common/user_agent.h" | 79 #include "content/public/common/user_agent.h" |
| 81 #include "extensions/browser/extension_system.h" | 80 #include "extensions/browser/extension_registry.h" |
| 81 #include "extensions/common/extension.h" |
| 82 #include "extensions/common/extension_set.h" |
| 82 #include "net/base/escape.h" | 83 #include "net/base/escape.h" |
| 83 #include "ui/events/keycodes/keyboard_codes.h" | 84 #include "ui/events/keycodes/keyboard_codes.h" |
| 84 | 85 |
| 85 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
| 86 #include "chrome/browser/ui/metro_pin_tab_helper_win.h" | 87 #include "chrome/browser/ui/metro_pin_tab_helper_win.h" |
| 87 #include "win8/util/win8_util.h" | 88 #include "win8/util/win8_util.h" |
| 88 #endif | 89 #endif |
| 89 | 90 |
| 90 #if defined(ENABLE_PRINTING) | 91 #if defined(ENABLE_PRINTING) |
| 91 #if defined(ENABLE_FULL_PRINTING) | 92 #if defined(ENABLE_FULL_PRINTING) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 DCHECK(command); | 134 DCHECK(command); |
| 134 DCHECK(command_type); | 135 DCHECK(command_type); |
| 135 | 136 |
| 136 ui::Accelerator bookmark_page_accelerator = | 137 ui::Accelerator bookmark_page_accelerator = |
| 137 chrome::GetPrimaryChromeAcceleratorForCommandId(IDC_BOOKMARK_PAGE); | 138 chrome::GetPrimaryChromeAcceleratorForCommandId(IDC_BOOKMARK_PAGE); |
| 138 if (bookmark_page_accelerator.key_code() == ui::VKEY_UNKNOWN) | 139 if (bookmark_page_accelerator.key_code() == ui::VKEY_UNKNOWN) |
| 139 return false; | 140 return false; |
| 140 | 141 |
| 141 extensions::CommandService* command_service = | 142 extensions::CommandService* command_service = |
| 142 extensions::CommandService::Get(profile); | 143 extensions::CommandService::Get(profile); |
| 143 ExtensionService* extension_service = | 144 const extensions::ExtensionSet& extension_set = |
| 144 extensions::ExtensionSystem::Get(profile)->extension_service(); | 145 extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); |
| 145 // Extension service may be NULL during test execution. | 146 for (extensions::ExtensionSet::const_iterator i = extension_set.begin(); |
| 146 if (!extension_service) | 147 i != extension_set.end(); |
| 147 return false; | 148 ++i) { |
| 148 const extensions::ExtensionSet* extension_set = | |
| 149 extension_service->extensions(); | |
| 150 for (extensions::ExtensionSet::const_iterator i = extension_set->begin(); | |
| 151 i != extension_set->end(); ++i) { | |
| 152 extensions::Command prospective_command; | 149 extensions::Command prospective_command; |
| 153 extensions::CommandService::ExtensionCommandType prospective_command_type; | 150 extensions::CommandService::ExtensionCommandType prospective_command_type; |
| 154 if (command_service->GetBoundExtensionCommand((*i)->id(), | 151 if (command_service->GetBoundExtensionCommand((*i)->id(), |
| 155 bookmark_page_accelerator, | 152 bookmark_page_accelerator, |
| 156 &prospective_command, | 153 &prospective_command, |
| 157 &prospective_command_type)) { | 154 &prospective_command_type)) { |
| 158 *extension = i->get(); | 155 *extension = i->get(); |
| 159 *command = prospective_command; | 156 *command = prospective_command; |
| 160 *command_type = prospective_command_type; | 157 *command_type = prospective_command_type; |
| 161 return true; | 158 return true; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 RLZTracker::CHROME_HOME_PAGE); | 455 RLZTracker::CHROME_HOME_PAGE); |
| 459 } | 456 } |
| 460 } | 457 } |
| 461 #endif | 458 #endif |
| 462 | 459 |
| 463 GURL url = browser->profile()->GetHomePage(); | 460 GURL url = browser->profile()->GetHomePage(); |
| 464 | 461 |
| 465 // Streamlined hosted apps should return to their launch page when the home | 462 // Streamlined hosted apps should return to their launch page when the home |
| 466 // button is pressed. | 463 // button is pressed. |
| 467 if (browser->is_app()) { | 464 if (browser->is_app()) { |
| 468 const ExtensionService* service = browser->profile()->GetExtensionService(); | |
| 469 if (!service) | |
| 470 return; | |
| 471 | |
| 472 const extensions::Extension* extension = | 465 const extensions::Extension* extension = |
| 473 service->GetInstalledExtension( | 466 extensions::ExtensionRegistry::Get(browser->profile()) |
| 474 web_app::GetExtensionIdFromApplicationName(browser->app_name())); | 467 ->GetExtensionById( |
| 468 web_app::GetExtensionIdFromApplicationName(browser->app_name()), |
| 469 extensions::ExtensionRegistry::EVERYTHING); |
| 475 if (!extension) | 470 if (!extension) |
| 476 return; | 471 return; |
| 477 | 472 |
| 478 url = extensions::AppLaunchInfo::GetLaunchWebURL(extension); | 473 url = extensions::AppLaunchInfo::GetLaunchWebURL(extension); |
| 479 } | 474 } |
| 480 | 475 |
| 481 OpenURLParams params( | 476 OpenURLParams params( |
| 482 url, Referrer(), disposition, | 477 url, Referrer(), disposition, |
| 483 content::PageTransitionFromInt( | 478 content::PageTransitionFromInt( |
| 484 content::PAGE_TRANSITION_AUTO_BOOKMARK | | 479 content::PAGE_TRANSITION_AUTO_BOOKMARK | |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least | 514 // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least |
| 520 // inherit the opener. In some cases the tabstrip will determine the group | 515 // inherit the opener. In some cases the tabstrip will determine the group |
| 521 // should be inherited, in which case the group is inherited instead of the | 516 // should be inherited, in which case the group is inherited instead of the |
| 522 // opener. | 517 // opener. |
| 523 params.tabstrip_add_types = | 518 params.tabstrip_add_types = |
| 524 TabStripModel::ADD_FORCE_INDEX | TabStripModel::ADD_INHERIT_OPENER; | 519 TabStripModel::ADD_FORCE_INDEX | TabStripModel::ADD_INHERIT_OPENER; |
| 525 Navigate(¶ms); | 520 Navigate(¶ms); |
| 526 | 521 |
| 527 DCHECK(browser->profile()->GetExtensionService()); | 522 DCHECK(browser->profile()->GetExtensionService()); |
| 528 const extensions::Extension* extension = | 523 const extensions::Extension* extension = |
| 529 browser->profile()->GetExtensionService()->GetInstalledApp(url); | 524 extensions::ExtensionRegistry::Get(browser->profile()) |
| 525 ->enabled_extensions().GetAppByURL(url); |
| 530 if (extension) { | 526 if (extension) { |
| 531 CoreAppLauncherHandler::RecordAppLaunchType( | 527 CoreAppLauncherHandler::RecordAppLaunchType( |
| 532 extension_misc::APP_LAUNCH_OMNIBOX_LOCATION, | 528 extension_misc::APP_LAUNCH_OMNIBOX_LOCATION, |
| 533 extension->GetType()); | 529 extension->GetType()); |
| 534 } | 530 } |
| 535 } | 531 } |
| 536 | 532 |
| 537 void Stop(Browser* browser) { | 533 void Stop(Browser* browser) { |
| 538 content::RecordAction(UserMetricsAction("Stop")); | 534 content::RecordAction(UserMetricsAction("Stop")); |
| 539 browser->tab_strip_model()->GetActiveWebContents()->Stop(); | 535 browser->tab_strip_model()->GetActiveWebContents()->Stop(); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile(), | 1259 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile(), |
| 1264 browser->host_desktop_type())); | 1260 browser->host_desktop_type())); |
| 1265 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1261 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
| 1266 | 1262 |
| 1267 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1263 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1268 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1264 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1269 app_browser->window()->Show(); | 1265 app_browser->window()->Show(); |
| 1270 } | 1266 } |
| 1271 | 1267 |
| 1272 } // namespace chrome | 1268 } // namespace chrome |
| OLD | NEW |