summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-12 15:18:55 +0000
committermgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-12 15:20:40 +0000
commit9b770aef7f564353654f3eec70e599ece6692955 (patch)
treec7deea2db2c5e0852b293b0c1436b6351962232f
parentdb0f0c91630189937fd7cc627c2e6766fa8783ba (diff)
downloadchromium_src-9b770aef7f564353654f3eec70e599ece6692955.zip
chromium_src-9b770aef7f564353654f3eec70e599ece6692955.tar.gz
chromium_src-9b770aef7f564353654f3eec70e599ece6692955.tar.bz2
App list: Infrastructure now supports multiple custom launcher pages.
AppListTestViewDelegate::CreateCustomPageWebViews now returns a vector of views, not a single view. AppListViewDelegate is now able to generate multiple custom launcher pages which will all be inserted into the launcher (but currently only ever produces a single one, from the --custom-launcher-page switch). BUG=399131 Review URL: https://codereview.chromium.org/441873004 Cr-Commit-Position: refs/heads/master@{#288975} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288975 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/shell/app_list.cc6
-rw-r--r--athena/home/app_list_view_delegate.cc5
-rw-r--r--athena/home/app_list_view_delegate.h3
-rw-r--r--chrome/browser/ui/app_list/app_list_view_delegate.cc80
-rw-r--r--chrome/browser/ui/app_list/app_list_view_delegate.h8
-rw-r--r--ui/app_list/app_list_view_delegate.h7
-rw-r--r--ui/app_list/test/app_list_test_view_delegate.cc5
-rw-r--r--ui/app_list/test/app_list_test_view_delegate.h3
-rw-r--r--ui/app_list/views/contents_view.cc13
9 files changed, 84 insertions, 46 deletions
diff --git a/ash/shell/app_list.cc b/ash/shell/app_list.cc
index f835153..1d8eb80 100644
--- a/ash/shell/app_list.cc
+++ b/ash/shell/app_list.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <string>
+#include <vector>
#include "ash/session/session_state_delegate.h"
#include "ash/shell.h"
@@ -353,8 +354,9 @@ class ExampleAppListViewDelegate : public app_list::AppListViewDelegate {
return NULL;
}
- virtual views::View* CreateCustomPageWebView(const gfx::Size& size) OVERRIDE {
- return NULL;
+ virtual std::vector<views::View*> CreateCustomPageWebViews(
+ const gfx::Size& size) OVERRIDE {
+ return std::vector<views::View*>();
}
virtual bool IsSpeechRecognitionEnabled() OVERRIDE {
diff --git a/athena/home/app_list_view_delegate.cc b/athena/home/app_list_view_delegate.cc
index 5180022..c867364 100644
--- a/athena/home/app_list_view_delegate.cc
+++ b/athena/home/app_list_view_delegate.cc
@@ -5,6 +5,7 @@
#include "athena/home/app_list_view_delegate.h"
#include <string>
+#include <vector>
#include "athena/home/public/app_model_builder.h"
#include "base/basictypes.h"
@@ -184,9 +185,9 @@ views::View* AppListViewDelegate::CreateStartPageWebView(
return new DummyLogoView(size);
}
-views::View* AppListViewDelegate::CreateCustomPageWebView(
+std::vector<views::View*> AppListViewDelegate::CreateCustomPageWebViews(
const gfx::Size& size) {
- return NULL;
+ return std::vector<views::View*>();
}
bool AppListViewDelegate::IsSpeechRecognitionEnabled() {
diff --git a/athena/home/app_list_view_delegate.h b/athena/home/app_list_view_delegate.h
index 76c06aa..7ea9240 100644
--- a/athena/home/app_list_view_delegate.h
+++ b/athena/home/app_list_view_delegate.h
@@ -55,7 +55,8 @@ 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 std::vector<views::View*> CreateCustomPageWebViews(
+ 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 25180a0..7e7a94b 100644
--- a/chrome/browser/ui/app_list/app_list_view_delegate.cc
+++ b/chrome/browser/ui/app_list/app_list_view_delegate.cc
@@ -103,6 +103,29 @@ void PopulateUsers(const ProfileInfoCache& profile_info,
}
}
+// Gets a list of URLs of the custom launcher pages to show in the launcher.
+// Returns a URL for each installed launcher page. If --custom-launcher-page is
+// specified and valid, also includes that URL.
+void GetCustomLauncherPageUrls(std::vector<GURL>* urls) {
+ // First, check the command line.
+ 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)) {
+ urls->push_back(custom_launcher_page_url);
+ } else {
+ LOG(ERROR) << "Invalid custom launcher page URL: "
+ << custom_launcher_page_url.possibly_invalid_spec();
+ }
+ }
+
+ // TODO(mgiuca): Search the list of installed extensions and add any with a
+ // 'launcher_page' attribute in its manifest.
+}
+
} // namespace
AppListViewDelegate::AppListViewDelegate(Profile* profile,
@@ -148,23 +171,18 @@ AppListViewDelegate::AppListViewDelegate(Profile* profile,
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 {
- std::string extension_id = custom_launcher_page_url.host();
- custom_page_contents_.reset(new apps::CustomLauncherPageContents(
- scoped_ptr<apps::AppDelegate>(new ChromeAppDelegate), extension_id));
- custom_page_contents_->Initialize(profile, custom_launcher_page_url);
- }
+ // Set up the custom launcher pages.
+ std::vector<GURL> custom_launcher_page_urls;
+ GetCustomLauncherPageUrls(&custom_launcher_page_urls);
+ for (std::vector<GURL>::const_iterator it = custom_launcher_page_urls.begin();
+ it != custom_launcher_page_urls.end();
+ ++it) {
+ std::string extension_id = it->host();
+ apps::CustomLauncherPageContents* page_contents =
+ new apps::CustomLauncherPageContents(
+ scoped_ptr<apps::AppDelegate>(new ChromeAppDelegate), extension_id);
+ page_contents->Initialize(profile, *it);
+ custom_page_contents_.push_back(page_contents);
}
}
@@ -475,19 +493,25 @@ views::View* AppListViewDelegate::CreateStartPageWebView(
return web_view;
}
-views::View* AppListViewDelegate::CreateCustomPageWebView(
+std::vector<views::View*> AppListViewDelegate::CreateCustomPageWebViews(
const gfx::Size& size) {
- if (!custom_page_contents_)
- return NULL;
+ std::vector<views::View*> web_views;
+
+ for (ScopedVector<apps::CustomLauncherPageContents>::const_iterator it =
+ custom_page_contents_.begin();
+ it != custom_page_contents_.end();
+ ++it) {
+ content::WebContents* web_contents = (*it)->web_contents();
+ // TODO(mgiuca): DCHECK_EQ(profile_, web_contents->GetBrowserContext())
+ // after http://crbug.com/392763 resolved.
+ views::WebView* web_view =
+ new views::WebView(web_contents->GetBrowserContext());
+ web_view->SetPreferredSize(size);
+ web_view->SetWebContents(web_contents);
+ web_views.push_back(web_view);
+ }
- content::WebContents* web_contents = custom_page_contents_->web_contents();
- // TODO(mgiuca): DCHECK_EQ(profile_, web_contents->GetBrowserContext()) after
- // http://crbug.com/392763 resolved.
- views::WebView* web_view =
- new views::WebView(web_contents->GetBrowserContext());
- web_view->SetPreferredSize(size);
- web_view->SetWebContents(web_contents);
- return web_view;
+ return web_views;
}
#endif
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 31899f9..ec67e74 100644
--- a/chrome/browser/ui/app_list/app_list_view_delegate.h
+++ b/chrome/browser/ui/app_list/app_list_view_delegate.h
@@ -11,6 +11,7 @@
#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "base/observer_list.h"
#include "base/scoped_observer.h"
#include "chrome/browser/profiles/profile_info_cache_observer.h"
@@ -89,7 +90,8 @@ 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;
+ virtual std::vector<views::View*> CreateCustomPageWebViews(
+ const gfx::Size& size) OVERRIDE;
#endif
virtual bool IsSpeechRecognitionEnabled() OVERRIDE;
virtual const Users& GetUsers() const OVERRIDE;
@@ -154,8 +156,8 @@ class AppListViewDelegate : public app_list::AppListViewDelegate,
// this instance can be removed as an observer on its destruction.
ScopedObserver<SigninManagerBase, AppListViewDelegate> scoped_observer_;
- // Window contents of the additional custom launcher page. May be NULL.
- scoped_ptr<apps::CustomLauncherPageContents> custom_page_contents_;
+ // Window contents of additional custom launcher pages.
+ ScopedVector<apps::CustomLauncherPageContents> custom_page_contents_;
DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate);
};
diff --git a/ui/app_list/app_list_view_delegate.h b/ui/app_list/app_list_view_delegate.h
index 606e218..90a608e 100644
--- a/ui/app_list/app_list_view_delegate.h
+++ b/ui/app_list/app_list_view_delegate.h
@@ -140,9 +140,10 @@ class APP_LIST_EXPORT AppListViewDelegate {
// 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;
+ // Creates the web views for the user-specified custom pages. The caller takes
+ // ownership of the returned views.
+ virtual std::vector<views::View*> CreateCustomPageWebViews(
+ 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 e4044b4..56c2e8f 100644
--- a/ui/app_list/test/app_list_test_view_delegate.cc
+++ b/ui/app_list/test/app_list_test_view_delegate.cc
@@ -5,6 +5,7 @@
#include "ui/app_list/test/app_list_test_view_delegate.h"
#include <string>
+#include <vector>
#include "base/callback.h"
#include "base/files/file_path.h"
@@ -96,9 +97,9 @@ views::View* AppListTestViewDelegate::CreateStartPageWebView(
const gfx::Size& size) {
return NULL;
}
-views::View* AppListTestViewDelegate::CreateCustomPageWebView(
+std::vector<views::View*> AppListTestViewDelegate::CreateCustomPageWebViews(
const gfx::Size& size) {
- return NULL;
+ return std::vector<views::View*>();
}
#endif
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 acf7130..dac12b7 100644
--- a/ui/app_list/test/app_list_test_view_delegate.h
+++ b/ui/app_list/test/app_list_test_view_delegate.h
@@ -77,7 +77,8 @@ 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;
+ virtual std::vector<views::View*> CreateCustomPageWebViews(
+ 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 9057abc..650115c 100644
--- a/ui/app_list/views/contents_view.cc
+++ b/ui/app_list/views/contents_view.cc
@@ -5,6 +5,7 @@
#include "ui/app_list/views/contents_view.h"
#include <algorithm>
+#include <vector>
#include "base/logging.h"
#include "grit/ui_resources.h"
@@ -56,10 +57,14 @@ 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);
+ std::vector<views::View*> custom_page_views =
+ view_delegate->CreateCustomPageWebViews(GetLocalBounds().size());
+ for (std::vector<views::View*>::const_iterator it =
+ custom_page_views.begin();
+ it != custom_page_views.end();
+ ++it) {
+ AddLauncherPage(*it, IDR_APP_LIST_NOTIFICATIONS_ICON);
+ }
start_page_view_ = new StartPageView(app_list_main_view_, view_delegate);
AddLauncherPage(