OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "apps/custom_launcher_page_contents.h" | 5 #include "apps/custom_launcher_page_contents.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "apps/app_delegate.h" | |
10 #include "apps/app_web_contents_helper.h" | |
11 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 10 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
13 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
14 #include "content/public/browser/site_instance.h" | 12 #include "content/public/browser/site_instance.h" |
15 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
16 #include "content/public/common/renderer_preferences.h" | 14 #include "content/public/common/renderer_preferences.h" |
| 15 #include "extensions/browser/app_window/app_delegate.h" |
| 16 #include "extensions/browser/app_window/app_web_contents_helper.h" |
17 #include "extensions/browser/view_type_utils.h" | 17 #include "extensions/browser/view_type_utils.h" |
18 #include "extensions/common/extension_messages.h" | 18 #include "extensions/common/extension_messages.h" |
19 | 19 |
20 namespace apps { | 20 namespace apps { |
21 | 21 |
22 CustomLauncherPageContents::CustomLauncherPageContents( | 22 CustomLauncherPageContents::CustomLauncherPageContents( |
23 scoped_ptr<AppDelegate> app_delegate, | 23 scoped_ptr<extensions::AppDelegate> app_delegate, |
24 const std::string& extension_id) | 24 const std::string& extension_id) |
25 : app_delegate_(app_delegate.Pass()), extension_id_(extension_id) { | 25 : app_delegate_(app_delegate.Pass()), extension_id_(extension_id) { |
26 } | 26 } |
27 | 27 |
28 CustomLauncherPageContents::~CustomLauncherPageContents() { | 28 CustomLauncherPageContents::~CustomLauncherPageContents() { |
29 } | 29 } |
30 | 30 |
31 void CustomLauncherPageContents::Initialize(content::BrowserContext* context, | 31 void CustomLauncherPageContents::Initialize(content::BrowserContext* context, |
32 const GURL& url) { | 32 const GURL& url) { |
33 extension_function_dispatcher_.reset( | 33 extension_function_dispatcher_.reset( |
34 new extensions::ExtensionFunctionDispatcher(context, this)); | 34 new extensions::ExtensionFunctionDispatcher(context, this)); |
35 | 35 |
36 web_contents_.reset( | 36 web_contents_.reset( |
37 content::WebContents::Create(content::WebContents::CreateParams( | 37 content::WebContents::Create(content::WebContents::CreateParams( |
38 context, content::SiteInstance::CreateForURL(context, url)))); | 38 context, content::SiteInstance::CreateForURL(context, url)))); |
39 | 39 |
40 Observe(web_contents()); | 40 Observe(web_contents()); |
41 web_contents_->GetMutableRendererPrefs() | 41 web_contents_->GetMutableRendererPrefs() |
42 ->browser_handles_all_top_level_requests = true; | 42 ->browser_handles_all_top_level_requests = true; |
43 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 43 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
44 | 44 |
45 helper_.reset(new AppWebContentsHelper( | 45 helper_.reset(new extensions::AppWebContentsHelper( |
46 context, extension_id_, web_contents_.get(), app_delegate_.get())); | 46 context, extension_id_, web_contents_.get(), app_delegate_.get())); |
47 web_contents_->SetDelegate(this); | 47 web_contents_->SetDelegate(this); |
48 | 48 |
49 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_LAUNCHER_PAGE); | 49 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_LAUNCHER_PAGE); |
50 | 50 |
51 // This observer will activate the extension when it is navigated to, which | 51 // This observer will activate the extension when it is navigated to, which |
52 // allows Dispatcher to give it the proper context and makes it behave like an | 52 // allows Dispatcher to give it the proper context and makes it behave like an |
53 // extension. | 53 // extension. |
54 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( | 54 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
55 web_contents()); | 55 web_contents()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
90 bool CustomLauncherPageContents::ShouldSuppressDialogs() { | 90 bool CustomLauncherPageContents::ShouldSuppressDialogs() { |
91 return true; | 91 return true; |
92 } | 92 } |
93 | 93 |
94 bool CustomLauncherPageContents::PreHandleGestureEvent( | 94 bool CustomLauncherPageContents::PreHandleGestureEvent( |
95 content::WebContents* source, | 95 content::WebContents* source, |
96 const blink::WebGestureEvent& event) { | 96 const blink::WebGestureEvent& event) { |
97 return AppWebContentsHelper::ShouldSuppressGestureEvent(event); | 97 return extensions::AppWebContentsHelper::ShouldSuppressGestureEvent(event); |
98 } | 98 } |
99 | 99 |
100 content::ColorChooser* CustomLauncherPageContents::OpenColorChooser( | 100 content::ColorChooser* CustomLauncherPageContents::OpenColorChooser( |
101 content::WebContents* web_contents, | 101 content::WebContents* web_contents, |
102 SkColor initial_color, | 102 SkColor initial_color, |
103 const std::vector<content::ColorSuggestion>& suggestionss) { | 103 const std::vector<content::ColorSuggestion>& suggestionss) { |
104 return app_delegate_->ShowColorChooser(web_contents, initial_color); | 104 return app_delegate_->ShowColorChooser(web_contents, initial_color); |
105 } | 105 } |
106 | 106 |
107 void CustomLauncherPageContents::RunFileChooser( | 107 void CustomLauncherPageContents::RunFileChooser( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 return web_contents(); | 146 return web_contents(); |
147 } | 147 } |
148 | 148 |
149 void CustomLauncherPageContents::OnRequest( | 149 void CustomLauncherPageContents::OnRequest( |
150 const ExtensionHostMsg_Request_Params& params) { | 150 const ExtensionHostMsg_Request_Params& params) { |
151 extension_function_dispatcher_->Dispatch(params, | 151 extension_function_dispatcher_->Dispatch(params, |
152 web_contents_->GetRenderViewHost()); | 152 web_contents_->GetRenderViewHost()); |
153 } | 153 } |
154 | 154 |
155 } // namespace apps | 155 } // namespace apps |
OLD | NEW |