| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/extensions/application_launch.h" | 5 #include "chrome/browser/ui/extensions/application_launch.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "chrome/browser/app_mode/app_mode_utils.h" | 11 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 12 #include "chrome/browser/extensions/extension_prefs.h" | 12 #include "chrome/browser/extensions/extension_prefs.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/extension_system.h" | 14 #include "chrome/browser/extensions/extension_system.h" |
| 15 #include "chrome/browser/extensions/platform_app_launcher.h" | 15 #include "chrome/browser/extensions/platform_app_launcher.h" |
| 16 #include "chrome/browser/extensions/tab_helper.h" | 16 #include "chrome/browser/extensions/tab_helper.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_commands.h" | 19 #include "chrome/browser/ui/browser_commands.h" |
| 20 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 21 #include "chrome/browser/ui/browser_tabstrip.h" | 21 #include "chrome/browser/ui/browser_tabstrip.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/browser/ui/host_desktop.h" | 23 #include "chrome/browser/ui/host_desktop.h" |
| 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 25 #include "chrome/browser/web_applications/web_app.h" | 25 #include "chrome/browser/web_applications/web_app.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/extensions/app_launcher_info.h" |
| 27 #include "chrome/common/extensions/extension.h" | 28 #include "chrome/common/extensions/extension.h" |
| 28 #include "chrome/common/extensions/extension_constants.h" | 29 #include "chrome/common/extensions/extension_constants.h" |
| 29 #include "chrome/common/extensions/manifest_url_handler.h" | 30 #include "chrome/common/extensions/manifest_url_handler.h" |
| 30 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 31 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
| 32 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 33 #include "content/public/browser/web_contents_view.h" | 34 #include "content/public/browser/web_contents_view.h" |
| 34 #include "content/public/common/renderer_preferences.h" | 35 #include "content/public/common/renderer_preferences.h" |
| 35 #include "ui/base/window_open_disposition.h" | 36 #include "ui/base/window_open_disposition.h" |
| 36 #include "ui/gfx/rect.h" | 37 #include "ui/gfx/rect.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 56 const GURL& override_url) { | 57 const GURL& override_url) { |
| 57 if (!extension) | 58 if (!extension) |
| 58 return override_url; | 59 return override_url; |
| 59 | 60 |
| 60 GURL url; | 61 GURL url; |
| 61 if (!override_url.is_empty()) { | 62 if (!override_url.is_empty()) { |
| 62 DCHECK(extension->web_extent().MatchesURL(override_url) || | 63 DCHECK(extension->web_extent().MatchesURL(override_url) || |
| 63 override_url.GetOrigin() == extension->url()); | 64 override_url.GetOrigin() == extension->url()); |
| 64 url = override_url; | 65 url = override_url; |
| 65 } else { | 66 } else { |
| 66 url = extension->GetFullLaunchURL(); | 67 url = extensions::AppLauncherInfo::GetFullLaunchURL(extension); |
| 67 } | 68 } |
| 68 | 69 |
| 69 // For extensions lacking launch urls, determine a reasonable fallback. | 70 // For extensions lacking launch urls, determine a reasonable fallback. |
| 70 if (!url.is_valid()) { | 71 if (!url.is_valid()) { |
| 71 url = extensions::ManifestURL::GetOptionsPage(extension); | 72 url = extensions::ManifestURL::GetOptionsPage(extension); |
| 72 if (!url.is_valid()) | 73 if (!url.is_valid()) |
| 73 url = GURL(chrome::kChromeUIExtensionsURL); | 74 url = GURL(chrome::kChromeUIExtensionsURL); |
| 74 } | 75 } |
| 75 | 76 |
| 76 return url; | 77 return url; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 118 |
| 118 std::string app_name; | 119 std::string app_name; |
| 119 app_name = extension ? | 120 app_name = extension ? |
| 120 web_app::GenerateApplicationNameFromExtensionId(extension->id()) : | 121 web_app::GenerateApplicationNameFromExtensionId(extension->id()) : |
| 121 web_app::GenerateApplicationNameFromURL(url); | 122 web_app::GenerateApplicationNameFromURL(url); |
| 122 | 123 |
| 123 Browser::Type type = Browser::TYPE_POPUP; | 124 Browser::Type type = Browser::TYPE_POPUP; |
| 124 | 125 |
| 125 gfx::Rect window_bounds; | 126 gfx::Rect window_bounds; |
| 126 if (extension) { | 127 if (extension) { |
| 127 window_bounds.set_width(extension->launch_width()); | 128 window_bounds.set_width( |
| 128 window_bounds.set_height(extension->launch_height()); | 129 extensions::AppLauncherInfo::GetLaunchWidth(extension)); |
| 130 window_bounds.set_height( |
| 131 extensions::AppLauncherInfo::GetLaunchHeight(extension)); |
| 129 } | 132 } |
| 130 if (!override_bounds.IsEmpty()) | 133 if (!override_bounds.IsEmpty()) |
| 131 window_bounds = override_bounds; | 134 window_bounds = override_bounds; |
| 132 | 135 |
| 133 Browser::CreateParams params(type, profile, chrome::GetActiveDesktop()); | 136 Browser::CreateParams params(type, profile, chrome::GetActiveDesktop()); |
| 134 params.app_name = app_name; | 137 params.app_name = app_name; |
| 135 params.initial_bounds = window_bounds; | 138 params.initial_bounds = window_bounds; |
| 136 params.initial_show_state = DetermineWindowShowState(profile, | 139 params.initial_show_state = DetermineWindowShowState(profile, |
| 137 container, | 140 container, |
| 138 extension); | 141 extension); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 // OnDidGetApplicationInfo, which calls | 390 // OnDidGetApplicationInfo, which calls |
| 388 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as | 391 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as |
| 389 // pending web app action. | 392 // pending web app action. |
| 390 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( | 393 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( |
| 391 extensions::TabHelper::UPDATE_SHORTCUT); | 394 extensions::TabHelper::UPDATE_SHORTCUT); |
| 392 | 395 |
| 393 return tab; | 396 return tab; |
| 394 } | 397 } |
| 395 | 398 |
| 396 } // namespace chrome | 399 } // namespace chrome |
| OLD | NEW |