OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/browser.h" | 5 #include "chrome/browser/browser.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/idle_timer.h" | 8 #include "base/idle_timer.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 // In playback/record mode we always fix the size of the browser and | 362 // In playback/record mode we always fix the size of the browser and |
363 // move it to (0,0). The reason for this is two reasons: First we want | 363 // move it to (0,0). The reason for this is two reasons: First we want |
364 // resize/moves in the playback to still work, and Second we want | 364 // resize/moves in the playback to still work, and Second we want |
365 // playbacks to work (as much as possible) on machines w/ different | 365 // playbacks to work (as much as possible) on machines w/ different |
366 // screen sizes. | 366 // screen sizes. |
367 return gfx::Rect(0, 0, 800, 600); | 367 return gfx::Rect(0, 0, 800, 600); |
368 } | 368 } |
369 | 369 |
370 gfx::Rect restored_bounds = override_bounds_; | 370 gfx::Rect restored_bounds = override_bounds_; |
371 bool maximized; | 371 bool maximized; |
372 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, | 372 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, NULL, |
373 &restored_bounds, &maximized); | 373 &restored_bounds, &maximized); |
374 return restored_bounds; | 374 return restored_bounds; |
375 } | 375 } |
376 | 376 |
377 // TODO(beng): obtain maximized state some other way so we don't need to go | 377 // TODO(beng): obtain maximized state some other way so we don't need to go |
378 // through all this hassle. | 378 // through all this hassle. |
379 bool Browser::GetSavedMaximizedState() const { | 379 bool Browser::GetSavedMaximizedState() const { |
380 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) | 380 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) |
381 return true; | 381 return true; |
382 | 382 |
383 if (maximized_state_ == MAXIMIZED_STATE_MAXIMIZED) | 383 if (maximized_state_ == MAXIMIZED_STATE_MAXIMIZED) |
384 return true; | 384 return true; |
385 if (maximized_state_ == MAXIMIZED_STATE_UNMAXIMIZED) | 385 if (maximized_state_ == MAXIMIZED_STATE_UNMAXIMIZED) |
386 return false; | 386 return false; |
387 | 387 |
388 // An explicit maximized state was not set. Query the window sizer. | 388 // An explicit maximized state was not set. Query the window sizer. |
389 gfx::Rect restored_bounds; | 389 gfx::Rect restored_bounds; |
390 bool maximized = false; | 390 bool maximized = false; |
391 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, | 391 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, NULL, |
392 &restored_bounds, &maximized); | 392 &restored_bounds, &maximized); |
393 return maximized; | 393 return maximized; |
394 } | 394 } |
395 | 395 |
396 SkBitmap Browser::GetCurrentPageIcon() const { | 396 SkBitmap Browser::GetCurrentPageIcon() const { |
397 TabContents* contents = GetSelectedTabContents(); | 397 TabContents* contents = GetSelectedTabContents(); |
398 // |contents| can be NULL since GetCurrentPageIcon() is called by the window | 398 // |contents| can be NULL since GetCurrentPageIcon() is called by the window |
399 // during the window's creation (before tabs have been added). | 399 // during the window's creation (before tabs have been added). |
400 return contents ? contents->GetFavIcon() : SkBitmap(); | 400 return contents ? contents->GetFavIcon() : SkBitmap(); |
401 } | 401 } |
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1973 // the focus. FocusLocationBar() is only reached when the location bar is | 1973 // the focus. FocusLocationBar() is only reached when the location bar is |
1974 // focusable, but this may be reached at other times, e.g. while in | 1974 // focusable, but this may be reached at other times, e.g. while in |
1975 // fullscreen mode, where we need to leave focus in a consistent state. | 1975 // fullscreen mode, where we need to leave focus in a consistent state. |
1976 window_->SetFocusToLocationBar(); | 1976 window_->SetFocusToLocationBar(); |
1977 } | 1977 } |
1978 | 1978 |
1979 void Browser::RenderWidgetShowing() { | 1979 void Browser::RenderWidgetShowing() { |
1980 window_->DisableInactiveFrame(); | 1980 window_->DisableInactiveFrame(); |
1981 } | 1981 } |
1982 | 1982 |
| 1983 ExtensionFunctionDispatcher* Browser::CreateExtensionFunctionDispatcher( |
| 1984 RenderViewHost* render_view_host, |
| 1985 const std::string& extension_id) { |
| 1986 return new ExtensionFunctionDispatcher(render_view_host, this, extension_id); |
| 1987 } |
| 1988 |
1983 /////////////////////////////////////////////////////////////////////////////// | 1989 /////////////////////////////////////////////////////////////////////////////// |
1984 // Browser, SelectFileDialog::Listener implementation: | 1990 // Browser, SelectFileDialog::Listener implementation: |
1985 | 1991 |
1986 void Browser::FileSelected(const FilePath& path, int index, void* params) { | 1992 void Browser::FileSelected(const FilePath& path, int index, void* params) { |
1987 GURL file_url = net::FilePathToFileURL(path); | 1993 GURL file_url = net::FilePathToFileURL(path); |
1988 if (!file_url.is_empty()) | 1994 if (!file_url.is_empty()) |
1989 OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 1995 OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED); |
1990 } | 1996 } |
1991 | 1997 |
1992 | 1998 |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 | 2641 |
2636 // We need to register the window position pref. | 2642 // We need to register the window position pref. |
2637 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2643 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
2638 window_pref.append(L"_"); | 2644 window_pref.append(L"_"); |
2639 window_pref.append(app_name); | 2645 window_pref.append(app_name); |
2640 PrefService* prefs = g_browser_process->local_state(); | 2646 PrefService* prefs = g_browser_process->local_state(); |
2641 DCHECK(prefs); | 2647 DCHECK(prefs); |
2642 | 2648 |
2643 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2649 prefs->RegisterDictionaryPref(window_pref.c_str()); |
2644 } | 2650 } |
OLD | NEW |