summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-05 09:00:24 +0000
committercalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-05 09:00:24 +0000
commitc9f983d7b27a3fa08ba1a8034cfe5a8c31868bf0 (patch)
treeb2a6611823bbe37f52425d2ca893f405589f395b
parentfb5af8334aed4203889a37708406430bb359970f (diff)
downloadchromium_src-c9f983d7b27a3fa08ba1a8034cfe5a8c31868bf0.zip
chromium_src-c9f983d7b27a3fa08ba1a8034cfe5a8c31868bf0.tar.gz
chromium_src-c9f983d7b27a3fa08ba1a8034cfe5a8c31868bf0.tar.bz2
Add home button to streamlined hosted apps.
This CL adds a home button to the toolbar when running streamlined hosted apps. The home button will navigate to the browser's initial page which is the launch page of the app. BUG=318607 Review URL: https://codereview.chromium.org/149393002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248934 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/browser_command_controller.cc6
-rw-r--r--chrome/browser/ui/browser_commands.cc21
-rw-r--r--chrome/browser/ui/views/toolbar/toolbar_view.cc11
3 files changed, 33 insertions, 5 deletions
diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc
index 57ea06b..a85a5bc 100644
--- a/chrome/browser/ui/browser_command_controller.cc
+++ b/chrome/browser/ui/browser_command_controller.cc
@@ -969,7 +969,11 @@ void BrowserCommandController::InitCommandState() {
bool normal_window = browser_->is_type_tabbed();
// Navigation commands
- command_updater_.UpdateCommandEnabled(IDC_HOME, normal_window);
+ command_updater_.UpdateCommandEnabled(
+ IDC_HOME,
+ normal_window || (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableStreamlinedHostedApps) &&
+ browser_->is_app()));
// Window management commands
command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window);
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
index 900ed6f..309ee6c 100644
--- a/chrome/browser/ui/browser_commands.cc
+++ b/chrome/browser/ui/browser_commands.cc
@@ -59,6 +59,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/content_restriction.h"
+#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/pref_names.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/devtools_agent_host.h"
@@ -397,8 +398,26 @@ void Home(Browser* browser, WindowOpenDisposition disposition) {
}
#endif
+ GURL url = browser->profile()->GetHomePage();
+
+ // Streamlined hosted apps should return to their launch page when the home
+ // button is pressed.
+ if (browser->is_app()) {
+ const ExtensionService* service = browser->profile()->GetExtensionService();
+ if (!service)
+ return;
+
+ const extensions::Extension* extension =
+ service->GetInstalledExtension(
+ web_app::GetExtensionIdFromApplicationName(browser->app_name()));
+ if (!extension)
+ return;
+
+ url = extensions::AppLaunchInfo::GetLaunchWebURL(extension);
+ }
+
OpenURLParams params(
- browser->profile()->GetHomePage(), Referrer(), disposition,
+ url, Referrer(), disposition,
content::PageTransitionFromInt(
content::PAGE_TRANSITION_AUTO_BOOKMARK |
content::PAGE_TRANSITION_HOME_PAGE),
diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.cc b/chrome/browser/ui/views/toolbar/toolbar_view.cc
index 576cf1c..84fb1ed 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc
@@ -101,6 +101,11 @@ int GetButtonSpacing() {
ToolbarView::kStandardSpacing : 0;
}
+bool IsStreamlinedHostedAppsEnabled() {
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableStreamlinedHostedApps);
+}
+
} // namespace
// static
@@ -129,8 +134,7 @@ ToolbarView::ToolbarView(Browser* browser)
display_mode_ = DISPLAYMODE_LOCATION;
if (browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ||
- (browser->is_app() && CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableStreamlinedHostedApps)))
+ (browser->is_app() && IsStreamlinedHostedAppsEnabled()))
display_mode_ = DISPLAYMODE_NORMAL;
registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
@@ -567,7 +571,8 @@ void ToolbarView::Layout() {
reload_->GetPreferredSize().width(), child_height);
next_element_x = reload_->bounds().right();
- if (show_home_button_.GetValue()) {
+ if (show_home_button_.GetValue() ||
+ (browser_->is_app() && IsStreamlinedHostedAppsEnabled())) {
home_->SetVisible(true);
home_->SetBounds(next_element_x + button_spacing, child_y,
home_->GetPreferredSize().width(), child_height);