Skip to content

Commit

Permalink
Custom launcher pages: right-click menu is now the platform apps menu.
Browse files Browse the repository at this point in the history
Added new extensions::ViewType, VIEW_TYPE_LAUNCHER_PAGE, which is used
to identify custom launcher page views and give them the platform app
menu. Note that currently some of the menu items have no effect.

Right-clicking on a custom launcher page that is not actually a platform
app results in a DCHECK failure (the --custom-launcher-page switch is a
use-at-your-own-risk switch; this situation will not be possible once we
switch to manifests).

BUG=399123

Review URL: https://codereview.chromium.org/442653002

Cr-Commit-Position: refs/heads/master@{#288670}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288670 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mgiuca@chromium.org committed Aug 11, 2014
1 parent a233aff commit 9faae96
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions apps/custom_launcher_page_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/renderer_preferences.h"
#include "extensions/browser/view_type_utils.h"
#include "extensions/common/extension_messages.h"

namespace apps {
Expand Down Expand Up @@ -45,6 +46,8 @@ void CustomLauncherPageContents::Initialize(content::BrowserContext* context,
context, extension_id_, web_contents_.get(), app_delegate_.get()));
web_contents_->SetDelegate(this);

extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_LAUNCHER_PAGE);

// This observer will activate the extension when it is navigated to, which
// allows Dispatcher to give it the proper context and makes it behave like an
// extension.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ ContextMenuContentType* ContextMenuContentTypeFactory::CreateInternal(

const extensions::ViewType view_type = extensions::GetViewType(web_contents);

if (view_type == extensions::VIEW_TYPE_APP_WINDOW)
if (view_type == extensions::VIEW_TYPE_APP_WINDOW ||
view_type == extensions::VIEW_TYPE_LAUNCHER_PAGE)
return new ContextMenuContentTypePlatformApp(web_contents, params);

if (view_type == extensions::VIEW_TYPE_EXTENSION_POPUP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ void ChromeSpeechRecognitionManagerDelegate::CheckRenderViewType(

if (view_type == extensions::VIEW_TYPE_TAB_CONTENTS ||
view_type == extensions::VIEW_TYPE_APP_WINDOW ||
view_type == extensions::VIEW_TYPE_LAUNCHER_PAGE ||
view_type == extensions::VIEW_TYPE_VIRTUAL_KEYBOARD ||
view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
// If it is a tab, we can check for permission. For apps, this means
Expand Down
1 change: 1 addition & 0 deletions extensions/common/view_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const char kViewTypePanel[] = "PANEL";
const char kViewTypeInfobar[] = "INFOBAR";
const char kViewTypeExtensionDialog[] = "EXTENSION_DIALOG";
const char kViewTypeAppWindow[] = "APP_WINDOW";
const char kViewTypeLauncherPage[] = "LAUNCHER_PAGE";
const char kViewTypeAll[] = "ALL";

} // namespace extensions
2 changes: 2 additions & 0 deletions extensions/common/view_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum ViewType {
VIEW_TYPE_EXTENSION_DIALOG,
VIEW_TYPE_EXTENSION_INFOBAR,
VIEW_TYPE_EXTENSION_POPUP,
VIEW_TYPE_LAUNCHER_PAGE,
VIEW_TYPE_PANEL,
VIEW_TYPE_TAB_CONTENTS,
VIEW_TYPE_VIRTUAL_KEYBOARD,
Expand All @@ -33,6 +34,7 @@ extern const char kViewTypeAppWindow[];
extern const char kViewTypeBackgroundPage[];
extern const char kViewTypeExtensionDialog[];
extern const char kViewTypeInfobar[];
extern const char kViewTypeLauncherPage[];
extern const char kViewTypePanel[];
extern const char kViewTypePopup[];
extern const char kViewTypeTabContents[];
Expand Down
2 changes: 2 additions & 0 deletions extensions/renderer/runtime_custom_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ void RuntimeCustomBindings::GetExtensionViews(
view_type = VIEW_TYPE_EXTENSION_DIALOG;
} else if (view_type_string == kViewTypeAppWindow) {
view_type = VIEW_TYPE_APP_WINDOW;
} else if (view_type_string == kViewTypeLauncherPage) {
view_type = VIEW_TYPE_LAUNCHER_PAGE;
} else if (view_type_string == kViewTypePanel) {
view_type = VIEW_TYPE_PANEL;
} else if (view_type_string != kViewTypeAll) {
Expand Down

0 comments on commit 9faae96

Please sign in to comment.