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

Side by Side Diff: chrome/browser/ui/panels/panel_browser_window.cc

Issue 10908153: [Panel refactor] Deprecate old panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux_chromeos test failure Created 8 years, 3 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/panels/panel_browser_window.h"
6
7 #include "base/logging.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/panels/panel.h"
12 #include "chrome/browser/ui/panels/native_panel.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/browser/ui/window_sizer/window_sizer.h"
16 #include "content/public/browser/web_contents.h"
17 #include "ui/gfx/rect.h"
18
19 #if defined(USE_AURA)
20 #include "chrome/browser/ui/panels/panel_browser_view.h"
21 #endif
22
23 using content::NativeWebKeyboardEvent;
24 using content::SSLStatus;
25 using content::WebContents;
26
27 PanelBrowserWindow::PanelBrowserWindow(Browser* browser, Panel* panel,
28 NativePanel* native_panel)
29 : browser_(browser),
30 panel_(panel),
31 native_panel_(native_panel) {
32 browser_->tab_strip_model()->AddObserver(this);
33 }
34
35 PanelBrowserWindow::~PanelBrowserWindow() {
36 browser_->tab_strip_model()->RemoveObserver(this);
37 // Invoked by native panel destructor via panel destructor.
38 // Do not access native_panel_ nor panel_ here.
39 }
40
41 // ----------------------------------------------
42 // BaseWindow interface - just delegates to Panel
43 // ----------------------------------------------
44 bool PanelBrowserWindow::IsActive() const {
45 return panel_->IsActive();
46 }
47
48 bool PanelBrowserWindow::IsMaximized() const {
49 return panel_->IsMaximized();
50 }
51
52 bool PanelBrowserWindow::IsMinimized() const {
53 return panel_->IsMinimized();
54 }
55
56 bool PanelBrowserWindow::IsFullscreen() const {
57 return panel_->IsFullscreen();
58 }
59
60 gfx::Rect PanelBrowserWindow::GetRestoredBounds() const {
61 return panel_->GetRestoredBounds();
62 }
63
64 gfx::Rect PanelBrowserWindow::GetBounds() const {
65 return panel_->GetBounds();
66 }
67
68 void PanelBrowserWindow::Show() {
69 panel_->Show();
70 }
71
72 void PanelBrowserWindow::ShowInactive() {
73 panel_->ShowInactive();
74 }
75
76 void PanelBrowserWindow::Close() {
77 panel_->Close();
78 }
79
80 void PanelBrowserWindow::Activate() {
81 panel_->Activate();
82 }
83
84 void PanelBrowserWindow::Deactivate() {
85 panel_->Deactivate();
86 }
87
88 void PanelBrowserWindow::Maximize() {
89 panel_->Maximize();
90 }
91
92 void PanelBrowserWindow::Minimize() {
93 panel_->Minimize();
94 }
95
96 void PanelBrowserWindow::Restore() {
97 panel_->Restore();
98 }
99
100 void PanelBrowserWindow::SetBounds(const gfx::Rect& bounds) {
101 panel_->SetBounds(bounds);
102 }
103
104 void PanelBrowserWindow::FlashFrame(bool flash) {
105 panel_->FlashFrame(flash);
106 }
107
108 bool PanelBrowserWindow::IsAlwaysOnTop() const {
109 return panel_->IsAlwaysOnTop();
110 }
111
112 // ------------------------------------------------------------
113 // BrowserWindow interface - either does nothing, delegates to
114 // native panel, delegates to Panel (WebContents handling)
115 // or invoke logic that has nothing to do with panels (GetDownloadShelf).
116 // -----------------------------------------------------------
117 gfx::NativeWindow PanelBrowserWindow::GetNativeWindow() {
118 return native_panel_->GetNativePanelHandle();
119 }
120
121 BrowserWindowTesting* PanelBrowserWindow::GetBrowserWindowTesting() {
122 NOTIMPLEMENTED();
123 return NULL;
124 }
125
126 StatusBubble* PanelBrowserWindow::GetStatusBubble() {
127 // TODO(jennb): Implement. http://crbug.com/102723
128 return NULL;
129 }
130
131 void PanelBrowserWindow::UpdateTitleBar() {
132 native_panel_->UpdatePanelTitleBar();
133 }
134
135 void PanelBrowserWindow::BookmarkBarStateChanged(
136 BookmarkBar::AnimateChangeType change_type) {
137 NOTIMPLEMENTED();
138 }
139
140 void PanelBrowserWindow::UpdateDevTools() {
141 NOTIMPLEMENTED();
142 }
143
144 void PanelBrowserWindow::SetDevToolsDockSide(DevToolsDockSide side) {
145 NOTIMPLEMENTED();
146 }
147
148 void PanelBrowserWindow::UpdateLoadingAnimations(bool should_animate) {
149 native_panel_->UpdatePanelLoadingAnimations(should_animate);
150 }
151
152 void PanelBrowserWindow::SetStarredState(bool is_starred) {
153 // Since panels are typically not bookmarked extension UI windows, they don't
154 // have starred state.
155 }
156
157 void PanelBrowserWindow::ZoomChangedForActiveTab(bool can_show_bubble) {
158 // Since panels don't have an Omnibox, they don't have a zoom icon, so no
159 // view icon nor bubble will appear for this action.
160 }
161
162 void PanelBrowserWindow::EnterFullscreen(
163 const GURL& url, FullscreenExitBubbleType type) {
164 NOTIMPLEMENTED();
165 }
166
167 void PanelBrowserWindow::ExitFullscreen() {
168 NOTIMPLEMENTED();
169 }
170
171 #if defined(OS_WIN)
172 void PanelBrowserWindow::SetMetroSnapMode(bool enable) {
173 NOTIMPLEMENTED();
174 }
175
176 bool PanelBrowserWindow::IsInMetroSnapMode() const {
177 NOTIMPLEMENTED();
178 return false;
179 }
180 #endif
181
182 void PanelBrowserWindow::UpdateFullscreenExitBubbleContent(
183 const GURL& url,
184 FullscreenExitBubbleType bubble_type) {
185 NOTIMPLEMENTED();
186 }
187
188 bool PanelBrowserWindow::IsFullscreenBubbleVisible() const {
189 NOTIMPLEMENTED();
190 return false;
191 }
192
193 LocationBar* PanelBrowserWindow::GetLocationBar() const {
194 #if defined(USE_AURA)
195 // TODO(stevenjb): Remove this when Aura panels are implemented post R18.
196 PanelBrowserView* panel_view = static_cast<PanelBrowserView*>(native_panel_);
197 return panel_view->GetLocationBar();
198 #else
199 // Panels do not have a location bar.
200 return NULL;
201 #endif
202 }
203
204 void PanelBrowserWindow::SetFocusToLocationBar(bool select_all) {
205 #if defined(USE_AURA)
206 // TODO(stevenjb): Remove this when Aura panels are implemented post R18.
207 PanelBrowserView* panel_view = static_cast<PanelBrowserView*>(native_panel_);
208 panel_view->SetFocusToLocationBar(select_all);
209 #else
210 // Panels do not have a location bar.
211 #endif
212 }
213
214 void PanelBrowserWindow::UpdateReloadStopState(bool is_loading, bool force) {
215 // Panels don't have stop/reload indicator.
216 }
217
218 void PanelBrowserWindow::UpdateToolbar(TabContents* contents,
219 bool should_restore_state) {
220 // Panels do not have a toolbar.
221 }
222
223 void PanelBrowserWindow::FocusToolbar() {
224 // Panels do not have a toolbar.
225 }
226
227 void PanelBrowserWindow::FocusAppMenu() {
228 NOTIMPLEMENTED();
229 }
230
231 void PanelBrowserWindow::FocusBookmarksToolbar() {
232 NOTIMPLEMENTED();
233 }
234
235 void PanelBrowserWindow::RotatePaneFocus(bool forwards) {
236 NOTIMPLEMENTED();
237 }
238
239 bool PanelBrowserWindow::IsBookmarkBarVisible() const {
240 return false;
241 }
242
243 bool PanelBrowserWindow::IsBookmarkBarAnimating() const {
244 return false;
245 }
246
247 // This is used by extensions to decide if a window can be closed.
248 // Always return true as panels do not have tabs that can be dragged,
249 // during which extensions will avoid closing a window.
250 bool PanelBrowserWindow::IsTabStripEditable() const {
251 return true;
252 }
253
254 bool PanelBrowserWindow::IsToolbarVisible() const {
255 NOTIMPLEMENTED();
256 return false;
257 }
258
259 gfx::Rect PanelBrowserWindow::GetRootWindowResizerRect() const {
260 return gfx::Rect();
261 }
262
263 bool PanelBrowserWindow::IsPanel() const {
264 return true;
265 }
266
267 void PanelBrowserWindow::DisableInactiveFrame() {
268 NOTIMPLEMENTED();
269 }
270
271 void PanelBrowserWindow::ConfirmAddSearchProvider(TemplateURL* template_url,
272 Profile* profile) {
273 NOTIMPLEMENTED();
274 }
275
276 void PanelBrowserWindow::ToggleBookmarkBar() {
277 NOTIMPLEMENTED();
278 }
279
280 void PanelBrowserWindow::ShowUpdateChromeDialog() {
281 NOTIMPLEMENTED();
282 }
283
284 void PanelBrowserWindow::ShowTaskManager() {
285 native_panel_->ShowTaskManagerForPanel();
286 }
287
288 void PanelBrowserWindow::ShowBackgroundPages() {
289 NOTIMPLEMENTED();
290 }
291
292 void PanelBrowserWindow::ShowBookmarkBubble(const GURL& url,
293 bool already_bookmarked) {
294 NOTIMPLEMENTED();
295 }
296
297 void PanelBrowserWindow::ShowChromeToMobileBubble() {
298 NOTIMPLEMENTED();
299 }
300
301 #if defined(ENABLE_ONE_CLICK_SIGNIN)
302 void PanelBrowserWindow::ShowOneClickSigninBubble(
303 const StartSyncCallback& start_sync_callback) {
304 NOTIMPLEMENTED();
305 }
306 #endif
307
308 bool PanelBrowserWindow::IsDownloadShelfVisible() const {
309 return false;
310 }
311
312 DownloadShelf* PanelBrowserWindow::GetDownloadShelf() {
313 Profile* profile = browser_->profile();
314 Browser* tabbed_browser = browser::FindTabbedBrowser(profile, true);
315
316 if (!tabbed_browser) {
317 // Set initial bounds so window will not be positioned at an offset
318 // to this panel as panels are at the bottom of the screen.
319 gfx::Rect window_bounds;
320 WindowSizer::GetBrowserWindowBounds(std::string(), gfx::Rect(),
321 browser_, &window_bounds);
322 Browser::CreateParams params(Browser::TYPE_TABBED, profile);
323 params.initial_bounds = window_bounds;
324 tabbed_browser = new Browser(params);
325 chrome::NewTab(tabbed_browser);
326 }
327
328 tabbed_browser->window()->Show(); // Ensure download shelf is visible.
329 return tabbed_browser->window()->GetDownloadShelf();
330 }
331
332 void PanelBrowserWindow::ConfirmBrowserCloseWithPendingDownloads() {
333 NOTIMPLEMENTED();
334 }
335
336 void PanelBrowserWindow::UserChangedTheme() {
337 native_panel_->NotifyPanelOnUserChangedTheme();
338 }
339
340 int PanelBrowserWindow::GetExtraRenderViewHeight() const {
341 // This is currently used only on Linux and that returns the height for
342 // optional elements like bookmark bar, download bar etc. Not applicable to
343 // panels.
344 return 0;
345 }
346
347 void PanelBrowserWindow::WebContentsFocused(WebContents* contents) {
348 native_panel_->PanelWebContentsFocused(contents);
349 }
350
351 void PanelBrowserWindow::ShowPageInfo(WebContents* web_contents,
352 const GURL& url,
353 const SSLStatus& ssl,
354 bool show_history) {
355 NOTIMPLEMENTED();
356 }
357 void PanelBrowserWindow::ShowWebsiteSettings(
358 Profile* profile,
359 TabContents* tab_contents,
360 const GURL& url,
361 const content::SSLStatus& ssl,
362 bool show_history) {
363 NOTIMPLEMENTED();
364 }
365
366 void PanelBrowserWindow::ShowAppMenu() {
367 NOTIMPLEMENTED();
368 }
369
370 bool PanelBrowserWindow::PreHandleKeyboardEvent(
371 const content::NativeWebKeyboardEvent& event,
372 bool* is_keyboard_shortcut) {
373 return native_panel_->PreHandlePanelKeyboardEvent(event,
374 is_keyboard_shortcut);
375 }
376
377 void PanelBrowserWindow::HandleKeyboardEvent(
378 const content::NativeWebKeyboardEvent& event) {
379 native_panel_->HandlePanelKeyboardEvent(event);
380 }
381
382 void PanelBrowserWindow::ShowCreateChromeAppShortcutsDialog(
383 Profile* profile,
384 const extensions::Extension* app) {
385 NOTIMPLEMENTED();
386 }
387
388 void PanelBrowserWindow::Cut() {
389 native_panel_->PanelCut();
390 }
391
392 void PanelBrowserWindow::Copy() {
393 native_panel_->PanelCopy();
394 }
395
396 void PanelBrowserWindow::Paste() {
397 native_panel_->PanelPaste();
398 }
399
400 #if defined(OS_MACOSX)
401 void PanelBrowserWindow::OpenTabpose() {
402 NOTIMPLEMENTED();
403 }
404
405 void PanelBrowserWindow::EnterPresentationMode(
406 const GURL& url,
407 FullscreenExitBubbleType content_type) {
408 NOTIMPLEMENTED();
409 }
410
411 void PanelBrowserWindow::ExitPresentationMode() {
412 NOTIMPLEMENTED();
413 }
414
415 bool PanelBrowserWindow::InPresentationMode() {
416 NOTIMPLEMENTED();
417 return false;
418 }
419 #endif
420
421 void PanelBrowserWindow::ShowInstant(TabContents* preview) {
422 NOTIMPLEMENTED();
423 }
424
425 void PanelBrowserWindow::HideInstant() {
426 NOTIMPLEMENTED();
427 }
428
429 gfx::Rect PanelBrowserWindow::GetInstantBounds() {
430 NOTIMPLEMENTED();
431 return gfx::Rect();
432 }
433
434 bool PanelBrowserWindow::IsInstantTabShowing() {
435 NOTIMPLEMENTED();
436 return false;
437 }
438
439 WindowOpenDisposition PanelBrowserWindow::GetDispositionForPopupBounds(
440 const gfx::Rect& bounds) {
441 #if defined(USE_AURA)
442 // TODO(stevenjb): Remove this when Aura panels are implemented post R18.
443 PanelBrowserView* panel_view = static_cast<PanelBrowserView*>(native_panel_);
444 return panel_view->GetDispositionForPopupBounds(bounds);
445 #else
446 return NEW_POPUP;
447 #endif
448 }
449
450 FindBar* PanelBrowserWindow::CreateFindBar() {
451 return native_panel_->CreatePanelFindBar();
452 }
453
454 void PanelBrowserWindow::ResizeDueToAutoResize(WebContents* web_contents,
455 const gfx::Size& pref_size) {
456 DCHECK(panel_->auto_resizable());
457 return panel_->OnContentsAutoResized(pref_size);
458 }
459
460 void PanelBrowserWindow::ShowAvatarBubble(WebContents* web_contents,
461 const gfx::Rect& rect) {
462 // Panels will never show a new tab page so this should never be called.
463 NOTREACHED();
464 }
465
466 void PanelBrowserWindow::ShowAvatarBubbleFromAvatarButton() {
467 // Panels will never show an avatar button so this should never be called.
468 NOTREACHED();
469 }
470
471 void PanelBrowserWindow::DestroyBrowser() {
472 native_panel_->DestroyPanelBrowser();
473 }
474
475 void PanelBrowserWindow::TabInsertedAt(TabContents* contents,
476 int index,
477 bool foreground) {
478 if (panel_->auto_resizable()) {
479 DCHECK_EQ(0, index);
480 panel_->EnableWebContentsAutoResize(contents->web_contents());
481 }
482 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_window.h ('k') | chrome/browser/ui/panels/panel_browser_window_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698