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

Side by Side Diff: chrome/browser/views/frame/browser_view.cc

Issue 10761: Rewire the throbber so that the timer for updating lives on BrowserView, not ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month 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
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/command_line.h" 5 #include "base/command_line.h"
6 6
7 #include "chrome/browser/views/frame/browser_view.h" 7 #include "chrome/browser/views/frame/browser_view.h"
8 8
9 #include "base/file_version_info.h" 9 #include "base/file_version_info.h"
10 #include "base/time.h"
10 #include "chrome/app/chrome_dll_resource.h" 11 #include "chrome/app/chrome_dll_resource.h"
11 #include "chrome/app/theme/theme_resources.h" 12 #include "chrome/app/theme/theme_resources.h"
12 #include "chrome/browser/app_modal_dialog_queue.h" 13 #include "chrome/browser/app_modal_dialog_queue.h"
13 #include "chrome/browser/browser.h" 14 #include "chrome/browser/browser.h"
14 #include "chrome/browser/browser_list.h" 15 #include "chrome/browser/browser_list.h"
15 #include "chrome/browser/encoding_menu_controller_delegate.h" 16 #include "chrome/browser/encoding_menu_controller_delegate.h"
16 #include "chrome/browser/navigation_entry.h" 17 #include "chrome/browser/navigation_entry.h"
17 #include "chrome/browser/view_ids.h" 18 #include "chrome/browser/view_ids.h"
18 #include "chrome/browser/views/about_chrome_view.h" 19 #include "chrome/browser/views/about_chrome_view.h"
19 #include "chrome/browser/views/bookmark_bar_view.h" 20 #include "chrome/browser/views/bookmark_bar_view.h"
(...skipping 20 matching lines...) Expand all
40 #include "chrome/common/pref_names.h" 41 #include "chrome/common/pref_names.h"
41 #include "chrome/common/resource_bundle.h" 42 #include "chrome/common/resource_bundle.h"
42 #include "chrome/common/win_util.h" 43 #include "chrome/common/win_util.h"
43 #include "chrome/views/hwnd_notification_source.h" 44 #include "chrome/views/hwnd_notification_source.h"
44 #include "chrome/views/view.h" 45 #include "chrome/views/view.h"
45 #include "chrome/views/window.h" 46 #include "chrome/views/window.h"
46 47
47 #include "chromium_strings.h" 48 #include "chromium_strings.h"
48 #include "generated_resources.h" 49 #include "generated_resources.h"
49 50
51 using base::TimeDelta;
52
50 // static 53 // static
51 SkBitmap BrowserView::default_favicon_; 54 SkBitmap BrowserView::default_favicon_;
52 SkBitmap BrowserView::otr_avatar_; 55 SkBitmap BrowserView::otr_avatar_;
53 // The vertical overlap between the TabStrip and the Toolbar. 56 // The vertical overlap between the TabStrip and the Toolbar.
54 static const int kToolbarTabStripVerticalOverlap = 3; 57 static const int kToolbarTabStripVerticalOverlap = 3;
55 // The visible height of the shadow above the tabs. Clicks in this area are 58 // The visible height of the shadow above the tabs. Clicks in this area are
56 // treated as clicks to the frame, rather than clicks to the tab. 59 // treated as clicks to the frame, rather than clicks to the tab.
57 static const int kTabShadowSize = 2; 60 static const int kTabShadowSize = 2;
58 // The height of the status bubble. 61 // The height of the status bubble.
59 static const int kStatusBubbleHeight = 20; 62 static const int kStatusBubbleHeight = 20;
60 // The distance of the status bubble from the left edge of the window. 63 // The distance of the status bubble from the left edge of the window.
61 static const int kStatusBubbleHorizontalOffset = 3; 64 static const int kStatusBubbleHorizontalOffset = 3;
62 // The distance of the status bubble from the bottom edge of the window. 65 // The distance of the status bubble from the bottom edge of the window.
63 static const int kStatusBubbleVerticalOffset = 2; 66 static const int kStatusBubbleVerticalOffset = 2;
64 // An offset distance between certain toolbars and the toolbar that preceded 67 // An offset distance between certain toolbars and the toolbar that preceded
65 // them in layout. 68 // them in layout.
66 static const int kSeparationLineHeight = 1; 69 static const int kSeparationLineHeight = 1;
67 // The name of a key to store on the window handle so that other code can 70 // The name of a key to store on the window handle so that other code can
68 // locate this object using just the handle. 71 // locate this object using just the handle.
69 static const wchar_t* kBrowserWindowKey = L"__BROWSER_WINDOW__"; 72 static const wchar_t* kBrowserWindowKey = L"__BROWSER_WINDOW__";
70 // The distance between tiled windows. 73 // The distance between tiled windows.
71 static const int kWindowTilePixels = 10; 74 static const int kWindowTilePixels = 10;
72 // How frequently we check for hung plugin windows. 75 // How frequently we check for hung plugin windows.
73 static const int kDefaultHungPluginDetectFrequency = 2000; 76 static const int kDefaultHungPluginDetectFrequency = 2000;
74 // How long do we wait before we consider a window hung (in ms). 77 // How long do we wait before we consider a window hung (in ms).
75 static const int kDefaultPluginMessageResponseTimeout = 30000; 78 static const int kDefaultPluginMessageResponseTimeout = 30000;
79 // The number of milliseconds between loading animation frames.
80 static const int kLoadingAnimationFrameTimeMs = 30;
76 81
77 static const struct { bool separator; int command; int label; } kMenuLayout[] = { 82 static const struct { bool separator; int command; int label; } kMenuLayout[] = {
78 { true, 0, 0 }, 83 { true, 0, 0 },
79 { false, IDC_TASKMANAGER, IDS_TASKMANAGER }, 84 { false, IDC_TASKMANAGER, IDS_TASKMANAGER },
80 { true, 0, 0 }, 85 { true, 0, 0 },
81 { false, IDC_ENCODING, IDS_ENCODING }, 86 { false, IDC_ENCODING, IDS_ENCODING },
82 { false, IDC_ZOOM, IDS_ZOOM }, 87 { false, IDC_ZOOM, IDS_ZOOM },
83 { false, IDC_PRINT, IDS_PRINT }, 88 { false, IDC_PRINT, IDS_PRINT },
84 { false, IDC_SAVEPAGE, IDS_SAVEPAGEAS }, 89 { false, IDC_SAVEPAGE, IDS_SAVEPAGEAS },
85 { false, IDC_FIND, IDS_FIND_IN_PAGE }, 90 { false, IDC_FIND, IDS_FIND_IN_PAGE },
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 contents_container_->UpdateHWNDBounds(); 414 contents_container_->UpdateHWNDBounds();
410 } 415 }
411 } 416 }
412 417
413 void BrowserView::UpdateTitleBar() { 418 void BrowserView::UpdateTitleBar() {
414 frame_->GetWindow()->UpdateWindowTitle(); 419 frame_->GetWindow()->UpdateWindowTitle();
415 if (ShouldShowWindowIcon()) 420 if (ShouldShowWindowIcon())
416 frame_->GetWindow()->UpdateWindowIcon(); 421 frame_->GetWindow()->UpdateWindowIcon();
417 } 422 }
418 423
419 void BrowserView::ValidateThrobber() { 424 void BrowserView::UpdateLoadingAnimations(bool should_animate) {
420 if (ShouldShowWindowIcon()) { 425 if (should_animate) {
421 TabContents* tab_contents = browser_->GetSelectedTabContents(); 426 if (!loading_animation_timer_.IsRunning()) {
422 frame_->UpdateThrobber(tab_contents ? tab_contents->is_loading() : false); 427 // Loads are happening, and the timer isn't running, so start it.
428 loading_animation_timer_.Start(
429 TimeDelta::FromMilliseconds(kLoadingAnimationFrameTimeMs), this,
sky 2008/11/14 22:07:21 nit: 4 space indent
430 &BrowserView::LoadingAnimationCallback);
431 }
432 } else {
433 if (loading_animation_timer_.IsRunning()) {
434 loading_animation_timer_.Stop();
435 // Loads are now complete, update the state if a task was scheduled.
436 LoadingAnimationCallback();
437 }
423 } 438 }
424 } 439 }
425 440
426 gfx::Rect BrowserView::GetNormalBounds() const { 441 gfx::Rect BrowserView::GetNormalBounds() const {
427 WINDOWPLACEMENT wp; 442 WINDOWPLACEMENT wp;
428 wp.length = sizeof(wp); 443 wp.length = sizeof(wp);
429 const bool ret = !!GetWindowPlacement(frame_->GetWindow()->GetHWND(), &wp); 444 const bool ret = !!GetWindowPlacement(frame_->GetWindow()->GetHWND(), &wp);
430 DCHECK(ret); 445 DCHECK(ret);
431 return gfx::Rect(wp.rcNormalPosition); 446 return gfx::Rect(wp.rcNormalPosition);
432 } 447 }
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 case APPCOMMAND_COPY: 1282 case APPCOMMAND_COPY:
1268 case APPCOMMAND_CUT: 1283 case APPCOMMAND_CUT:
1269 case APPCOMMAND_PASTE: 1284 case APPCOMMAND_PASTE:
1270 case APPCOMMAND_SPELL_CHECK: 1285 case APPCOMMAND_SPELL_CHECK:
1271 default: 1286 default:
1272 break; 1287 break;
1273 } 1288 }
1274 return -1; 1289 return -1;
1275 } 1290 }
1276 1291
1292 void BrowserView::LoadingAnimationCallback() {
1293 if (SupportsWindowFeature(FEATURE_TABSTRIP)) {
1294 // Loading animations are shown in the tab for tabbed windows.
1295 tabstrip_->UpdateLoadingAnimations();
1296 } else if (ShouldShowWindowIcon()) {
1297 // ... or in the window icon area for popups and app windows.
1298 frame_->UpdateThrobber(browser_->IsCurrentPageLoading());
1299 }
1300 }
1301
1277 void BrowserView::InitHangMonitor() { 1302 void BrowserView::InitHangMonitor() {
1278 PrefService* pref_service = g_browser_process->local_state(); 1303 PrefService* pref_service = g_browser_process->local_state();
1279 int plugin_message_response_timeout = 1304 int plugin_message_response_timeout =
1280 pref_service->GetInteger(prefs::kPluginMessageResponseTimeout); 1305 pref_service->GetInteger(prefs::kPluginMessageResponseTimeout);
1281 int hung_plugin_detect_freq = 1306 int hung_plugin_detect_freq =
1282 pref_service->GetInteger(prefs::kHungPluginDetectFrequency); 1307 pref_service->GetInteger(prefs::kHungPluginDetectFrequency);
1283 if ((hung_plugin_detect_freq > 0) && 1308 if ((hung_plugin_detect_freq > 0) &&
1284 hung_window_detector_.Initialize(GetContainer()->GetHWND(), 1309 hung_window_detector_.Initialize(GetContainer()->GetHWND(),
1285 plugin_message_response_timeout)) { 1310 plugin_message_response_timeout)) {
1286 ticker_.set_tick_interval(hung_plugin_detect_freq); 1311 ticker_.set_tick_interval(hung_plugin_detect_freq);
1287 ticker_.RegisterTickHandler(&hung_window_detector_); 1312 ticker_.RegisterTickHandler(&hung_window_detector_);
1288 ticker_.Start(); 1313 ticker_.Start();
1289 1314
1290 pref_service->SetInteger(prefs::kPluginMessageResponseTimeout, 1315 pref_service->SetInteger(prefs::kPluginMessageResponseTimeout,
1291 plugin_message_response_timeout); 1316 plugin_message_response_timeout);
1292 pref_service->SetInteger(prefs::kHungPluginDetectFrequency, 1317 pref_service->SetInteger(prefs::kHungPluginDetectFrequency,
1293 hung_plugin_detect_freq); 1318 hung_plugin_detect_freq);
1294 } 1319 }
1295 } 1320 }
1296 1321
1297 // static 1322 // static
1298 void BrowserView::InitClass() { 1323 void BrowserView::InitClass() {
1299 static bool initialized = false; 1324 static bool initialized = false;
1300 if (!initialized) { 1325 if (!initialized) {
1301 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 1326 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1302 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); 1327 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
1303 initialized = true; 1328 initialized = true;
1304 } 1329 }
1305 } 1330 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698