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/views/ash/panel_view_aura.h" | 5 #include "chrome/browser/ui/views/ash/panel_view_aura.h" |
6 | 6 |
7 #include "ash/wm/panel_frame_view.h" | 7 #include "ash/wm/panel_frame_view.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
10 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 10 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
11 #include "chrome/browser/extensions/extension_process_manager.h" | 11 #include "chrome/browser/extensions/extension_process_manager.h" |
12 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
13 #include "chrome/browser/extensions/extension_tab_util.h" | 13 #include "chrome/browser/extensions/extension_tab_util.h" |
14 #include "chrome/browser/extensions/extension_window_controller.h" | 14 #include "chrome/browser/extensions/window_controller.h" |
15 #include "chrome/browser/extensions/extension_window_list.h" | |
16 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/sessions/session_id.h" | 16 #include "chrome/browser/sessions/session_id.h" |
18 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
20 #include "chrome/browser/ui/browser_tabstrip.h" | 19 #include "chrome/browser/ui/browser_tabstrip.h" |
21 #include "chrome/browser/view_type_utils.h" | 20 #include "chrome/browser/view_type_utils.h" |
22 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
23 #include "chrome/common/extensions/extension_messages.h" | 22 #include "chrome/common/extensions/extension_messages.h" |
24 #include "content/public/browser/site_instance.h" | 23 #include "content/public/browser/site_instance.h" |
25 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
(...skipping 25 matching lines...) Expand all Loading... |
51 public: | 50 public: |
52 PanelHost(PanelViewAura* panel_view, Profile* profile); | 51 PanelHost(PanelViewAura* panel_view, Profile* profile); |
53 virtual ~PanelHost(); | 52 virtual ~PanelHost(); |
54 | 53 |
55 void Init(const GURL& url); | 54 void Init(const GURL& url); |
56 | 55 |
57 content::WebContents* web_contents() const { return web_contents_.get(); } | 56 content::WebContents* web_contents() const { return web_contents_.get(); } |
58 Profile* profile() const { return profile_; } | 57 Profile* profile() const { return profile_; } |
59 | 58 |
60 // ExtensionFunctionDispatcher::Delegate overrides. | 59 // ExtensionFunctionDispatcher::Delegate overrides. |
61 virtual ExtensionWindowController* GetExtensionWindowController() | 60 virtual extensions::WindowController* GetExtensionWindowController() |
62 const OVERRIDE; | 61 const OVERRIDE; |
63 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | 62 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
64 | 63 |
65 // content::WebContentsDelegate implementation: | 64 // content::WebContentsDelegate implementation: |
66 virtual void CloseContents(content::WebContents* source) OVERRIDE; | 65 virtual void CloseContents(content::WebContents* source) OVERRIDE; |
67 virtual void HandleMouseDown() OVERRIDE; | 66 virtual void HandleMouseDown() OVERRIDE; |
68 virtual void UpdatePreferredSize(content::WebContents* source, | 67 virtual void UpdatePreferredSize(content::WebContents* source, |
69 const gfx::Size& pref_size) OVERRIDE; | 68 const gfx::Size& pref_size) OVERRIDE; |
70 virtual void AddNewContents(content::WebContents* source, | 69 virtual void AddNewContents(content::WebContents* source, |
71 content::WebContents* new_contents, | 70 content::WebContents* new_contents, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 web_contents_.reset(content::WebContents::Create( | 108 web_contents_.reset(content::WebContents::Create( |
110 profile_, site_instance_.get(), MSG_ROUTING_NONE, NULL, NULL)); | 109 profile_, site_instance_.get(), MSG_ROUTING_NONE, NULL, NULL)); |
111 chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_PANEL); | 110 chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_PANEL); |
112 web_contents_->SetDelegate(this); | 111 web_contents_->SetDelegate(this); |
113 Observe(web_contents_.get()); | 112 Observe(web_contents_.get()); |
114 | 113 |
115 web_contents_->GetController().LoadURL( | 114 web_contents_->GetController().LoadURL( |
116 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 115 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
117 } | 116 } |
118 | 117 |
119 ExtensionWindowController* PanelHost::GetExtensionWindowController() const { | 118 extensions::WindowController* PanelHost::GetExtensionWindowController() const { |
120 return panel_view_->extension_window_controller(); | 119 return panel_view_->extension_window_controller(); |
121 } | 120 } |
122 | 121 |
123 content::WebContents* PanelHost::GetAssociatedWebContents() const { | 122 content::WebContents* PanelHost::GetAssociatedWebContents() const { |
124 return web_contents_.get(); | 123 return web_contents_.get(); |
125 } | 124 } |
126 | 125 |
127 void PanelHost::CloseContents(content::WebContents* source) { | 126 void PanelHost::CloseContents(content::WebContents* source) { |
128 panel_view_->CloseView(); | 127 panel_view_->CloseView(); |
129 } | 128 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 171 } |
173 | 172 |
174 void PanelHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { | 173 void PanelHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { |
175 extension_function_dispatcher_.Dispatch(params, | 174 extension_function_dispatcher_.Dispatch(params, |
176 web_contents_->GetRenderViewHost()); | 175 web_contents_->GetRenderViewHost()); |
177 } | 176 } |
178 | 177 |
179 //////////////////////////////////////////////////////////////////////////////// | 178 //////////////////////////////////////////////////////////////////////////////// |
180 // PanelExtensionWindowController | 179 // PanelExtensionWindowController |
181 | 180 |
182 class PanelExtensionWindowController : public ExtensionWindowController { | 181 class PanelExtensionWindowController : public extensions::WindowController { |
183 public: | 182 public: |
184 PanelExtensionWindowController(PanelViewAura* panel_view, | 183 PanelExtensionWindowController(PanelViewAura* panel_view, |
185 PanelHost* panel_host); | 184 PanelHost* panel_host); |
186 | 185 |
187 // Overriden from ExtensionWindowController: | 186 // Overriden from extensions::WindowController: |
188 virtual int GetWindowId() const OVERRIDE; | 187 virtual int GetWindowId() const OVERRIDE; |
189 virtual std::string GetWindowTypeText() const OVERRIDE; | 188 virtual std::string GetWindowTypeText() const OVERRIDE; |
190 virtual base::DictionaryValue* CreateWindowValue() const OVERRIDE; | 189 virtual base::DictionaryValue* CreateWindowValue() const OVERRIDE; |
191 virtual base::DictionaryValue* CreateWindowValueWithTabs() const OVERRIDE; | 190 virtual base::DictionaryValue* CreateWindowValueWithTabs() const OVERRIDE; |
192 virtual bool CanClose(Reason* reason) const OVERRIDE; | 191 virtual bool CanClose(Reason* reason) const OVERRIDE; |
193 virtual void SetFullscreenMode(bool is_fullscreen, | 192 virtual void SetFullscreenMode(bool is_fullscreen, |
194 const GURL& extension_url) const OVERRIDE; | 193 const GURL& extension_url) const OVERRIDE; |
195 virtual bool IsVisibleToExtension( | 194 virtual bool IsVisibleToExtension( |
196 const extensions::Extension* extension) const OVERRIDE; | 195 const extensions::Extension* extension) const OVERRIDE; |
197 | 196 |
198 private: | 197 private: |
199 PanelViewAura* panel_view_; | 198 PanelViewAura* panel_view_; |
200 PanelHost* panel_host_; | 199 PanelHost* panel_host_; |
201 | 200 |
202 DISALLOW_COPY_AND_ASSIGN(PanelExtensionWindowController); | 201 DISALLOW_COPY_AND_ASSIGN(PanelExtensionWindowController); |
203 }; | 202 }; |
204 | 203 |
205 PanelExtensionWindowController::PanelExtensionWindowController( | 204 PanelExtensionWindowController::PanelExtensionWindowController( |
206 PanelViewAura* panel_view, | 205 PanelViewAura* panel_view, |
207 PanelHost* panel_host) | 206 PanelHost* panel_host) |
208 : ExtensionWindowController(panel_view, panel_host->profile()), | 207 : extensions::WindowController(panel_view, panel_host->profile()), |
209 panel_view_(panel_view), | 208 panel_view_(panel_view), |
210 panel_host_(panel_host) { | 209 panel_host_(panel_host) { |
211 } | 210 } |
212 | 211 |
213 int PanelExtensionWindowController::GetWindowId() const { | 212 int PanelExtensionWindowController::GetWindowId() const { |
214 return static_cast<int>(panel_view_->session_id().id()); | 213 return static_cast<int>(panel_view_->session_id().id()); |
215 } | 214 } |
216 | 215 |
217 std::string PanelExtensionWindowController::GetWindowTypeText() const { | 216 std::string PanelExtensionWindowController::GetWindowTypeText() const { |
218 return keys::kWindowTypeValuePanel; | 217 return keys::kWindowTypeValuePanel; |
219 } | 218 } |
220 | 219 |
221 base::DictionaryValue* | 220 base::DictionaryValue* |
222 PanelExtensionWindowController::CreateWindowValue() const { | 221 PanelExtensionWindowController::CreateWindowValue() const { |
223 DictionaryValue* result = ExtensionWindowController::CreateWindowValue(); | 222 DictionaryValue* result = extensions::WindowController::CreateWindowValue(); |
224 return result; | 223 return result; |
225 } | 224 } |
226 | 225 |
227 base::DictionaryValue* | 226 base::DictionaryValue* |
228 PanelExtensionWindowController::CreateWindowValueWithTabs() const { | 227 PanelExtensionWindowController::CreateWindowValueWithTabs() const { |
229 DictionaryValue* result = CreateWindowValue(); | 228 DictionaryValue* result = CreateWindowValue(); |
230 | 229 |
231 // TODO(stevenjb): Implement tab interface for Aura panels. | 230 // TODO(stevenjb): Implement tab interface for Aura panels. |
232 // Currently there is no mechanism to get a tab id without an associated | 231 // Currently there is no mechanism to get a tab id without an associated |
233 // TabContents. We will need to either add a TabContents for | 232 // TabContents. We will need to either add a TabContents for |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 } | 446 } |
448 | 447 |
449 void PanelViewAura::FlashFrame(bool flash) { | 448 void PanelViewAura::FlashFrame(bool flash) { |
450 // TODO(stevenjb): Implement | 449 // TODO(stevenjb): Implement |
451 NOTIMPLEMENTED(); | 450 NOTIMPLEMENTED(); |
452 } | 451 } |
453 | 452 |
454 bool PanelViewAura::IsAlwaysOnTop() const { | 453 bool PanelViewAura::IsAlwaysOnTop() const { |
455 return true; | 454 return true; |
456 } | 455 } |
OLD | NEW |