OLD | NEW |
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 85 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
84 service_->Shutdown(); | 86 service_->Shutdown(); |
85 } | 87 } |
86 | 88 |
87 StartPageService* service_; // Owner of this class. | 89 StartPageService* service_; // Owner of this class. |
88 content::NotificationRegistrar registrar_; | 90 content::NotificationRegistrar registrar_; |
89 | 91 |
90 DISALLOW_COPY_AND_ASSIGN(ProfileDestroyObserver); | 92 DISALLOW_COPY_AND_ASSIGN(ProfileDestroyObserver); |
91 }; | 93 }; |
92 | 94 |
| 95 class StartPageService::StartPageWebContentsDelegate |
| 96 : public content::WebContentsDelegate { |
| 97 public: |
| 98 StartPageWebContentsDelegate() {} |
| 99 virtual ~StartPageWebContentsDelegate() {} |
| 100 |
| 101 virtual void RequestMediaAccessPermission( |
| 102 content::WebContents* web_contents, |
| 103 const content::MediaStreamRequest& request, |
| 104 const content::MediaResponseCallback& callback) OVERRIDE { |
| 105 if (MediaStreamInfoBarDelegate::Create(web_contents, request, callback)) |
| 106 NOTREACHED() << "Media stream not allowed for WebUI"; |
| 107 } |
| 108 |
| 109 private: |
| 110 DISALLOW_COPY_AND_ASSIGN(StartPageWebContentsDelegate); |
| 111 }; |
| 112 |
93 // static | 113 // static |
94 StartPageService* StartPageService::Get(Profile* profile) { | 114 StartPageService* StartPageService::Get(Profile* profile) { |
95 return Factory::GetForProfile(profile); | 115 return Factory::GetForProfile(profile); |
96 } | 116 } |
97 | 117 |
98 StartPageService::StartPageService(Profile* profile) | 118 StartPageService::StartPageService(Profile* profile) |
99 : profile_(profile), | 119 : profile_(profile), |
100 profile_destroy_observer_(new ProfileDestroyObserver(this)), | 120 profile_destroy_observer_(new ProfileDestroyObserver(this)), |
101 recommended_apps_(new RecommendedApps(profile)) { | 121 recommended_apps_(new RecommendedApps(profile)) { |
102 contents_.reset(content::WebContents::Create( | 122 contents_.reset(content::WebContents::Create( |
103 content::WebContents::CreateParams(profile_))); | 123 content::WebContents::CreateParams(profile_))); |
| 124 contents_delegate_.reset(new StartPageWebContentsDelegate()); |
| 125 contents_->SetDelegate(contents_delegate_.get()); |
104 | 126 |
105 GURL url(chrome::kChromeUIAppListStartPageURL); | 127 GURL url(chrome::kChromeUIAppListStartPageURL); |
106 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 128 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
107 if (command_line->HasSwitch(switches::kAppListStartPageURL)) { | 129 if (command_line->HasSwitch(switches::kAppListStartPageURL)) { |
108 url = GURL( | 130 url = GURL( |
109 command_line->GetSwitchValueASCII(switches::kAppListStartPageURL)); | 131 command_line->GetSwitchValueASCII(switches::kAppListStartPageURL)); |
110 } | 132 } |
111 | 133 |
112 contents_->GetController().LoadURL( | 134 contents_->GetController().LoadURL( |
113 url, | 135 url, |
114 content::Referrer(), | 136 content::Referrer(), |
115 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 137 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
116 std::string()); | 138 std::string()); |
117 } | 139 } |
118 | 140 |
119 StartPageService::~StartPageService() {} | 141 StartPageService::~StartPageService() {} |
120 | 142 |
121 void StartPageService::Shutdown() { | 143 void StartPageService::Shutdown() { |
122 contents_.reset(); | 144 contents_.reset(); |
123 } | 145 } |
124 | 146 |
125 } // namespace app_list | 147 } // namespace app_list |
OLD | NEW |