Skip to content

Commit

Permalink
Removes the dependency of ui/app_list -> content.
Browse files Browse the repository at this point in the history
BUG=380959
R=xiyuan@chromium.org
TBR=darin@chromium.org, oshima@chromium.org
TEST=aura_builder compile succeeds, app_list_unittests

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275191 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mukai@chromium.org committed Jun 5, 2014
1 parent c5ed372 commit 0735b51
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 75 deletions.
6 changes: 3 additions & 3 deletions ash/shell/app_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,12 @@ class ExampleAppListViewDelegate : public app_list::AppListViewDelegate {
// Nothing needs to be done.
}

virtual content::WebContents* GetStartPageContents() OVERRIDE {
virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE {
return NULL;
}

virtual content::WebContents* GetSpeechRecognitionContents() OVERRIDE {
return NULL;
virtual bool IsSpeechRecognitionEnabled() OVERRIDE {
return false;
}

scoped_ptr<app_list::AppListModel> model_;
Expand Down
26 changes: 19 additions & 7 deletions chrome/browser/ui/app_list/app_list_view_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include "ui/app_list/speech_ui_model.h"
#include "ui/base/resource/resource_bundle.h"

#if defined(TOOLKIT_VIEWS)
#include "ui/views/controls/webview/webview.h"
#endif

#if defined(USE_AURA)
#include "ui/keyboard/keyboard_util.h"
#endif
Expand Down Expand Up @@ -382,22 +386,30 @@ void AppListViewDelegate::OnProfileNameChanged(
OnProfileChanged();
}

content::WebContents* AppListViewDelegate::GetStartPageContents() {
#if defined(TOOLKIT_VIEWS)
views::View* AppListViewDelegate::CreateStartPageWebView(
const gfx::Size& size) {
app_list::StartPageService* service =
app_list::StartPageService::Get(profile_);
if (!service)
return NULL;

return service->GetStartPageContents();
content::WebContents* web_contents = service->GetStartPageContents();
if (!web_contents)
return NULL;

views::WebView* web_view = new views::WebView(
web_contents->GetBrowserContext());
web_view->SetPreferredSize(size);
web_view->SetWebContents(web_contents);
return web_view;
}
#endif

content::WebContents* AppListViewDelegate::GetSpeechRecognitionContents() {
bool AppListViewDelegate::IsSpeechRecognitionEnabled() {
app_list::StartPageService* service =
app_list::StartPageService::Get(profile_);
if (!service)
return NULL;

return service->GetSpeechRecognitionContents();
return service && service->GetSpeechRecognitionContents();
}

const app_list::AppListViewDelegate::Users&
Expand Down
6 changes: 4 additions & 2 deletions chrome/browser/ui/app_list/app_list_view_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ class AppListViewDelegate : public app_list::AppListViewDelegate,
virtual void ToggleSpeechRecognition() OVERRIDE;
virtual void ShowForProfileByPath(
const base::FilePath& profile_path) OVERRIDE;
virtual content::WebContents* GetStartPageContents() OVERRIDE;
virtual content::WebContents* GetSpeechRecognitionContents() OVERRIDE;
#if defined(TOOLKIT_VIEWS)
virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE;
#endif
virtual bool IsSpeechRecognitionEnabled() OVERRIDE;
virtual const Users& GetUsers() const OVERRIDE;
virtual bool ShouldCenterWindow() const OVERRIDE;
virtual void AddObserver(
Expand Down
8 changes: 3 additions & 5 deletions ui/app_list/app_list.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@
}],
['toolkit_views==1', {
'dependencies': [
'../../content/content.gyp:content_browser',
'../events/events.gyp:events',
'../views/controls/webview/webview.gyp:webview',
'../views/views.gyp:views',
],
}, { # toolkit_views==0
Expand Down Expand Up @@ -233,8 +231,6 @@
'dependencies': [
'../views/views.gyp:views',
'../views/views.gyp:views_test_support',
'../../content/content.gyp:content',
'../../content/content.gyp:content_browser',
],
}, { # toolkit_views==0
'sources/': [
Expand Down Expand Up @@ -285,17 +281,19 @@
'type': 'executable',
'sources': [
'../../content/app/startup_helper_win.cc',
'views/app_list_demo.cc',
'demo/app_list_demo_views.cc',
],
'dependencies': [
'../../base/base.gyp:base',
'../../content/content.gyp:content',
'../../content/content.gyp:content_browser',
'../../skia/skia.gyp:skia',
'../../url/url.gyp:url_lib',
'../base/ui_base.gyp:ui_base',
'../events/events.gyp:events',
'../resources/ui_resources.gyp:ui_resources',
'../resources/ui_resources.gyp:ui_test_pak',
'../views/controls/webview/webview.gyp:webview',
'../views/views.gyp:views',
'../views_content_client/views_content_client.gyp:views_content_client',
'app_list',
Expand Down
23 changes: 14 additions & 9 deletions ui/app_list/app_list_view_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ namespace base {
class FilePath;
}

namespace content {
class WebContents;
}

namespace gfx {
class ImageSkia;
class Size;
}

#if defined(TOOLKIT_VIEWS)
namespace views {
class View;
}
#endif

namespace app_list {

Expand Down Expand Up @@ -132,12 +135,14 @@ class APP_LIST_EXPORT AppListViewDelegate {
// Shows the app list for the profile specified by |profile_path|.
virtual void ShowForProfileByPath(const base::FilePath& profile_path) = 0;

// Get the start page web contents. Owned by the AppListViewDelegate.
virtual content::WebContents* GetStartPageContents() = 0;
#if defined(TOOLKIT_VIEWS)
// 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;
#endif

// Get the web contents for speech recognition or NULL if speech recognition
// is unavailable.
virtual content::WebContents* GetSpeechRecognitionContents() = 0;
// Returns true if the delegate supports speech recognition.
virtual bool IsSpeechRecognitionEnabled() = 0;

// Returns the list of users (for AppListMenu).
virtual const Users& GetUsers() const = 0;
Expand Down
5 changes: 5 additions & 0 deletions ui/app_list/demo/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include_rules = {
"+content/public",
"+sandbox",
"+ui/views_content_client",
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ui/app_list/test/app_list_test_view_delegate.h"
#include "ui/app_list/views/app_list_view.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/controls/webview/webview.h"
#include "ui/views_content_client/views_content_client.h"

#if defined(OS_WIN)
Expand Down Expand Up @@ -40,7 +41,7 @@ class DemoAppListViewDelegate : public app_list::test::AppListTestViewDelegate {
// Overridden from AppListViewDelegate:
virtual void Dismiss() OVERRIDE;
virtual void ViewClosing() OVERRIDE;
virtual content::WebContents* GetStartPageContents() OVERRIDE;
virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE;

private:
app_list::AppListView* view_; // Weak. Owns this.
Expand Down Expand Up @@ -83,14 +84,19 @@ void DemoAppListViewDelegate::ViewClosing() {
base::MessageLoopForUI::current()->Quit();
}

content::WebContents* DemoAppListViewDelegate::GetStartPageContents() {
views::View* DemoAppListViewDelegate::CreateStartPageWebView(
const gfx::Size& size) {
web_contents_.reset(content::WebContents::Create(
content::WebContents::CreateParams(browser_context_)));
web_contents_->GetController().LoadURL(GURL("http://www.google.com/"),
content::Referrer(),
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
std::string());
return web_contents_.get();
views::WebView* web_view = new views::WebView(
web_contents_->GetBrowserContext());
web_view->SetPreferredSize(size);
web_view->SetWebContents(web_contents_.get());
return web_view;
}

void ShowAppList(content::BrowserContext* browser_context,
Expand Down
9 changes: 6 additions & 3 deletions ui/app_list/test/app_list_test_view_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ gfx::ImageSkia AppListTestViewDelegate::GetWindowIcon() {
return gfx::ImageSkia();
}

content::WebContents* AppListTestViewDelegate::GetStartPageContents() {
#if defined(TOOLKIT_VIEWS)
views::View* AppListTestViewDelegate::CreateStartPageWebView(
const gfx::Size& size) {
return NULL;
}
#endif

content::WebContents* AppListTestViewDelegate::GetSpeechRecognitionContents() {
return NULL;
bool AppListTestViewDelegate::IsSpeechRecognitionEnabled() {
return false;
}

const AppListViewDelegate::Users& AppListTestViewDelegate::GetUsers() const {
Expand Down
6 changes: 4 additions & 2 deletions ui/app_list/test/app_list_test_view_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ class AppListTestViewDelegate : public AppListViewDelegate {
virtual void ToggleSpeechRecognition() OVERRIDE;
virtual void ShowForProfileByPath(
const base::FilePath& profile_path) OVERRIDE {}
virtual content::WebContents* GetStartPageContents() OVERRIDE;
virtual content::WebContents* GetSpeechRecognitionContents() OVERRIDE;
#if defined(TOOLKIT_VIEWS)
virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE;
#endif
virtual bool IsSpeechRecognitionEnabled() OVERRIDE;
virtual const Users& GetUsers() const OVERRIDE;
virtual bool ShouldCenterWindow() const OVERRIDE;
virtual void AddObserver(AppListViewDelegateObserver* observer) OVERRIDE;
Expand Down
10 changes: 0 additions & 10 deletions ui/app_list/views/DEPS

This file was deleted.

2 changes: 1 addition & 1 deletion ui/app_list/views/app_list_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
app_list_main_view_->layer()->SetMasksToBounds(true);

// Speech recognition is available only when the start page exists.
if (delegate_ && delegate_->GetSpeechRecognitionContents()) {
if (delegate_ && delegate_->IsSpeechRecognitionEnabled()) {
speech_view_ = new SpeechView(delegate_.get());
speech_view_->SetVisible(false);
speech_view_->SetPaintToLayer(true);
Expand Down
4 changes: 0 additions & 4 deletions ui/app_list/views/apps_container_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#include "ui/app_list/views/top_icon_animation_view.h"
#include "ui/views/view.h"

namespace content {
class WebContents;
}

namespace app_list {

class AppsGridView;
Expand Down
2 changes: 0 additions & 2 deletions ui/app_list/views/apps_grid_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <string>

#include "base/guid.h"
#include "content/public/browser/web_contents.h"
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/app_list_folder_item.h"
#include "ui/app_list/app_list_item.h"
Expand All @@ -25,7 +24,6 @@
#include "ui/events/event.h"
#include "ui/gfx/animation/animation.h"
#include "ui/views/border.h"
#include "ui/views/controls/webview/webview.h"
#include "ui/views/view_model_utils.h"
#include "ui/views/widget/widget.h"

Expand Down
5 changes: 0 additions & 5 deletions ui/app_list/views/apps_grid_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,9 @@
#include "ui/base/dragdrop/drag_source_win.h"
#endif

namespace content {
class WebContents;
}

namespace views {
class ButtonListener;
class DragImageView;
class WebView;
}

namespace app_list {
Expand Down
4 changes: 0 additions & 4 deletions ui/app_list/views/contents_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#include "ui/app_list/app_list_export.h"
#include "ui/views/view.h"

namespace content {
class WebContents;
}

namespace views {
class BoundsAnimator;
class ViewModel;
Expand Down
15 changes: 4 additions & 11 deletions ui/app_list/views/start_page_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "ui/app_list/views/start_page_view.h"

#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/web_contents.h"
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/app_list_item.h"
#include "ui/app_list/app_list_model.h"
Expand All @@ -16,7 +15,6 @@
#include "ui/views/controls/button/custom_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/webview/webview.h"
#include "ui/views/layout/box_layout.h"

namespace app_list {
Expand Down Expand Up @@ -91,15 +89,10 @@ StartPageView::StartPageView(AppListMainView* app_list_main_view,
views::BoxLayout::MAIN_AXIS_ALIGNMENT_END);
instant_container_->SetLayoutManager(instant_layout_manager);

content::WebContents* start_page_web_contents =
view_delegate->GetStartPageContents();
views::WebView* web_view = new views::WebView(
start_page_web_contents ? start_page_web_contents->GetBrowserContext()
: NULL);
web_view->SetPreferredSize(gfx::Size(kWebViewWidth, kWebViewHeight));
web_view->SetWebContents(start_page_web_contents);

instant_container_->AddChildView(web_view);
views::View* web_view = view_delegate->CreateStartPageWebView(
gfx::Size(kWebViewWidth, kWebViewHeight));
if (web_view)
instant_container_->AddChildView(web_view);
instant_container_->AddChildView(new BarPlaceholderButton(this));

// The view containing the start page tiles.
Expand Down
4 changes: 0 additions & 4 deletions ui/app_list/views/start_page_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#include "ui/views/controls/button/button.h"
#include "ui/views/view.h"

namespace content {
class WebContents;
}

namespace app_list {

class AppListMainView;
Expand Down

0 comments on commit 0735b51

Please sign in to comment.