Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: chrome/browser/ui/app_list/start_page_service.cc

Issue 29763004: Embeds offline voice recognizer plugin and its manager to app-list start page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/app_list/start_page_service.h" 5 #include "chrome/browser/ui/app_list/start_page_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/extensions/extension_system_factory.h" 12 #include "chrome/browser/extensions/extension_system_factory.h"
13 #include "chrome/browser/extensions/install_tracker_factory.h" 13 #include "chrome/browser/extensions/install_tracker_factory.h"
14 #include "chrome/browser/media/media_stream_infobar_delegate.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/app_list/recommended_apps.h" 16 #include "chrome/browser/ui/app_list/recommended_apps.h"
16 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
19 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 20 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
20 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h" 21 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h"
21 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_contents_delegate.h"
25 27
26 namespace app_list { 28 namespace app_list {
27 29
28 class StartPageService::Factory : public BrowserContextKeyedServiceFactory { 30 class StartPageService::Factory : public BrowserContextKeyedServiceFactory {
29 public: 31 public:
30 static StartPageService* GetForProfile(Profile* profile) { 32 static StartPageService* GetForProfile(Profile* profile) {
31 if (!CommandLine::ForCurrentProcess()->HasSwitch( 33 if (!CommandLine::ForCurrentProcess()->HasSwitch(
32 switches::kShowAppListStartPage)) { 34 switches::kShowAppListStartPage)) {
33 return NULL; 35 return NULL;
34 } 36 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type); 83 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type);
82 service_->Shutdown(); 84 service_->Shutdown();
83 } 85 }
84 86
85 StartPageService* service_; // Owner of this class. 87 StartPageService* service_; // Owner of this class.
86 content::NotificationRegistrar registrar_; 88 content::NotificationRegistrar registrar_;
87 89
88 DISALLOW_COPY_AND_ASSIGN(ExitObserver); 90 DISALLOW_COPY_AND_ASSIGN(ExitObserver);
89 }; 91 };
90 92
93 class StartPageService::StartPageWebContentsDelegate
94 : public content::WebContentsDelegate {
95 public:
96 StartPageWebContentsDelegate() {}
97 virtual ~StartPageWebContentsDelegate() {}
98
99 virtual void RequestMediaAccessPermission(
100 content::WebContents* web_contents,
101 const content::MediaStreamRequest& request,
102 const content::MediaResponseCallback& callback) OVERRIDE {
103 if (MediaStreamInfoBarDelegate::Create(web_contents, request, callback))
104 NOTREACHED() << "Media stream not allowed for WebUI";
105 }
106
107 private:
108 DISALLOW_COPY_AND_ASSIGN(StartPageWebContentsDelegate);
109 };
110
91 // static 111 // static
92 StartPageService* StartPageService::Get(Profile* profile) { 112 StartPageService* StartPageService::Get(Profile* profile) {
93 return Factory::GetForProfile(profile); 113 return Factory::GetForProfile(profile);
94 } 114 }
95 115
96 StartPageService::StartPageService(Profile* profile) 116 StartPageService::StartPageService(Profile* profile)
97 : profile_(profile), 117 : profile_(profile),
98 exit_observer_(new ExitObserver(this)), 118 exit_observer_(new ExitObserver(this)),
99 recommended_apps_(new RecommendedApps(profile)) { 119 recommended_apps_(new RecommendedApps(profile)) {
100 contents_.reset(content::WebContents::Create( 120 contents_.reset(content::WebContents::Create(
101 content::WebContents::CreateParams(profile_))); 121 content::WebContents::CreateParams(profile_)));
122 contents_delegate_.reset(new StartPageWebContentsDelegate());
123 contents_->SetDelegate(contents_delegate_.get());
102 124
103 GURL url(chrome::kChromeUIAppListStartPageURL); 125 GURL url(chrome::kChromeUIAppListStartPageURL);
104 CommandLine* command_line = CommandLine::ForCurrentProcess(); 126 CommandLine* command_line = CommandLine::ForCurrentProcess();
105 if (command_line->HasSwitch(switches::kAppListStartPageURL)) { 127 if (command_line->HasSwitch(switches::kAppListStartPageURL)) {
106 url = GURL( 128 url = GURL(
107 command_line->GetSwitchValueASCII(switches::kAppListStartPageURL)); 129 command_line->GetSwitchValueASCII(switches::kAppListStartPageURL));
108 } 130 }
109 131
110 contents_->GetController().LoadURL( 132 contents_->GetController().LoadURL(
111 url, 133 url,
112 content::Referrer(), 134 content::Referrer(),
113 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 135 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
114 std::string()); 136 std::string());
115 } 137 }
116 138
117 StartPageService::~StartPageService() {} 139 StartPageService::~StartPageService() {}
118 140
119 void StartPageService::Shutdown() { 141 void StartPageService::Shutdown() {
120 contents_.reset(); 142 contents_.reset();
121 } 143 }
122 144
123 } // namespace app_list 145 } // namespace app_list
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/start_page_service.h ('k') | chrome/browser/ui/webui/app_list/start_page_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698