| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "chrome/browser/extensions/extension_prefs.h" | 9 #include "chrome/browser/extensions/extension_prefs.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/extension_system.h" | 11 #include "chrome/browser/extensions/extension_system.h" |
| 12 #include "chrome/browser/extensions/platform_app_launcher.h" | 12 #include "chrome/browser/extensions/platform_app_launcher.h" |
| 13 #include "chrome/browser/extensions/tab_helper.h" | 13 #include "chrome/browser/extensions/tab_helper.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 17 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
| 18 #include "chrome/browser/ui/browser_tabstrip.h" | 18 #include "chrome/browser/ui/browser_tabstrip.h" |
| 19 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/browser/web_applications/web_app.h" | 21 #include "chrome/browser/web_applications/web_app.h" |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/extensions/app_launch_manifest_handler.h" |
| 23 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 24 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
| 25 #include "chrome/common/extensions/manifest_url_handler.h" | 26 #include "chrome/common/extensions/manifest_url_handler.h" |
| 26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 27 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
| 28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 29 #include "content/public/browser/web_contents_view.h" | 30 #include "content/public/browser/web_contents_view.h" |
| 30 #include "content/public/common/renderer_preferences.h" | 31 #include "content/public/common/renderer_preferences.h" |
| 31 #include "ui/base/window_open_disposition.h" | 32 #include "ui/base/window_open_disposition.h" |
| 32 #include "ui/gfx/rect.h" | 33 #include "ui/gfx/rect.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 52 const GURL& override_url) { | 53 const GURL& override_url) { |
| 53 if (!extension) | 54 if (!extension) |
| 54 return override_url; | 55 return override_url; |
| 55 | 56 |
| 56 GURL url; | 57 GURL url; |
| 57 if (!override_url.is_empty()) { | 58 if (!override_url.is_empty()) { |
| 58 DCHECK(extension->web_extent().MatchesURL(override_url) || | 59 DCHECK(extension->web_extent().MatchesURL(override_url) || |
| 59 override_url.GetOrigin() == extension->url()); | 60 override_url.GetOrigin() == extension->url()); |
| 60 url = override_url; | 61 url = override_url; |
| 61 } else { | 62 } else { |
| 62 url = extension->GetFullLaunchURL(); | 63 url = extensions::AppLaunchInfo::GetFullLaunchURL(extension); |
| 63 } | 64 } |
| 64 | 65 |
| 65 // For extensions lacking launch urls, determine a reasonable fallback. | 66 // For extensions lacking launch urls, determine a reasonable fallback. |
| 66 if (!url.is_valid()) { | 67 if (!url.is_valid()) { |
| 67 url = extensions::ManifestURL::GetOptionsPage(extension); | 68 url = extensions::ManifestURL::GetOptionsPage(extension); |
| 68 if (!url.is_valid()) | 69 if (!url.is_valid()) |
| 69 url = GURL(chrome::kChromeUIExtensionsURL); | 70 url = GURL(chrome::kChromeUIExtensionsURL); |
| 70 } | 71 } |
| 71 | 72 |
| 72 return url; | 73 return url; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 84 | 85 |
| 85 std::string app_name; | 86 std::string app_name; |
| 86 app_name = extension ? | 87 app_name = extension ? |
| 87 web_app::GenerateApplicationNameFromExtensionId(extension->id()) : | 88 web_app::GenerateApplicationNameFromExtensionId(extension->id()) : |
| 88 web_app::GenerateApplicationNameFromURL(url); | 89 web_app::GenerateApplicationNameFromURL(url); |
| 89 | 90 |
| 90 Browser::Type type = Browser::TYPE_POPUP; | 91 Browser::Type type = Browser::TYPE_POPUP; |
| 91 | 92 |
| 92 gfx::Rect window_bounds; | 93 gfx::Rect window_bounds; |
| 93 if (extension) { | 94 if (extension) { |
| 94 window_bounds.set_width(extension->launch_width()); | 95 window_bounds.set_width( |
| 95 window_bounds.set_height(extension->launch_height()); | 96 extensions::AppLaunchInfo::GetLaunchWidth(extension)); |
| 97 window_bounds.set_height( |
| 98 extensions::AppLaunchInfo::GetLaunchHeight(extension)); |
| 96 } else if (!override_bounds.IsEmpty()) { | 99 } else if (!override_bounds.IsEmpty()) { |
| 97 window_bounds = override_bounds; | 100 window_bounds = override_bounds; |
| 98 } | 101 } |
| 99 | 102 |
| 100 Browser::CreateParams params(type, profile, chrome::GetActiveDesktop()); | 103 Browser::CreateParams params(type, profile, chrome::GetActiveDesktop()); |
| 101 params.app_name = app_name; | 104 params.app_name = app_name; |
| 102 params.initial_bounds = window_bounds; | 105 params.initial_bounds = window_bounds; |
| 103 | 106 |
| 104 #if defined(USE_ASH) | 107 #if defined(USE_ASH) |
| 105 if (extension && | 108 if (extension && |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 // OnDidGetApplicationInfo, which calls | 365 // OnDidGetApplicationInfo, which calls |
| 363 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as | 366 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as |
| 364 // pending web app action. | 367 // pending web app action. |
| 365 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( | 368 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( |
| 366 extensions::TabHelper::UPDATE_SHORTCUT); | 369 extensions::TabHelper::UPDATE_SHORTCUT); |
| 367 | 370 |
| 368 return tab; | 371 return tab; |
| 369 } | 372 } |
| 370 | 373 |
| 371 } // namespace chrome | 374 } // namespace chrome |
| OLD | NEW |