Commit 2ba30fe7 authored by mukai's avatar mukai Committed by Commit bot

Adds full-functional search results for Athena on Chrome.

BUG=380875, 421444
R=oshima@chromium.org, xiyuan@chromium.org
TBR=pkasting@chromium.org, jar@chromium.org
TEST=manually

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

Cr-Commit-Position: refs/heads/master@{#299186}
parent 3f6b84cd
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
'home/minimized_home.h', 'home/minimized_home.h',
'home/public/app_model_builder.h', 'home/public/app_model_builder.h',
'home/public/home_card.h', 'home/public/home_card.h',
'home/public/search_controller_factory.h',
'input/accelerator_manager_impl.cc', 'input/accelerator_manager_impl.cc',
'input/accelerator_manager_impl.h', 'input/accelerator_manager_impl.h',
'input/input_manager_impl.cc', 'input/input_manager_impl.cc',
...@@ -158,7 +159,6 @@ ...@@ -158,7 +159,6 @@
'content/public/app_registry.h', 'content/public/app_registry.h',
'content/public/content_activity_factory_creator.h', 'content/public/content_activity_factory_creator.h',
'content/public/dialogs.h', 'content/public/dialogs.h',
'content/public/scheme_classifier_factory.h',
'content/public/web_contents_view_delegate_creator.h', 'content/public/web_contents_view_delegate_creator.h',
'content/render_view_context_menu_impl.cc', 'content/render_view_context_menu_impl.cc',
'content/render_view_context_menu_impl.h', 'content/render_view_context_menu_impl.h',
...@@ -174,6 +174,7 @@ ...@@ -174,6 +174,7 @@
'extensions/athena_native_app_window_views.h', 'extensions/athena_native_app_window_views.h',
'extensions/extension_app_model_builder.cc', 'extensions/extension_app_model_builder.cc',
'extensions/extensions_delegate.cc', 'extensions/extensions_delegate.cc',
'extensions/pubilc/apps_search_controller_factory.h',
'extensions/public/extension_app_model_builder.h', 'extensions/public/extension_app_model_builder.h',
'extensions/public/extensions_delegate.h', 'extensions/public/extensions_delegate.h',
'virtual_keyboard/public/virtual_keyboard_manager.h', 'virtual_keyboard/public/virtual_keyboard_manager.h',
...@@ -191,12 +192,15 @@ ...@@ -191,12 +192,15 @@
'sources': [ 'sources': [
'content/chrome/dialogs.cc', 'content/chrome/dialogs.cc',
'content/chrome/media_utils.cc', 'content/chrome/media_utils.cc',
'content/chrome/scheme_classifier_factory.cc',
'content/chrome/web_activity_helpers.cc', 'content/chrome/web_activity_helpers.cc',
'extensions/chrome/app_list_controller_delegate_athena.cc',
'extensions/chrome/app_list_controller_delegate_athena.h',
'extensions/chrome/athena_chrome_app_delegate.cc', 'extensions/chrome/athena_chrome_app_delegate.cc',
'extensions/chrome/athena_chrome_app_delegate.h', 'extensions/chrome/athena_chrome_app_delegate.h',
'extensions/chrome/athena_chrome_app_window_client.cc', 'extensions/chrome/athena_chrome_app_window_client.cc',
'extensions/chrome/athena_chrome_app_window_client.h', 'extensions/chrome/athena_chrome_app_window_client.h',
'extensions/chrome/chrome_search_controller_factory.cc',
'extensions/chrome/chrome_search_controller_factory.h',
'extensions/chrome/extensions_delegate_impl.cc', 'extensions/chrome/extensions_delegate_impl.cc',
], ],
}, },
...@@ -212,14 +216,19 @@ ...@@ -212,14 +216,19 @@
'sources': [ 'sources': [
'content/shell/dialogs.cc', 'content/shell/dialogs.cc',
'content/shell/media_utils.cc', 'content/shell/media_utils.cc',
'content/shell/scheme_classifier_factory.cc',
'content/shell/web_activity_helpers.cc', 'content/shell/web_activity_helpers.cc',
'extensions/shell/extensions_delegate_impl.cc', 'extensions/shell/extensions_delegate_impl.cc',
'extensions/shell/athena_shell_app_delegate.cc', 'extensions/shell/athena_shell_app_delegate.cc',
'extensions/shell/athena_shell_app_delegate.h', 'extensions/shell/athena_shell_app_delegate.h',
'extensions/shell/athena_shell_app_window_client.cc', 'extensions/shell/athena_shell_app_window_client.cc',
'extensions/shell/athena_shell_app_window_client.h', 'extensions/shell/athena_shell_app_window_client.h',
'extensions/shell/athena_shell_scheme_classifier.cc',
'extensions/shell/athena_shell_scheme_classifier.h',
'extensions/shell/athena_apps_client_delegate.h', 'extensions/shell/athena_apps_client_delegate.h',
'extensions/shell/shell_search_controller_factory.cc',
'extensions/shell/shell_search_controller_factory.h',
'extensions/shell/url_search_provider.cc',
'extensions/shell/url_search_provider.h',
], ],
}, },
{ {
......
...@@ -12,7 +12,6 @@ include_rules = [ ...@@ -12,7 +12,6 @@ include_rules = [
"+components/renderer_context_menu", "+components/renderer_context_menu",
"+components/web_modal", "+components/web_modal",
"+content/public", "+content/public",
"+net/url_request",
"+ui/aura", "+ui/aura",
"+ui/base", "+ui/base",
"+ui/compositor", "+ui/compositor",
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/content/public/scheme_classifier_factory.h"
#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
#include "chrome/browser/profiles/profile.h"
namespace athena {
scoped_ptr<AutocompleteSchemeClassifier> CreateSchemeClassifier(
content::BrowserContext* context) {
return scoped_ptr<AutocompleteSchemeClassifier>(
new ChromeAutocompleteSchemeClassifier(
Profile::FromBrowserContext(context)));
}
} // namespace athena
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/extensions/chrome/app_list_controller_delegate_athena.h"
#include "athena/activity/public/activity_factory.h"
#include "athena/extensions/public/extensions_delegate.h"
#include "chrome/browser/profiles/profile.h"
#include "extensions/common/extension.h"
#include "ui/app_list/views/app_list_view.h"
namespace athena {
AppListControllerDelegateAthena::AppListControllerDelegateAthena() {
}
AppListControllerDelegateAthena::~AppListControllerDelegateAthena() {
}
void AppListControllerDelegateAthena::DismissView() {
}
gfx::NativeWindow AppListControllerDelegateAthena::GetAppListWindow() {
NOTIMPLEMENTED();
return NULL;
}
gfx::Rect AppListControllerDelegateAthena::GetAppListBounds() {
NOTIMPLEMENTED();
return gfx::Rect();
}
gfx::ImageSkia AppListControllerDelegateAthena::GetWindowIcon() {
return gfx::ImageSkia();
}
bool AppListControllerDelegateAthena::IsAppPinned(
const std::string& extension_id) {
return false;
}
void AppListControllerDelegateAthena::PinApp(const std::string& extension_id) {
NOTREACHED();
}
void AppListControllerDelegateAthena::UnpinApp(
const std::string& extension_id) {
NOTREACHED();
}
AppListControllerDelegate::Pinnable
AppListControllerDelegateAthena::GetPinnable() {
return NO_PIN;
}
void AppListControllerDelegateAthena::OnShowChildDialog() {
NOTIMPLEMENTED();
}
void AppListControllerDelegateAthena::OnCloseChildDialog() {
NOTIMPLEMENTED();
}
bool AppListControllerDelegateAthena::CanDoCreateShortcutsFlow() {
return false;
}
void AppListControllerDelegateAthena::DoCreateShortcutsFlow(
Profile* profile,
const std::string& extension_id) {
NOTREACHED();
}
void AppListControllerDelegateAthena::CreateNewWindow(Profile* profile,
bool incognito) {
// Nothing needs to be done.
}
void AppListControllerDelegateAthena::OpenURL(
Profile* profile,
const GURL& url,
ui::PageTransition transition,
WindowOpenDisposition disposition) {
ActivityFactory::Get()->CreateWebActivity(profile, base::string16(), url);
}
void AppListControllerDelegateAthena::ActivateApp(
Profile* profile,
const extensions::Extension* extension,
AppListSource source,
int event_flags) {
LaunchApp(profile, extension, source, event_flags);
}
void AppListControllerDelegateAthena::LaunchApp(
Profile* profile,
const extensions::Extension* extension,
AppListSource source,
int event_flags) {
ExtensionsDelegate::Get(profile)->LaunchApp(extension->id());
}
void AppListControllerDelegateAthena::ShowForProfileByPath(
const base::FilePath& profile_path) {
// Ash doesn't have profile switching.
NOTREACHED();
}
bool AppListControllerDelegateAthena::ShouldShowUserIcon() {
return false;
}
} // namespace athena
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_EXTENSIONS_CHROME_APP_LIST_CONTROLLER_DELEGATE_ATHENA_H_
#define ATHENA_EXTENSIONS_CHROME_APP_LIST_CONTROLLER_DELEGATE_ATHENA_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
namespace athena {
class AppListControllerDelegateAthena : public AppListControllerDelegate {
public:
AppListControllerDelegateAthena();
virtual ~AppListControllerDelegateAthena();
private:
// AppListControllerDelegate overrides:
virtual void DismissView() override;
virtual gfx::NativeWindow GetAppListWindow() override;
virtual gfx::Rect GetAppListBounds() override;
virtual gfx::ImageSkia GetWindowIcon() override;
virtual bool IsAppPinned(const std::string& extension_id) override;
virtual void PinApp(const std::string& extension_id) override;
virtual void UnpinApp(const std::string& extension_id) override;
virtual Pinnable GetPinnable() override;
virtual void OnShowChildDialog() override;
virtual void OnCloseChildDialog() override;
virtual bool CanDoCreateShortcutsFlow() override;
virtual void DoCreateShortcutsFlow(Profile* profile,
const std::string& extension_id) override;
virtual void CreateNewWindow(Profile* profile, bool incognito) override;
virtual void OpenURL(Profile* profile,
const GURL& url,
ui::PageTransition transition,
WindowOpenDisposition disposition) override;
virtual void ActivateApp(Profile* profile,
const extensions::Extension* extension,
AppListSource source,
int event_flags) override;
virtual void LaunchApp(Profile* profile,
const extensions::Extension* extension,
AppListSource source,
int event_flags) override;
virtual void ShowForProfileByPath(
const base::FilePath& profile_path) override;
virtual bool ShouldShowUserIcon() override;
DISALLOW_COPY_AND_ASSIGN(AppListControllerDelegateAthena);
};
} // namespace athena
#endif // ATHENA_EXTENSIONS_CHROME_APP_LIST_CONTROLLER_DELEGATE_ATHENA_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/extensions/chrome/chrome_search_controller_factory.h"
#include "athena/extensions/chrome/app_list_controller_delegate_athena.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/search/search_controller_factory.h"
namespace athena {
ChromeSearchControllerFactory::ChromeSearchControllerFactory(
content::BrowserContext* browser_context)
: browser_context_(browser_context) {
}
ChromeSearchControllerFactory::~ChromeSearchControllerFactory() {
}
scoped_ptr<app_list::SearchController> ChromeSearchControllerFactory::Create(
app_list::SearchBoxModel* search_box,
app_list::AppListModel::SearchResults* results) {
list_controller_.reset(new AppListControllerDelegateAthena());
return app_list::CreateSearchController(
Profile::FromBrowserContext(browser_context_),
search_box,
results,
list_controller_.get());
}
scoped_ptr<SearchControllerFactory> CreateSearchControllerFactory(
content::BrowserContext* context) {
return make_scoped_ptr(new ChromeSearchControllerFactory(context));
}
} // namespace athena
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_EXTENSIONS_CHROME_CHROME_SEARCH_CONTROLLER_FACTORY_H_
#define ATHENA_EXTENSIONS_CHROME_CHROME_SEARCH_CONTROLLER_FACTORY_H_
#include "athena/home/public/search_controller_factory.h"
#include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
namespace content {
class BrowserContext;
}
namespace athena {
class ChromeSearchControllerFactory : public SearchControllerFactory {
public:
explicit ChromeSearchControllerFactory(
content::BrowserContext* browser_context);
virtual ~ChromeSearchControllerFactory();
virtual scoped_ptr<app_list::SearchController> Create(
app_list::SearchBoxModel* search_box,
app_list::AppListModel::SearchResults* results) override;
private:
content::BrowserContext* browser_context_;
scoped_ptr<AppListControllerDelegate> list_controller_;
DISALLOW_COPY_AND_ASSIGN(ChromeSearchControllerFactory);
};
} // namespace athena
#endif // ATHENA_EXTENSIONS_CHROME_CHROME_SEARCH_CONTROLLER_FACTORY_H_
...@@ -2,23 +2,21 @@ ...@@ -2,23 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ATHENA_CONTENT_PUBLIC_SCHEME_CLASSIFIER_FACTORY_H_ #ifndef ATHENA_EXTENSIONS_PUBLIC_APPS_SEARCH_CONTROLLER_FACTORY_H_
#define ATHENA_CONTENT_PUBLIC_SCHEME_CLASSIFIER_FACTORY_H_ #define ATHENA_EXTENSIONS_PUBLIC_APPS_SEARCH_CONTROLLER_FACTORY_H_
#include "base/memory/scoped_ptr.h" #include "athena/athena_export.h"
#include "components/omnibox/autocomplete_scheme_classifier.h"
namespace content { namespace content {
class BrowserContext; class BrowserContext;
} }
namespace athena { namespace athena {
class SearchControllerFactory;
// Create the AutocompleteSchemeClassifier implementation of the current ATHENA_EXPORT scoped_ptr<SearchControllerFactory> CreateSearchControllerFactory(
// environment.
scoped_ptr<AutocompleteSchemeClassifier> CreateSchemeClassifier(
content::BrowserContext* context); content::BrowserContext* context);
} // namespace athena } // namespace athena
#endif // ATHENA_CONTENT_PUBLIC_SCHEME_CLASSIFIER_FACTORY_H_ #endif // ATHENA_EXTENSIONS_PUBLIC_APPS_SEARCH_CONTROLLER_FACTORY_H_
include_rules = [ include_rules = [
"+components/metrics/proto",
"+components/omnibox",
"+components/search_engines",
"+extensions/shell/browser", "+extensions/shell/browser",
"+net/url_request",
"+ui/app_list",
] ]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/extensions/shell/athena_shell_scheme_classifier.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "net/url_request/url_request.h"
using metrics::OmniboxInputType::Type;
namespace athena {
AthenaShellSchemeClassifier::AthenaShellSchemeClassifier() {
}
AthenaShellSchemeClassifier::~AthenaShellSchemeClassifier() {
}
Type AthenaShellSchemeClassifier::GetInputTypeForScheme(
const std::string& scheme) const {
if (net::URLRequest::IsHandledProtocol(scheme))
return metrics::OmniboxInputType::URL;
return metrics::OmniboxInputType::INVALID;
}
} // namespace athena
...@@ -2,39 +2,28 @@ ...@@ -2,39 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "athena/content/public/scheme_classifier_factory.h" #ifndef ATHENA_EXTENSIONS_SHELL_ATHENA_SHELL_SCHEME_CLASSIFIER_H_
#define ATHENA_EXTENSIONS_SHELL_ATHENA_SHELL_SCHEME_CLASSIFIER_H_
#include "components/metrics/proto/omnibox_input_type.pb.h" #include "base/macros.h"
#include "net/url_request/url_request.h" #include "components/omnibox/autocomplete_scheme_classifier.h"
namespace athena { namespace athena {
namespace {
// The AutocompleteSchemeClassifier implementation for athena_main. // The AutocompleteSchemeClassifier implementation for athena_main.
class AthenaShellSchemeClassifier : public AutocompleteSchemeClassifier { class AthenaShellSchemeClassifier : public AutocompleteSchemeClassifier {
public: public:
AthenaShellSchemeClassifier() {} AthenaShellSchemeClassifier();
virtual ~AthenaShellSchemeClassifier() {} virtual ~AthenaShellSchemeClassifier();
// AutocompleteSchemeClassifier: // AutocompleteSchemeClassifier:
virtual metrics::OmniboxInputType::Type GetInputTypeForScheme( virtual metrics::OmniboxInputType::Type GetInputTypeForScheme(
const std::string& scheme) const override { const std::string& scheme) const override;
if (net::URLRequest::IsHandledProtocol(scheme))
return metrics::OmniboxInputType::URL;
return metrics::OmniboxInputType::INVALID;
}
private: private:
DISALLOW_COPY_AND_ASSIGN(AthenaShellSchemeClassifier); DISALLOW_COPY_AND_ASSIGN(AthenaShellSchemeClassifier);
}; };
} // namespace
scoped_ptr<AutocompleteSchemeClassifier> CreateSchemeClassifier(
content::BrowserContext* context) {
return scoped_ptr<AutocompleteSchemeClassifier>(
new AthenaShellSchemeClassifier());
}
} // namespace athena } // namespace athena
#endif // ATHENA_EXTENSIONS_SHELL_ATHENA_SHELL_SCHEME_CLASSIFIER_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "athena/extensions/shell/shell_search_controller_factory.h"
#include "athena/extensions/shell/url_search_provider.h"
#include "ui/app_list/search_controller.h"
namespace athena {
ShellSearchControllerFactory::ShellSearchControllerFactory(
content::BrowserContext* browser_context)
: browser_context_(browser_context) {
}
ShellSearchControllerFactory::~ShellSearchControllerFactory() {
}
scoped_ptr<app_list::SearchController> ShellSearchControllerFactory::Create(
app_list::SearchBoxModel* search_box,
app_list::AppListModel::SearchResults* results) {
scoped_ptr<app_list::SearchController> controller(
new app_list::SearchController(
search_box, results, NULL /* no history */));
controller->AddProvider(app_list::Mixer::MAIN_GROUP,
scoped_ptr<app_list::SearchProvider>(
new UrlSearchProvider(browser_context_)));
return controller.Pass();
}
scoped_ptr<SearchControllerFactory> CreateSearchControllerFactory(
content::BrowserContext* context) {
return make_scoped_ptr(new ShellSearchControllerFactory(context));
}
} // namespace athena
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_EXTENSIONS_SHELL_SHELL_SEARCH_CONTROLLER_FACTORY_H_
#define ATHENA_EXTENSIONS_SHELL_SHELL_SEARCH_CONTROLLER_FACTORY_H_
#include "athena/home/public/search_controller_factory.h"
namespace content {
class BrowserContext;
}
namespace athena {
class ShellSearchControllerFactory : public SearchControllerFactory {
public:
explicit ShellSearchControllerFactory(
content::BrowserContext* browser_context);
virtual ~ShellSearchControllerFactory();
virtual scoped_ptr<app_list::SearchController> Create(
app_list::SearchBoxModel* search_box,
app_list::AppListModel::SearchResults* results) override;
private:
content::BrowserContext* browser_context_;
DISALLOW_COPY_AND_ASSIGN(ShellSearchControllerFactory);
};
} // namespace athena
#endif // ATHENA_EXTENSIONS_SHELL_SHELL_SEARCH_CONTROLLER_FACTORY_H_
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "athena/main/url_search_provider.h" #include "athena/extensions/shell/url_search_provider.h"
#include "athena/activity/public/activity.h" #include "athena/activity/public/activity.h"
#include "athena/activity/public/activity_factory.h" #include "athena/activity/public/activity_factory.h"
#include "athena/content/public/scheme_classifier_factory.h" #include "athena/extensions/shell/athena_shell_scheme_classifier.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "components/metrics/proto/omnibox_event.pb.h" #include "components/metrics/proto/omnibox_event.pb.h"
...@@ -34,9 +34,7 @@ const int kScoreForWhatYouTypedResult = 1203; ...@@ -34,9 +34,7 @@ const int kScoreForWhatYouTypedResult = 1203;
class AthenaSearchTermsData : public SearchTermsData { class AthenaSearchTermsData : public SearchTermsData {
public: public:
// SearchTermsData: // SearchTermsData:
virtual std::string GetSuggestClient() const override { virtual std::string GetSuggestClient() const override { return "chrome"; }
return "chrome";
}
}; };
// The templateURLServiceClient for Athena. Mainly for the interaction with // The templateURLServiceClient for Athena. Mainly for the interaction with
...@@ -67,8 +65,7 @@ class AthenaAutocompleteProviderClient : public AutocompleteProviderClient { ...@@ -67,8 +65,7 @@ class AthenaAutocompleteProviderClient : public AutocompleteProviderClient {
public: public:
explicit AthenaAutocompleteProviderClient( explicit AthenaAutocompleteProviderClient(
content::BrowserContext* browser_context) content::BrowserContext* browser_context)
: browser_context_(browser_context), : browser_context_(browser_context) {}
scheme_classifier_(CreateSchemeClassifier(browser_context)) {}
virtual ~AthenaAutocompleteProviderClient() {} virtual ~AthenaAutocompleteProviderClient() {}
virtual net::URLRequestContextGetter* RequestContext() override { virtual net::URLRequestContextGetter* RequestContext() override {
...@@ -84,7 +81,7 @@ class AthenaAutocompleteProviderClient : public AutocompleteProviderClient { ...@@ -84,7 +81,7 @@ class AthenaAutocompleteProviderClient : public AutocompleteProviderClient {
virtual bool SearchSuggestEnabled() override { return true; } virtual bool SearchSuggestEnabled() override { return true; }
virtual bool ShowBookmarkBar() override { return false; } virtual bool ShowBookmarkBar() override { return false; }
virtual const AutocompleteSchemeClassifier& SchemeClassifier() override { virtual const AutocompleteSchemeClassifier& SchemeClassifier() override {
return *scheme_classifier_; return scheme_classifier_;
} }
virtual void Classify( virtual void Classify(
const base::string16& text, const base::string16& text,
...@@ -102,7 +99,7 @@ class AthenaAutocompleteProviderClient : public AutocompleteProviderClient { ...@@ -102,7 +99,7 @@ class AthenaAutocompleteProviderClient : public AutocompleteProviderClient {
private: private:
content::BrowserContext* browser_context_; content::BrowserContext* browser_context_;
scoped_ptr<AutocompleteSchemeClassifier> scheme_classifier_; AthenaShellSchemeClassifier scheme_classifier_;
DISALLOW_COPY_AND_ASSIGN(AthenaAutocompleteProviderClient); DISALLOW_COPY_AND_ASSIGN(AthenaAutocompleteProviderClient);
}; };
...@@ -120,10 +117,9 @@ int ACMatchStyleToTagStyle(int styles) { ...@@ -120,10 +117,9 @@ int ACMatchStyleToTagStyle(int styles) {
} }
// Translates ACMatchClassifications into SearchResult tags. // Translates ACMatchClassifications into SearchResult tags.
void ACMatchClassificationsToTags( void ACMatchClassificationsToTags(const base::string16& text,
const base::string16& text, const ACMatchClassifications& text_classes,
const ACMatchClassifications& text_classes, app_list::SearchResult::Tags* tags) {
app_list::SearchResult::Tags* tags) {
int tag_styles = app_list::SearchResult::Tag::NONE; int tag_styles = app_list::SearchResult::Tag::NONE;
size_t tag_start = 0; size_t tag_start = 0;
...@@ -145,8 +141,8 @@ void ACMatchClassificationsToTags( ...@@ -145,8 +141,8 @@ void ACMatchClassificationsToTags(
} }
if (tag_styles != app_list::SearchResult::Tag::NONE) { if (tag_styles != app_list::SearchResult::Tag::NONE) {
tags->push_back(app_list::SearchResult::Tag( tags->push_back(
tag_styles, tag_start, text.length())); app_list::SearchResult::Tag(tag_styles, tag_start, text.length()));
} }
} }
...@@ -154,8 +150,7 @@ class UrlSearchResult : public app_list::SearchResult { ...@@ -154,8 +150,7 @@ class UrlSearchResult : public app_list::SearchResult {
public: public:
UrlSearchResult(content::BrowserContext* browser_context, UrlSearchResult(content::BrowserContext* browser_context,
const AutocompleteMatch& match) const AutocompleteMatch& match)
: browser_context_(browser_context), : browser_context_(browser_context), match_(match) {
match_(match) {
set_id(match_.destination_url.spec()); set_id(match_.destination_url.spec());
// Derive relevance from omnibox relevance and normalize it to [0, 1]. // Derive relevance from omnibox relevance and normalize it to [0, 1].
...@@ -189,16 +184,14 @@ class UrlSearchResult : public app_list::SearchResult { ...@@ -189,16 +184,14 @@ class UrlSearchResult : public app_list::SearchResult {
void UpdateTitleAndDetails() { void UpdateTitleAndDetails() {
set_title(match_.contents); set_title(match_.contents);
SearchResult::Tags title_tags; SearchResult::Tags title_tags;
ACMatchClassificationsToTags(match_.contents, ACMatchClassificationsToTags(
match_.contents_class, match_.contents, match_.contents_class, &title_tags);
&title_tags);
set_title_tags(title_tags); set_title_tags(title_tags);
set_details(match_.description); set_details(match_.description);
SearchResult::Tags details_tags; SearchResult::Tags details_tags;
ACMatchClassificationsToTags(match_.description, ACMatchClassificationsToTags(
match_.description_class, match_.description, match_.description_class, &details_tags);
&details_tags);
set_details_tags(details_tags); set_details_tags(details_tags);
} }
...@@ -213,16 +206,15 @@ class UrlSearchResult : public app_list::SearchResult { ...@@ -213,16 +206,15 @@ class UrlSearchResult : public app_list::SearchResult {
UrlSearchProvider::UrlSearchProvider(content::BrowserContext* browser_context) UrlSearchProvider::UrlSearchProvider(content::BrowserContext* browser_context)
: browser_context_(browser_context), : browser_context_(browser_context),
// TODO(mukai): introduce the real parameters when it's necessary. // TODO(mukai): introduce the real parameters when it's necessary.
template_url_service_( template_url_service_(new TemplateURLService(
new TemplateURLService(NULL /* prefs */, NULL /* prefs */,
scoped_ptr<SearchTermsData>( scoped_ptr<SearchTermsData>(new AthenaSearchTermsData()),
new AthenaSearchTermsData()), NULL /* KeywordWebDataService */,
NULL /* KeywordWebDataService */, scoped_ptr<TemplateURLServiceClient>(
scoped_ptr<TemplateURLServiceClient>( new AthenaTemplateURLServiceClient()),
new AthenaTemplateURLServiceClient()), NULL /*GoogleURLTracker */,
NULL /*GoogleURLTracker */, NULL /* RapporService */,
NULL /* RapporService */, base::Closure() /* dsp_change_callback */)),
base::Closure() /* dsp_change_callback */)),
provider_(new ::SearchProvider( provider_(new ::SearchProvider(
this, this,
template_url_service_.get(), template_url_service_.get(),
...@@ -236,8 +228,6 @@ UrlSearchProvider::~UrlSearchProvider() { ...@@ -236,8 +228,6 @@ UrlSearchProvider::~UrlSearchProvider() {
void UrlSearchProvider::Start(const base::string16& query) { void UrlSearchProvider::Start(const base::string16& query) {
const bool minimal_changes = query == input_.text(); const bool minimal_changes = query == input_.text();
scoped_ptr<AutocompleteSchemeClassifier> scheme_classifier(
CreateSchemeClassifier(browser_context_));
input_ = AutocompleteInput(query, input_ = AutocompleteInput(query,
base::string16::npos /* cursor_position */, base::string16::npos /* cursor_position */,
std::string() /* desired_tld */, std::string() /* desired_tld */,
...@@ -247,7 +237,7 @@ void UrlSearchProvider::Start(const base::string16& query) { ...@@ -247,7 +237,7 @@ void UrlSearchProvider::Start(const base::string16& query) {
false /* prefer_keyword */, false /* prefer_keyword */,
true /* allow_extract_keyword_match */, true /* allow_extract_keyword_match */,
true /* want_asynchronous_matches */, true /* want_asynchronous_matches */,
*scheme_classifier); AthenaShellSchemeClassifier());
// Clearing results here may cause unexpected results. // Clearing results here may cause unexpected results.
// TODO(mukai): fix this by fixing crbug.com/415500 // TODO(mukai): fix this by fixing crbug.com/415500
...@@ -261,8 +251,8 @@ void UrlSearchProvider::Start(const base::string16& query) { ...@@ -261,8 +251,8 @@ void UrlSearchProvider::Start(const base::string16& query) {
what_you_typed_match.destination_url = input_.canonicalized_url(); what_you_typed_match.destination_url = input_.canonicalized_url();
what_you_typed_match.contents = input_.text(); what_you_typed_match.contents = input_.text();
what_you_typed_match.relevance = kScoreForWhatYouTypedResult; what_you_typed_match.relevance = kScoreForWhatYouTypedResult;
Add(scoped_ptr<app_list::SearchResult>(new UrlSearchResult( Add(scoped_ptr<app_list::SearchResult>(
browser_context_, what_you_typed_match))); new UrlSearchResult(browser_context_, what_you_typed_match)));
} }
provider_->Start(input_, minimal_changes); provider_->Start(input_, minimal_changes);
...@@ -282,8 +272,8 @@ void UrlSearchProvider::OnProviderUpdate(bool updated_matches) { ...@@ -282,8 +272,8 @@ void UrlSearchProvider::OnProviderUpdate(bool updated_matches) {
if (!it->destination_url.is_valid()) if (!it->destination_url.is_valid())
continue; continue;
Add(scoped_ptr<app_list::SearchResult>(new UrlSearchResult( Add(scoped_ptr<app_list::SearchResult>(
browser_context_, *it))); new UrlSearchResult(browser_context_, *it)));
} }
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ATHENA_MAIN_URL_SEARCH_PROVIDER_H_ #ifndef ATHENA_EXTENSIONS_SHELL_URL_SEARCH_PROVIDER_H_
#define ATHENA_MAIN_URL_SEARCH_PROVIDER_H_ #define ATHENA_EXTENSIONS_SHELL_URL_SEARCH_PROVIDER_H_
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -48,4 +48,4 @@ class UrlSearchProvider : public app_list::SearchProvider, ...@@ -48,4 +48,4 @@ class UrlSearchProvider : public app_list::SearchProvider,
} // namespace athena } // namespace athena
#endif // ATHENA_MAIN_URL_SEARCH_PROVIDER_H_ #endif // ATHENA_EXTENSIONS_SHELL_URL_SEARCH_PROVIDER_H_
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <vector> #include <vector>
#include "athena/home/public/app_model_builder.h" #include "athena/home/public/app_model_builder.h"
#include "athena/home/public/search_controller_factory.h"
#include "athena/strings/grit/athena_strings.h" #include "athena/strings/grit/athena_strings.h"
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/bind.h" #include "base/bind.h"
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "ui/app_list/app_list_model.h" #include "ui/app_list/app_list_model.h"
#include "ui/app_list/search_box_model.h" #include "ui/app_list/search_box_model.h"
#include "ui/app_list/search_controller.h"
#include "ui/app_list/search_provider.h" #include "ui/app_list/search_provider.h"
#include "ui/app_list/search_result.h" #include "ui/app_list/search_result.h"
#include "ui/app_list/speech_ui_model.h" #include "ui/app_list/speech_ui_model.h"
...@@ -27,36 +29,21 @@ ...@@ -27,36 +29,21 @@
namespace athena { namespace athena {
AppListViewDelegate::AppListViewDelegate(AppModelBuilder* model_builder) AppListViewDelegate::AppListViewDelegate(
AppModelBuilder* model_builder,
SearchControllerFactory* search_factory)
: model_(new app_list::AppListModel), : model_(new app_list::AppListModel),
speech_ui_(new app_list::SpeechUIModel) { speech_ui_(new app_list::SpeechUIModel) {
model_builder->PopulateApps(model_.get()); model_builder->PopulateApps(model_.get());
model_->search_box()->SetHintText( model_->search_box()->SetHintText(
l10n_util::GetStringUTF16(IDS_ATHENA_SEARCH_BOX_HINT)); l10n_util::GetStringUTF16(IDS_ATHENA_SEARCH_BOX_HINT));
if (search_factory) {
search_controller_ =
search_factory->Create(model_->search_box(), model_->results());
}
} }
AppListViewDelegate::~AppListViewDelegate() { AppListViewDelegate::~AppListViewDelegate() {
for (size_t i = 0; i < search_providers_.size(); ++i)
search_providers_[i]->set_result_changed_callback(base::Closure());
}
void AppListViewDelegate::RegisterSearchProvider(
app_list::SearchProvider* search_provider) {
// Right now we allow only one provider.
// TODO(mukai): port app-list's mixer and remove this restriction.
DCHECK(search_providers_.empty());
search_provider->set_result_changed_callback(base::Bind(
&AppListViewDelegate::SearchResultChanged, base::Unretained(this)));
search_providers_.push_back(search_provider);
}
void AppListViewDelegate::SearchResultChanged() {
// TODO(mukai): port app-list's Mixer to reorder the results properly.
app_list::SearchProvider* search_provider = search_providers_[0];
const app_list::SearchProvider::Results& results = search_provider->results();
model_->results()->DeleteAll();
for (size_t i = 0; i < results.size(); ++i)
model_->results()->Add(results[i]->Duplicate().release());
} }
bool AppListViewDelegate::ForceNativeDesktop() const { bool AppListViewDelegate::ForceNativeDesktop() const {
...@@ -82,26 +69,28 @@ void AppListViewDelegate::GetShortcutPathForApp( ...@@ -82,26 +69,28 @@ void AppListViewDelegate::GetShortcutPathForApp(
} }
void AppListViewDelegate::StartSearch() { void AppListViewDelegate::StartSearch() {
for (size_t i = 0; i < search_providers_.size(); ++i) if (search_controller_)
search_providers_[i]->Start(model_->search_box()->text()); search_controller_->Start();
} }
void AppListViewDelegate::StopSearch() { void AppListViewDelegate::StopSearch() {
for (size_t i = 0; i < search_providers_.size(); ++i) if (search_controller_)
search_providers_[i]->Stop(); search_controller_->Stop();
} }
void AppListViewDelegate::OpenSearchResult(app_list::SearchResult* result, void AppListViewDelegate::OpenSearchResult(app_list::SearchResult* result,
bool auto_launch, bool auto_launch,
int event_flags) { int event_flags) {
result->Open(event_flags); if (search_controller_)
search_controller_->OpenResult(result, event_flags);
} }
void AppListViewDelegate::InvokeSearchResultAction( void AppListViewDelegate::InvokeSearchResultAction(
app_list::SearchResult* result, app_list::SearchResult* result,
int action_index, int action_index,
int event_flags) { int event_flags) {
// TODO(mukai): implement this. if (search_controller_)
search_controller_->InvokeResultAction(result, action_index, event_flags);
} }
base::TimeDelta AppListViewDelegate::GetAutoLaunchTimeout() { base::TimeDelta AppListViewDelegate::GetAutoLaunchTimeout() {
......
...@@ -10,22 +10,20 @@ ...@@ -10,22 +10,20 @@
#include "ui/app_list/app_list_view_delegate.h" #include "ui/app_list/app_list_view_delegate.h"
namespace app_list { namespace app_list {
class SearchProvider; class SearchController;
} }
namespace athena { namespace athena {
class AppModelBuilder; class AppModelBuilder;
class SearchControllerFactory;
class AppListViewDelegate : public app_list::AppListViewDelegate { class AppListViewDelegate : public app_list::AppListViewDelegate {
public: public:
explicit AppListViewDelegate(AppModelBuilder* model_builder); AppListViewDelegate(AppModelBuilder* model_builder,
SearchControllerFactory* search_factory);
virtual ~AppListViewDelegate(); virtual ~AppListViewDelegate();
void RegisterSearchProvider(app_list::SearchProvider* search_provider);
private: private:
void SearchResultChanged();
// Overridden from app_list::AppListViewDelegate: // Overridden from app_list::AppListViewDelegate:
virtual bool ForceNativeDesktop() const override; virtual bool ForceNativeDesktop() const override;
virtual void SetProfileByPath(const base::FilePath& profile_path) override; virtual void SetProfileByPath(const base::FilePath& profile_path) override;
...@@ -64,8 +62,7 @@ class AppListViewDelegate : public app_list::AppListViewDelegate { ...@@ -64,8 +62,7 @@ class AppListViewDelegate : public app_list::AppListViewDelegate {
scoped_ptr<app_list::AppListModel> model_; scoped_ptr<app_list::AppListModel> model_;
scoped_ptr<app_list::SpeechUIModel> speech_ui_; scoped_ptr<app_list::SpeechUIModel> speech_ui_;
Users users_; Users users_;
scoped_ptr<app_list::SearchController> search_controller_;
std::vector<app_list::SearchProvider*> search_providers_;
DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate); DISALLOW_COPY_AND_ASSIGN(AppListViewDelegate);
}; };
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "athena/screen/public/screen_manager.h" #include "athena/screen/public/screen_manager.h"
#include "athena/util/container_priorities.h" #include "athena/util/container_priorities.h"
#include "athena/wm/public/window_manager.h" #include "athena/wm/public/window_manager.h"
#include "ui/app_list/search_provider.h"
#include "ui/app_list/views/app_list_main_view.h" #include "ui/app_list/views/app_list_main_view.h"
#include "ui/app_list/views/contents_view.h" #include "ui/app_list/views/contents_view.h"
#include "ui/aura/layout_manager.h" #include "ui/aura/layout_manager.h"
...@@ -222,8 +221,10 @@ class HomeCardView : public views::WidgetDelegateView { ...@@ -222,8 +221,10 @@ class HomeCardView : public views::WidgetDelegateView {
DISALLOW_COPY_AND_ASSIGN(HomeCardView); DISALLOW_COPY_AND_ASSIGN(HomeCardView);
}; };
HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder) HomeCardImpl::HomeCardImpl(scoped_ptr<AppModelBuilder> model_builder,
: model_builder_(model_builder), scoped_ptr<SearchControllerFactory> search_factory)
: model_builder_(model_builder.Pass()),
search_factory_(search_factory.Pass()),
state_(HIDDEN), state_(HIDDEN),
original_state_(VISIBLE_MINIMIZED), original_state_(VISIBLE_MINIMIZED),
home_card_widget_(NULL), home_card_widget_(NULL),
...@@ -245,7 +246,6 @@ HomeCardImpl::~HomeCardImpl() { ...@@ -245,7 +246,6 @@ HomeCardImpl::~HomeCardImpl() {
// Reset the view delegate first as it access search provider during // Reset the view delegate first as it access search provider during
// shutdown. // shutdown.
view_delegate_.reset(); view_delegate_.reset();
search_provider_.reset();
instance = NULL; instance = NULL;
} }
...@@ -259,9 +259,8 @@ void HomeCardImpl::Init() { ...@@ -259,9 +259,8 @@ void HomeCardImpl::Init() {
container->SetLayoutManager(layout_manager_); container->SetLayoutManager(layout_manager_);
wm::SetChildWindowVisibilityChangesAnimated(container); wm::SetChildWindowVisibilityChangesAnimated(container);
view_delegate_.reset(new AppListViewDelegate(model_builder_.get())); view_delegate_.reset(
if (search_provider_) new AppListViewDelegate(model_builder_.get(), search_factory_.get()));
view_delegate_->RegisterSearchProvider(search_provider_.get());
home_card_view_ = new HomeCardView(view_delegate_.get(), container, this); home_card_view_ = new HomeCardView(view_delegate_.get(), container, this);
home_card_widget_ = new views::Widget(); home_card_widget_ = new views::Widget();
...@@ -339,13 +338,6 @@ HomeCard::State HomeCardImpl::GetState() { ...@@ -339,13 +338,6 @@ HomeCard::State HomeCardImpl::GetState() {
return state_; return state_;
} }
void HomeCardImpl::RegisterSearchProvider(
app_list::SearchProvider* search_provider) {
DCHECK(!search_provider_);
search_provider_.reset(search_provider);
view_delegate_->RegisterSearchProvider(search_provider_.get());
}
void HomeCardImpl::UpdateVirtualKeyboardBounds( void HomeCardImpl::UpdateVirtualKeyboardBounds(
const gfx::Rect& bounds) { const gfx::Rect& bounds) {
if (state_ == VISIBLE_MINIMIZED && !bounds.IsEmpty()) { if (state_ == VISIBLE_MINIMIZED && !bounds.IsEmpty()) {
...@@ -437,8 +429,9 @@ void HomeCardImpl::OnWindowActivated(aura::Window* gained_active, ...@@ -437,8 +429,9 @@ void HomeCardImpl::OnWindowActivated(aura::Window* gained_active,
} }
// static // static
HomeCard* HomeCard::Create(AppModelBuilder* model_builder) { HomeCard* HomeCard::Create(scoped_ptr<AppModelBuilder> model_builder,
(new HomeCardImpl(model_builder))->Init(); scoped_ptr<SearchControllerFactory> search_factory) {
(new HomeCardImpl(model_builder.Pass(), search_factory.Pass()))->Init();
DCHECK(instance); DCHECK(instance);
return instance; return instance;
} }
......
...@@ -8,14 +8,11 @@ ...@@ -8,14 +8,11 @@
#include "athena/athena_export.h" #include "athena/athena_export.h"
#include "athena/home/home_card_gesture_manager.h" #include "athena/home/home_card_gesture_manager.h"
#include "athena/home/public/home_card.h" #include "athena/home/public/home_card.h"
#include "athena/home/public/search_controller_factory.h"
#include "athena/input/public/accelerator_manager.h" #include "athena/input/public/accelerator_manager.h"
#include "athena/wm/public/window_manager_observer.h" #include "athena/wm/public/window_manager_observer.h"
#include "ui/wm/public/activation_change_observer.h" #include "ui/wm/public/activation_change_observer.h"
namespace app_list {
class SearchProvider;
}
namespace aura { namespace aura {
class Window; class Window;
...@@ -49,7 +46,8 @@ class ATHENA_EXPORT HomeCardImpl ...@@ -49,7 +46,8 @@ class ATHENA_EXPORT HomeCardImpl
public WindowManagerObserver, public WindowManagerObserver,
public aura::client::ActivationChangeObserver { public aura::client::ActivationChangeObserver {
public: public:
explicit HomeCardImpl(AppModelBuilder* model_builder); HomeCardImpl(scoped_ptr<AppModelBuilder> model_builder,
scoped_ptr<SearchControllerFactory> search_factory);
virtual ~HomeCardImpl(); virtual ~HomeCardImpl();
void Init(); void Init();
...@@ -65,8 +63,6 @@ class ATHENA_EXPORT HomeCardImpl ...@@ -65,8 +63,6 @@ class ATHENA_EXPORT HomeCardImpl
// Overridden from HomeCard: // Overridden from HomeCard:
virtual void SetState(HomeCard::State state) override; virtual void SetState(HomeCard::State state) override;
virtual State GetState() override; virtual State GetState() override;
virtual void RegisterSearchProvider(
app_list::SearchProvider* search_provider) override;
virtual void UpdateVirtualKeyboardBounds( virtual void UpdateVirtualKeyboardBounds(
const gfx::Rect& bounds) override; const gfx::Rect& bounds) override;
...@@ -94,6 +90,7 @@ class ATHENA_EXPORT HomeCardImpl ...@@ -94,6 +90,7 @@ class ATHENA_EXPORT HomeCardImpl
aura::Window* lost_active) override; aura::Window* lost_active) override;
scoped_ptr<AppModelBuilder> model_builder_; scoped_ptr<AppModelBuilder> model_builder_;
scoped_ptr<SearchControllerFactory> search_factory_;
HomeCard::State state_; HomeCard::State state_;
...@@ -108,10 +105,6 @@ class ATHENA_EXPORT HomeCardImpl ...@@ -108,10 +105,6 @@ class ATHENA_EXPORT HomeCardImpl
aura::client::ActivationClient* activation_client_; // Not owned aura::client::ActivationClient* activation_client_; // Not owned
scoped_ptr<ui::LayerOwner> minimized_home_; scoped_ptr<ui::LayerOwner> minimized_home_;
// Right now HomeCard allows only one search provider.
// TODO(mukai): port app-list's SearchController and Mixer.
scoped_ptr<app_list::SearchProvider> search_provider_;
DISALLOW_COPY_AND_ASSIGN(HomeCardImpl); DISALLOW_COPY_AND_ASSIGN(HomeCardImpl);
}; };
......
...@@ -6,10 +6,7 @@ ...@@ -6,10 +6,7 @@
#define ATHENA_HOME_PUBLIC_HOME_CARD_H_ #define ATHENA_HOME_PUBLIC_HOME_CARD_H_
#include "athena/athena_export.h" #include "athena/athena_export.h"
#include "base/memory/scoped_ptr.h"
namespace app_list {
class SearchProvider;
}
namespace gfx { namespace gfx {
class Rect; class Rect;
...@@ -17,6 +14,7 @@ class Rect; ...@@ -17,6 +14,7 @@ class Rect;
namespace athena { namespace athena {
class AppModelBuilder; class AppModelBuilder;
class SearchControllerFactory;
class ATHENA_EXPORT HomeCard { class ATHENA_EXPORT HomeCard {
public: public:
...@@ -38,7 +36,8 @@ class ATHENA_EXPORT HomeCard { ...@@ -38,7 +36,8 @@ class ATHENA_EXPORT HomeCard {
// Creates/deletes/gets the singleton object of the HomeCard // Creates/deletes/gets the singleton object of the HomeCard
// implementation. Takes the ownership of |model_builder|. // implementation. Takes the ownership of |model_builder|.
static HomeCard* Create(AppModelBuilder* model_builder); static HomeCard* Create(scoped_ptr<AppModelBuilder> model_builder,
scoped_ptr<SearchControllerFactory> search_factory);
static void Shutdown(); static void Shutdown();
static HomeCard* Get(); static HomeCard* Get();
...@@ -48,11 +47,6 @@ class ATHENA_EXPORT HomeCard { ...@@ -48,11 +47,6 @@ class ATHENA_EXPORT HomeCard {
virtual void SetState(State state) = 0; virtual void SetState(State state) = 0;
virtual State GetState() = 0; virtual State GetState() = 0;
// Registers a search_provider to the HomeCard. Receiver will take
// the ownership of the specified provider.
virtual void RegisterSearchProvider(
app_list::SearchProvider* search_provider) = 0;
// Called when the virtual keyboard changed has changed to |bounds|. An empty // Called when the virtual keyboard changed has changed to |bounds|. An empty
// |bounds| indicates that the virtual keyboard is not visible anymore. // |bounds| indicates that the virtual keyboard is not visible anymore.
virtual void UpdateVirtualKeyboardBounds( virtual void UpdateVirtualKeyboardBounds(
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATHENA_HOME_PUBLIC_SEARCH_CONTROLLER_FACTORY_H_
#define ATHENA_HOME_PUBLIC_SEARCH_CONTROLLER_FACTORY_H_
#include "athena/athena_export.h"
#include "ui/app_list/app_list_model.h"
#include "ui/app_list/search_controller.h"
namespace app_list {
class SearchBoxModel;
}
namespace athena {
class ATHENA_EXPORT SearchControllerFactory {
public:
virtual ~SearchControllerFactory() {}
virtual scoped_ptr<app_list::SearchController> Create(
app_list::SearchBoxModel* search_box,
app_list::AppListModel::SearchResults* results) = 0;
};
} // namespace athena
#endif // ATHENA_HOME_PUBLIC_SEARCH_CONTROLLER_FACTORY_H_
...@@ -12,10 +12,7 @@ include_rules = [ ...@@ -12,10 +12,7 @@ include_rules = [
"+athena/task/public", "+athena/task/public",
"+athena/virtual_keyboard/public", "+athena/virtual_keyboard/public",
"+athena/wm/public", "+athena/wm/public",
"+components/metrics/proto",
"+components/omnibox",
"+components/pdf", "+components/pdf",
"+components/search_engines",
"+content/public", "+content/public",
"+net", "+net",
"+ppapi", "+ppapi",
......
...@@ -9,14 +9,15 @@ ...@@ -9,14 +9,15 @@
#include "athena/content/public/app_registry.h" #include "athena/content/public/app_registry.h"
#include "athena/content/public/content_activity_factory_creator.h" #include "athena/content/public/content_activity_factory_creator.h"
#include "athena/env/public/athena_env.h" #include "athena/env/public/athena_env.h"
#include "athena/extensions/public/apps_search_controller_factory.h"
#include "athena/extensions/public/extension_app_model_builder.h" #include "athena/extensions/public/extension_app_model_builder.h"
#include "athena/extensions/public/extensions_delegate.h" #include "athena/extensions/public/extensions_delegate.h"
#include "athena/home/public/home_card.h" #include "athena/home/public/home_card.h"
#include "athena/home/public/search_controller_factory.h"
#include "athena/input/public/input_manager.h" #include "athena/input/public/input_manager.h"
#include "athena/main/athena_views_delegate.h" #include "athena/main/athena_views_delegate.h"
#include "athena/main/placeholder.h" #include "athena/main/placeholder.h"
#include "athena/main/placeholder.h" #include "athena/main/placeholder.h"
#include "athena/main/url_search_provider.h"
#include "athena/resource_manager/public/resource_manager.h" #include "athena/resource_manager/public/resource_manager.h"
#include "athena/screen/public/screen_manager.h" #include "athena/screen/public/screen_manager.h"
#include "athena/system/public/system_ui.h" #include "athena/system/public/system_ui.h"
...@@ -128,10 +129,10 @@ void CreateVirtualKeyboardWithContext(content::BrowserContext* context) { ...@@ -128,10 +129,10 @@ void CreateVirtualKeyboardWithContext(content::BrowserContext* context) {
void StartAthenaSessionWithContext(content::BrowserContext* context) { void StartAthenaSessionWithContext(content::BrowserContext* context) {
athena::ExtensionsDelegate::CreateExtensionsDelegate(context); athena::ExtensionsDelegate::CreateExtensionsDelegate(context);
StartAthenaSession(athena::CreateContentActivityFactory(), StartAthenaSession(
new athena::ExtensionAppModelBuilder(context)); athena::CreateContentActivityFactory(),
athena::HomeCard::Get()->RegisterSearchProvider( make_scoped_ptr(new athena::ExtensionAppModelBuilder(context)),
new athena::UrlSearchProvider(context)); athena::CreateSearchControllerFactory(context));
AthenaEnvState* env_state = AthenaEnvState* env_state =
athena::ScreenManager::Get()->GetContext()->GetProperty( athena::ScreenManager::Get()->GetContext()->GetProperty(
kAthenaEnvStateKey); kAthenaEnvStateKey);
...@@ -140,11 +141,13 @@ void StartAthenaSessionWithContext(content::BrowserContext* context) { ...@@ -140,11 +141,13 @@ void StartAthenaSessionWithContext(content::BrowserContext* context) {
CreateTestPages(context); CreateTestPages(context);
} }
void StartAthenaSession(athena::ActivityFactory* activity_factory, void StartAthenaSession(
athena::AppModelBuilder* app_model_builder) { athena::ActivityFactory* activity_factory,
scoped_ptr<athena::AppModelBuilder> app_model_builder,
scoped_ptr<athena::SearchControllerFactory> search_factory) {
DCHECK(!session_started); DCHECK(!session_started);
session_started = true; session_started = true;
athena::HomeCard::Create(app_model_builder); athena::HomeCard::Create(app_model_builder.Pass(), search_factory.Pass());
athena::ActivityManager::Create(); athena::ActivityManager::Create();
athena::ResourceManager::Create(); athena::ResourceManager::Create();
athena::ActivityFactory::RegisterActivityFactory(activity_factory); athena::ActivityFactory::RegisterActivityFactory(activity_factory);
......
...@@ -46,8 +46,6 @@ ...@@ -46,8 +46,6 @@
'placeholder.cc', 'placeholder.cc',
'placeholder.h', 'placeholder.h',
'public/athena_launcher.h', 'public/athena_launcher.h',
'url_search_provider.cc',
'url_search_provider.h',
], ],
}, },
{ {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define ATHENA_MAIN_PUBLIC_ATHENA_LAUNCHER_H_ #define ATHENA_MAIN_PUBLIC_ATHENA_LAUNCHER_H_
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
namespace base { namespace base {
class TaskRunner; class TaskRunner;
...@@ -22,6 +23,7 @@ class BrowserContext; ...@@ -22,6 +23,7 @@ class BrowserContext;
namespace athena { namespace athena {
class ActivityFactory; class ActivityFactory;
class AppModelBuilder; class AppModelBuilder;
class SearchControllerFactory;
// Starts down the athena shell environment. // Starts down the athena shell environment.
void StartAthenaEnv(scoped_refptr<base::TaskRunner> file_runner); void StartAthenaEnv(scoped_refptr<base::TaskRunner> file_runner);
...@@ -32,7 +34,8 @@ void CreateVirtualKeyboardWithContext(content::BrowserContext* context); ...@@ -32,7 +34,8 @@ void CreateVirtualKeyboardWithContext(content::BrowserContext* context);
// Starts the athena session. // Starts the athena session.
void StartAthenaSession(ActivityFactory* activity_factory, void StartAthenaSession(ActivityFactory* activity_factory,
AppModelBuilder* app_model_builder); scoped_ptr<AppModelBuilder> app_model_builder,
scoped_ptr<SearchControllerFactory> search_factory);
void ShutdownAthena(); void ShutdownAthena();
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
#include "athena/test/base/athena_test_helper.h" #include "athena/test/base/athena_test_helper.h"
#include "athena/env/public/athena_env.h" #include "athena/env/public/athena_env.h"
#include "athena/extensions/public/apps_search_controller_factory.h"
#include "athena/extensions/public/extensions_delegate.h" #include "athena/extensions/public/extensions_delegate.h"
#include "athena/home/public/search_controller_factory.h"
#include "athena/main/public/athena_launcher.h" #include "athena/main/public/athena_launcher.h"
#include "athena/test/base/sample_activity_factory.h" #include "athena/test/base/sample_activity_factory.h"
#include "athena/test/base/test_app_model_builder.h" #include "athena/test/base/test_app_model_builder.h"
...@@ -64,7 +66,8 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) { ...@@ -64,7 +66,8 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
athena::StartAthenaEnv(file_thread_->message_loop_proxy()); athena::StartAthenaEnv(file_thread_->message_loop_proxy());
athena::ExtensionsDelegate::CreateExtensionsDelegateForTest(); athena::ExtensionsDelegate::CreateExtensionsDelegateForTest();
athena::StartAthenaSession(new SampleActivityFactory(), athena::StartAthenaSession(new SampleActivityFactory(),
new TestAppModelBuilder()); make_scoped_ptr(new TestAppModelBuilder()),
CreateSearchControllerFactory(NULL));
} }
void AthenaTestHelper::TearDown() { void AthenaTestHelper::TearDown() {
......
...@@ -38,8 +38,12 @@ AppResult::AppResult(Profile* profile, ...@@ -38,8 +38,12 @@ AppResult::AppResult(Profile* profile,
controller_(controller), controller_(controller),
extension_registry_(NULL) { extension_registry_(NULL) {
set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id_).spec()); set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id_).spec());
#if !defined(USE_ATHENA)
// TODO(mukai): Athena also needs to use tile-styled search results for apps.
// Implement it and then remove this ifdef.
if (app_list::switches::IsExperimentalAppListEnabled()) if (app_list::switches::IsExperimentalAppListEnabled())
set_display_type(DISPLAY_TILE); set_display_type(DISPLAY_TILE);
#endif
const extensions::Extension* extension = const extensions::Extension* extension =
extensions::ExtensionSystem::Get(profile_)->extension_service() extensions::ExtensionSystem::Get(profile_)->extension_service()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment