| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 delete tabstrip_; | 376 delete tabstrip_; |
| 377 tabstrip_ = NULL; | 377 tabstrip_ = NULL; |
| 378 } | 378 } |
| 379 // Child views maintain PrefMember attributes that point to | 379 // Child views maintain PrefMember attributes that point to |
| 380 // OffTheRecordProfile's PrefService which gets deleted by ~Browser. | 380 // OffTheRecordProfile's PrefService which gets deleted by ~Browser. |
| 381 RemoveAllChildViews(true); | 381 RemoveAllChildViews(true); |
| 382 // Explicitly set browser_ to NULL. | 382 // Explicitly set browser_ to NULL. |
| 383 browser_.reset(); | 383 browser_.reset(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 // Tab dragging code on windows needs this. |
| 387 #if defined(OS_WIN) && !defined(USE_AURA) |
| 386 // static | 388 // static |
| 387 BrowserView* BrowserView::GetBrowserViewForNativeWindow( | 389 BrowserView* BrowserView::GetBrowserViewForNativeWindow( |
| 388 gfx::NativeWindow window) { | 390 gfx::NativeWindow window) { |
| 389 #if defined(USE_AURA) | 391 return IsWindow(window) ? reinterpret_cast<BrowserView*>( |
| 390 // TODO(beng): | 392 ui::ViewProp::GetValue(window, kBrowserViewKey)) : NULL; |
| 391 NOTIMPLEMENTED(); | 393 } |
| 392 #elif defined(OS_WIN) | 394 #endif |
| 393 if (IsWindow(window)) { | |
| 394 return reinterpret_cast<BrowserView*>( | |
| 395 ui::ViewProp::GetValue(window, kBrowserViewKey)); | |
| 396 } | |
| 397 #else | |
| 398 BrowserView* browser_view = NULL; | |
| 399 if (window) { | |
| 400 browser_view = static_cast<BrowserView*>( | |
| 401 g_object_get_data(G_OBJECT(window), kBrowserViewKey)); | |
| 402 | 395 |
| 403 #if defined(TOUCH_UI) | 396 // static |
| 404 if (!browser_view) { | 397 BrowserView* BrowserView::GetBrowserViewForBrowser(Browser* browser) { |
| 405 // With views-desktop, we cannot determine the BrowserView from the | 398 return static_cast<BrowserView*>(browser->window()); |
| 406 // NativeWindow. So do the next best thing, and assume the last active | |
| 407 // BrowserView is what we want. | |
| 408 Browser* browser = BrowserList::GetLastActive(); | |
| 409 if (browser && !browser->is_type_popup() && !browser->is_type_panel()) | |
| 410 browser_view = reinterpret_cast<BrowserView*>(browser->window()); | |
| 411 } | |
| 412 #endif | |
| 413 } | |
| 414 return browser_view; | |
| 415 #endif | |
| 416 return NULL; | |
| 417 } | 399 } |
| 418 | 400 |
| 419 gfx::Rect BrowserView::GetToolbarBounds() const { | 401 gfx::Rect BrowserView::GetToolbarBounds() const { |
| 420 gfx::Rect toolbar_bounds(toolbar_->bounds()); | 402 gfx::Rect toolbar_bounds(toolbar_->bounds()); |
| 421 if (toolbar_bounds.IsEmpty()) | 403 if (toolbar_bounds.IsEmpty()) |
| 422 return toolbar_bounds; | 404 return toolbar_bounds; |
| 423 // When using vertical tabs, the toolbar appears to extend behind the tab | 405 // When using vertical tabs, the toolbar appears to extend behind the tab |
| 424 // column. | 406 // column. |
| 425 if (UseVerticalTabs()) | 407 if (UseVerticalTabs()) |
| 426 toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0); | 408 toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0); |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 } | 1147 } |
| 1166 | 1148 |
| 1167 void BrowserView::TabContentsFocused(TabContents* tab_contents) { | 1149 void BrowserView::TabContentsFocused(TabContents* tab_contents) { |
| 1168 contents_container_->TabContentsFocused(tab_contents); | 1150 contents_container_->TabContentsFocused(tab_contents); |
| 1169 } | 1151 } |
| 1170 | 1152 |
| 1171 void BrowserView::ShowPageInfo(Profile* profile, | 1153 void BrowserView::ShowPageInfo(Profile* profile, |
| 1172 const GURL& url, | 1154 const GURL& url, |
| 1173 const NavigationEntry::SSLStatus& ssl, | 1155 const NavigationEntry::SSLStatus& ssl, |
| 1174 bool show_history) { | 1156 bool show_history) { |
| 1175 gfx::NativeWindow parent = GetWidget()->GetNativeWindow(); | 1157 browser::ShowPageInfoBubble(browser_.get(), profile, url, ssl, show_history); |
| 1176 | |
| 1177 browser::ShowPageInfoBubble(parent, profile, url, ssl, show_history); | |
| 1178 } | 1158 } |
| 1179 | 1159 |
| 1180 void BrowserView::ShowAppMenu() { | 1160 void BrowserView::ShowAppMenu() { |
| 1181 toolbar_->app_menu()->Activate(); | 1161 toolbar_->app_menu()->Activate(); |
| 1182 } | 1162 } |
| 1183 | 1163 |
| 1184 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 1164 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 1185 bool* is_keyboard_shortcut) { | 1165 bool* is_keyboard_shortcut) { |
| 1186 if (event.type != WebKit::WebInputEvent::RawKeyDown) | 1166 if (event.type != WebKit::WebInputEvent::RawKeyDown) |
| 1187 return false; | 1167 return false; |
| (...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2617 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2597 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2618 // Create the view and the frame. The frame will attach itself via the view | 2598 // Create the view and the frame. The frame will attach itself via the view |
| 2619 // so we don't need to do anything with the pointer. | 2599 // so we don't need to do anything with the pointer. |
| 2620 BrowserView* view = new BrowserView(browser); | 2600 BrowserView* view = new BrowserView(browser); |
| 2621 (new BrowserFrame(view))->InitBrowserFrame(); | 2601 (new BrowserFrame(view))->InitBrowserFrame(); |
| 2622 view->GetWidget()->non_client_view()->SetAccessibleName( | 2602 view->GetWidget()->non_client_view()->SetAccessibleName( |
| 2623 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 2603 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 2624 return view; | 2604 return view; |
| 2625 } | 2605 } |
| 2626 #endif | 2606 #endif |
| OLD | NEW |