| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/shell_window.h" | 5 #include "chrome/browser/ui/extensions/shell_window.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_process_manager.h" | 8 #include "chrome/browser/extensions/extension_process_manager.h" |
| 9 #include "chrome/browser/extensions/shell_window_registry.h" | 9 #include "chrome/browser/extensions/shell_window_registry.h" |
| 10 #include "chrome/browser/file_select_helper.h" | 10 #include "chrome/browser/file_select_helper.h" |
| 11 #include "chrome/browser/intents/web_intents_util.h" | 11 #include "chrome/browser/intents/web_intents_util.h" |
| 12 #include "chrome/browser/lifetime/application_lifetime.h" | 12 #include "chrome/browser/lifetime/application_lifetime.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/sessions/session_id.h" | 14 #include "chrome/browser/sessions/session_id.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 16 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
| 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 18 #include "chrome/browser/view_type_utils.h" | 18 #include "chrome/browser/view_type_utils.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 21 #include "chrome/common/extensions/extension_messages.h" | 21 #include "chrome/common/extensions/extension_messages.h" |
| 22 #include "content/public/browser/invalidate_type.h" | 22 #include "content/public/browser/invalidate_type.h" |
| 23 #include "content/public/browser/navigation_entry.h" | 23 #include "content/public/browser/navigation_entry.h" |
| 24 #include "content/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
| 25 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
| 26 #include "content/public/browser/notification_source.h" | 26 #include "content/public/browser/notification_source.h" |
| 27 #include "content/public/browser/notification_types.h" | 27 #include "content/public/browser/notification_types.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 ALLOW_THIS_IN_INITIALIZER_LIST( | 60 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 61 extension_function_dispatcher_(profile, this)) { | 61 extension_function_dispatcher_(profile, this)) { |
| 62 // TODO(jeremya) this should all be done in an Init() method, not in the | 62 // TODO(jeremya) this should all be done in an Init() method, not in the |
| 63 // constructor. During this code, WebContents will be calling | 63 // constructor. During this code, WebContents will be calling |
| 64 // WebContentsDelegate methods, but at this point the vftables for the | 64 // WebContentsDelegate methods, but at this point the vftables for the |
| 65 // subclass are not yet in place, since it's still halfway through its | 65 // subclass are not yet in place, since it's still halfway through its |
| 66 // constructor. As a result, overridden virtual methods won't be called. | 66 // constructor. As a result, overridden virtual methods won't be called. |
| 67 web_contents_ = WebContents::Create( | 67 web_contents_ = WebContents::Create( |
| 68 profile, SiteInstance::CreateForURL(profile, url), MSG_ROUTING_NONE, NULL, | 68 profile, SiteInstance::CreateForURL(profile, url), MSG_ROUTING_NONE, NULL, |
| 69 NULL); | 69 NULL); |
| 70 contents_wrapper_.reset(new TabContentsWrapper(web_contents_)); | 70 contents_.reset(new TabContents(web_contents_)); |
| 71 content::WebContentsObserver::Observe(web_contents_); | 71 content::WebContentsObserver::Observe(web_contents_); |
| 72 web_contents_->SetDelegate(this); | 72 web_contents_->SetDelegate(this); |
| 73 chrome::SetViewType(web_contents_, chrome::VIEW_TYPE_APP_SHELL); | 73 chrome::SetViewType(web_contents_, chrome::VIEW_TYPE_APP_SHELL); |
| 74 web_contents_->GetMutableRendererPrefs()-> | 74 web_contents_->GetMutableRendererPrefs()-> |
| 75 browser_handles_all_top_level_requests = true; | 75 browser_handles_all_top_level_requests = true; |
| 76 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 76 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
| 77 | 77 |
| 78 web_contents_->GetController().LoadURL( | 78 web_contents_->GetController().LoadURL( |
| 79 url, content::Referrer(), content::PAGE_TRANSITION_LINK, | 79 url, content::Referrer(), content::PAGE_TRANSITION_LINK, |
| 80 std::string()); | 80 std::string()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 bool ShellWindow::ShouldSuppressDialogs() { | 132 bool ShellWindow::ShouldSuppressDialogs() { |
| 133 return true; | 133 return true; |
| 134 } | 134 } |
| 135 | 135 |
| 136 void ShellWindow::WebIntentDispatch( | 136 void ShellWindow::WebIntentDispatch( |
| 137 content::WebContents* web_contents, | 137 content::WebContents* web_contents, |
| 138 content::WebIntentsDispatcher* intents_dispatcher) { | 138 content::WebIntentsDispatcher* intents_dispatcher) { |
| 139 if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) | 139 if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) |
| 140 return; | 140 return; |
| 141 | 141 |
| 142 contents_wrapper_->web_intent_picker_controller()->SetIntentsDispatcher( | 142 contents_->web_intent_picker_controller()->SetIntentsDispatcher( |
| 143 intents_dispatcher); | 143 intents_dispatcher); |
| 144 contents_wrapper_->web_intent_picker_controller()->ShowDialog( | 144 contents_->web_intent_picker_controller()->ShowDialog( |
| 145 intents_dispatcher->GetIntent().action, | 145 intents_dispatcher->GetIntent().action, |
| 146 intents_dispatcher->GetIntent().type); | 146 intents_dispatcher->GetIntent().type); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void ShellWindow::RunFileChooser(WebContents* tab, | 149 void ShellWindow::RunFileChooser(WebContents* tab, |
| 150 const content::FileChooserParams& params) { | 150 const content::FileChooserParams& params) { |
| 151 FileSelectHelper::RunFileChooser(tab, params); | 151 FileSelectHelper::RunFileChooser(tab, params); |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool ShellWindow::IsPopupOrPanel(const WebContents* source) const { | 154 bool ShellWindow::IsPopupOrPanel(const WebContents* source) const { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 | 202 |
| 203 ExtensionWindowController* ShellWindow::GetExtensionWindowController() const { | 203 ExtensionWindowController* ShellWindow::GetExtensionWindowController() const { |
| 204 return NULL; | 204 return NULL; |
| 205 } | 205 } |
| 206 | 206 |
| 207 void ShellWindow::OnRequest(const ExtensionHostMsg_Request_Params& params) { | 207 void ShellWindow::OnRequest(const ExtensionHostMsg_Request_Params& params) { |
| 208 extension_function_dispatcher_.Dispatch(params, | 208 extension_function_dispatcher_.Dispatch(params, |
| 209 web_contents_->GetRenderViewHost()); | 209 web_contents_->GetRenderViewHost()); |
| 210 } | 210 } |
| OLD | NEW |