diff options
author | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 12:04:33 +0000 |
---|---|---|
committer | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 12:04:33 +0000 |
commit | d0c122efd20f7cc8e06d3fe8d35c03bbdca4fa8f (patch) | |
tree | a69cfc124708265fa288cef991a0221803567e0e | |
parent | 387c79251b05f93ac8068674ac213e2e68460b8a (diff) | |
download | chromium_src-d0c122efd20f7cc8e06d3fe8d35c03bbdca4fa8f.zip chromium_src-d0c122efd20f7cc8e06d3fe8d35c03bbdca4fa8f.tar.gz chromium_src-d0c122efd20f7cc8e06d3fe8d35c03bbdca4fa8f.tar.bz2 |
Added --custom-launcher-page. Adds a page to the experimental launcher.
This allows the user to specify a custom web page (which must be in the
chrome-extension:// scheme) which will appear as a third top-level page
in the experimental launcher, alongside the start and apps pages.
This command-line switch is intended to be temporary; eventually,
extensions will be able to specify their own custom launcher pages. For
now, the command-line switch is sufficient for testing.
Most of the Chrome APIs are not yet available for these pages.
BUG=386004
TBR=mukai@chromium.org,jamescook@chromium.org
Review URL: https://codereview.chromium.org/352033002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279685 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/shell/app_list.cc | 4 | ||||
-rw-r--r-- | athena/home/app_list_view_delegate.cc | 5 | ||||
-rw-r--r-- | athena/home/app_list_view_delegate.h | 1 | ||||
-rw-r--r-- | chrome/browser/ui/app_list/app_list_view_delegate.cc | 39 | ||||
-rw-r--r-- | chrome/browser/ui/app_list/app_list_view_delegate.h | 8 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 4 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | ui/app_list/app_list_view_delegate.h | 4 | ||||
-rw-r--r-- | ui/app_list/test/app_list_test_view_delegate.cc | 4 | ||||
-rw-r--r-- | ui/app_list/test/app_list_test_view_delegate.h | 1 | ||||
-rw-r--r-- | ui/app_list/views/contents_view.cc | 5 |
11 files changed, 76 insertions, 0 deletions
diff --git a/ash/shell/app_list.cc b/ash/shell/app_list.cc index df277d0..e396848 100644 --- a/ash/shell/app_list.cc +++ b/ash/shell/app_list.cc @@ -354,6 +354,10 @@ class ExampleAppListViewDelegate : public app_list::AppListViewDelegate { return NULL; } + virtual views::View* CreateCustomPageWebView(const gfx::Size& size) OVERRIDE { + return NULL; + } + virtual bool IsSpeechRecognitionEnabled() OVERRIDE { return false; } diff --git a/athena/home/app_list_view_delegate.cc b/athena/home/app_list_view_delegate.cc index 2bd79ae..2938bf7 100644 --- a/athena/home/app_list_view_delegate.cc +++ b/athena/home/app_list_view_delegate.cc @@ -155,6 +155,11 @@ views::View* AppListViewDelegate::CreateStartPageWebView( return NULL; } +views::View* AppListViewDelegate::CreateCustomPageWebView( + const gfx::Size& size) { + return NULL; +} + bool AppListViewDelegate::IsSpeechRecognitionEnabled() { return false; } diff --git a/athena/home/app_list_view_delegate.h b/athena/home/app_list_view_delegate.h index 752eb78..76c06aa 100644 --- a/athena/home/app_list_view_delegate.h +++ b/athena/home/app_list_view_delegate.h @@ -55,6 +55,7 @@ class AppListViewDelegate : public app_list::AppListViewDelegate { virtual void ShowForProfileByPath( const base::FilePath& profile_path) OVERRIDE; virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE; + virtual views::View* CreateCustomPageWebView(const gfx::Size& size) OVERRIDE; virtual bool IsSpeechRecognitionEnabled() OVERRIDE; virtual const Users& GetUsers() const OVERRIDE; virtual bool ShouldCenterWindow() const OVERRIDE; diff --git a/chrome/browser/ui/app_list/app_list_view_delegate.cc b/chrome/browser/ui/app_list/app_list_view_delegate.cc index 2195fe6..7af49bd 100644 --- a/chrome/browser/ui/app_list/app_list_view_delegate.cc +++ b/chrome/browser/ui/app_list/app_list_view_delegate.cc @@ -7,6 +7,7 @@ #include <vector> #include "base/callback.h" +#include "base/command_line.h" #include "base/files/file_path.h" #include "base/metrics/user_metrics.h" #include "base/stl_util.h" @@ -27,19 +28,23 @@ #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" #include "chrome/browser/web_applications/web_app.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/url_constants.h" #include "components/signin/core/browser/signin_manager.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/page_navigator.h" #include "content/public/browser/user_metrics.h" +#include "content/public/browser/web_contents.h" #include "extensions/browser/extension_registry.h" +#include "extensions/common/constants.h" #include "grit/theme_resources.h" #include "ui/app_list/app_list_switches.h" #include "ui/app_list/app_list_view_delegate_observer.h" #include "ui/app_list/search_box_model.h" #include "ui/app_list/speech_ui_model.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/views/controls/webview/webview.h" #if defined(TOOLKIT_VIEWS) #include "ui/views/controls/webview/webview.h" @@ -144,6 +149,28 @@ AppListViewDelegate::AppListViewDelegate(Profile* profile, OnProfileChanged(); // sets model_ if (service) service->AddObserver(this); + + // Set up the custom launcher page. There is currently only a single custom + // page allowed, which is specified as a command-line flag. In the future, + // arbitrary extensions may be able to specify their own custom pages. + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + if (app_list::switches::IsExperimentalAppListEnabled() && + command_line->HasSwitch(switches::kCustomLauncherPage)) { + GURL custom_launcher_page_url( + command_line->GetSwitchValueASCII(switches::kCustomLauncherPage)); + if (!custom_launcher_page_url.SchemeIs(extensions::kExtensionScheme)) { + LOG(ERROR) << "Invalid custom launcher page URL: " + << custom_launcher_page_url.possibly_invalid_spec(); + } else { + content::WebContents::CreateParams params(profile_); + custom_page_web_contents_.reset(content::WebContents::Create(params)); + custom_page_web_contents_->GetController().LoadURL( + custom_launcher_page_url, + content::Referrer(), + content::PAGE_TRANSITION_AUTO_TOPLEVEL, + std::string()); + } + } } AppListViewDelegate::~AppListViewDelegate() { @@ -451,6 +478,18 @@ views::View* AppListViewDelegate::CreateStartPageWebView( web_view->SetWebContents(web_contents); return web_view; } + +views::View* AppListViewDelegate::CreateCustomPageWebView( + const gfx::Size& size) { + if (!custom_page_web_contents_) + return NULL; + + views::WebView* web_view = new views::WebView( + custom_page_web_contents_->GetBrowserContext()); + web_view->SetPreferredSize(size); + web_view->SetWebContents(custom_page_web_contents_.get()); + return web_view; +} #endif bool AppListViewDelegate::IsSpeechRecognitionEnabled() { diff --git a/chrome/browser/ui/app_list/app_list_view_delegate.h b/chrome/browser/ui/app_list/app_list_view_delegate.h index b6df54d..b5dba63 100644 --- a/chrome/browser/ui/app_list/app_list_view_delegate.h +++ b/chrome/browser/ui/app_list/app_list_view_delegate.h @@ -32,6 +32,10 @@ namespace base { class FilePath; } +namespace content { +class WebContents; +} + namespace gfx { class ImageSkia; } @@ -85,6 +89,7 @@ class AppListViewDelegate : public app_list::AppListViewDelegate, const base::FilePath& profile_path) OVERRIDE; #if defined(TOOLKIT_VIEWS) virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE; + virtual views::View* CreateCustomPageWebView(const gfx::Size& size) OVERRIDE; #endif virtual bool IsSpeechRecognitionEnabled() OVERRIDE; virtual const Users& GetUsers() const OVERRIDE; @@ -149,6 +154,9 @@ class AppListViewDelegate : public app_list::AppListViewDelegate, // this instance can be removed as an observer on its destruction. ScopedObserver<SigninManagerBase, AppListViewDelegate> scoped_observer_; + // Contents of the additional custom launcher page. May be NULL. + scoped_ptr<content::WebContents> custom_page_web_contents_; + DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate); }; diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 3a12539..34c8398 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -189,6 +189,10 @@ const char kCrashOnHangThreads[] = "crash-on-hang-threads"; const char kCreateBrowserOnStartupForTests[] = "create-browser-on-startup-for-tests"; +// Specifies the chrome-extension:// URL for the contents of an additional page +// added to the experimental app launcher. +const char kCustomLauncherPage[] = "custom-launcher-page"; + // Enables a frame context menu item that toggles the frame in and out of glass // mode (Windows Vista and up only). const char kDebugEnableFrameToggle[] = "debug-enable-frame-toggle"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 53c2a9f..6e4b1c9 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -63,6 +63,7 @@ extern const char kCloudPrintSetupProxy[]; extern const char kComponentUpdater[]; extern const char kCrashOnHangThreads[]; extern const char kCreateBrowserOnStartupForTests[]; +extern const char kCustomLauncherPage[]; extern const char kDebugEnableFrameToggle[]; extern const char kDebugPackedApps[]; extern const char kDiagnostics[]; diff --git a/ui/app_list/app_list_view_delegate.h b/ui/app_list/app_list_view_delegate.h index cf6fa53..606e218 100644 --- a/ui/app_list/app_list_view_delegate.h +++ b/ui/app_list/app_list_view_delegate.h @@ -139,6 +139,10 @@ class APP_LIST_EXPORT AppListViewDelegate { // Creates the web view for the start page. The caller takes the ownership of // the returned view. virtual views::View* CreateStartPageWebView(const gfx::Size& size) = 0; + + // Creates the web view for the user-specified custom page. May return NULL. + // The caller takes ownership of the returned view. + virtual views::View* CreateCustomPageWebView(const gfx::Size& size) = 0; #endif // Returns true if the delegate supports speech recognition. diff --git a/ui/app_list/test/app_list_test_view_delegate.cc b/ui/app_list/test/app_list_test_view_delegate.cc index e1380b6..e4044b4 100644 --- a/ui/app_list/test/app_list_test_view_delegate.cc +++ b/ui/app_list/test/app_list_test_view_delegate.cc @@ -96,6 +96,10 @@ views::View* AppListTestViewDelegate::CreateStartPageWebView( const gfx::Size& size) { return NULL; } +views::View* AppListTestViewDelegate::CreateCustomPageWebView( + const gfx::Size& size) { + return NULL; +} #endif bool AppListTestViewDelegate::IsSpeechRecognitionEnabled() { diff --git a/ui/app_list/test/app_list_test_view_delegate.h b/ui/app_list/test/app_list_test_view_delegate.h index 698496c..acf7130 100644 --- a/ui/app_list/test/app_list_test_view_delegate.h +++ b/ui/app_list/test/app_list_test_view_delegate.h @@ -77,6 +77,7 @@ class AppListTestViewDelegate : public AppListViewDelegate { const base::FilePath& profile_path) OVERRIDE {} #if defined(TOOLKIT_VIEWS) virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE; + virtual views::View* CreateCustomPageWebView(const gfx::Size& size) OVERRIDE; #endif virtual bool IsSpeechRecognitionEnabled() OVERRIDE; virtual const Users& GetUsers() const OVERRIDE; diff --git a/ui/app_list/views/contents_view.cc b/ui/app_list/views/contents_view.cc index 1b4e124..3dc588e 100644 --- a/ui/app_list/views/contents_view.cc +++ b/ui/app_list/views/contents_view.cc @@ -53,6 +53,11 @@ void ContentsView::InitNamedPages(AppListModel* model, DCHECK(model); if (app_list::switches::IsExperimentalAppListEnabled()) { + views::View* custom_page_view = + view_delegate->CreateCustomPageWebView(GetLocalBounds().size()); + if (custom_page_view) + AddLauncherPage(custom_page_view, IDR_APP_LIST_NOTIFICATIONS_ICON); + start_page_view_ = new StartPageView(app_list_main_view_, view_delegate); AddLauncherPage( start_page_view_, IDR_APP_LIST_SEARCH_ICON, NAMED_PAGE_START); |