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 "app/animation.h" | 7 #include "app/animation.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/idle_timer.h" | 10 #include "base/idle_timer.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 InitCommandState(); | 196 InitCommandState(); |
197 BrowserList::AddBrowser(this); | 197 BrowserList::AddBrowser(this); |
198 | 198 |
199 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, | 199 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, |
200 profile_->GetPrefs(), NULL); | 200 profile_->GetPrefs(), NULL); |
201 | 201 |
202 // Trim browser memory on idle for low & medium memory models. | 202 // Trim browser memory on idle for low & medium memory models. |
203 if (g_browser_process->memory_model() < BrowserProcess::HIGH_MEMORY_MODEL) | 203 if (g_browser_process->memory_model() < BrowserProcess::HIGH_MEMORY_MODEL) |
204 idle_task_->Start(); | 204 idle_task_->Start(); |
205 | |
206 renderer_preferences_.can_accept_load_drops = (this->type() == TYPE_NORMAL); | |
207 } | 205 } |
208 | 206 |
209 Browser::~Browser() { | 207 Browser::~Browser() { |
210 // The tab strip should be empty at this point. | 208 // The tab strip should be empty at this point. |
211 DCHECK(tabstrip_model_.empty()); | 209 DCHECK(tabstrip_model_.empty()); |
212 tabstrip_model_.RemoveObserver(this); | 210 tabstrip_model_.RemoveObserver(this); |
213 | 211 |
214 BrowserList::RemoveBrowser(this); | 212 BrowserList::RemoveBrowser(this); |
215 | 213 |
216 #if defined(OS_WIN) || defined(OS_LINUX) | 214 #if defined(OS_WIN) || defined(OS_LINUX) |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 } | 339 } |
342 | 340 |
343 // static | 341 // static |
344 void Browser::OpenApplicationWindow(Profile* profile, const GURL& url) { | 342 void Browser::OpenApplicationWindow(Profile* profile, const GURL& url) { |
345 std::wstring app_name = ComputeApplicationNameFromURL(url); | 343 std::wstring app_name = ComputeApplicationNameFromURL(url); |
346 RegisterAppPrefs(app_name); | 344 RegisterAppPrefs(app_name); |
347 | 345 |
348 Browser* browser = Browser::CreateForApp(app_name, profile, false); | 346 Browser* browser = Browser::CreateForApp(app_name, profile, false); |
349 browser->AddTabWithURL(url, GURL(), PageTransition::START_PAGE, true, -1, | 347 browser->AddTabWithURL(url, GURL(), PageTransition::START_PAGE, true, -1, |
350 false, NULL); | 348 false, NULL); |
351 browser->GetSelectedTabContents()->render_view_host()->SetRendererPrefs( | 349 |
352 browser->GetSelectedTabContents()->delegate()->GetRendererPrefs()); | 350 TabContents* tab_contents = browser->GetSelectedTabContents(); |
| 351 tab_contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 352 tab_contents->render_view_host()->SyncRendererPrefs(); |
353 browser->window()->Show(); | 353 browser->window()->Show(); |
354 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial | 354 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial |
355 // focus explicitly. | 355 // focus explicitly. |
356 browser->GetSelectedTabContents()->view()->SetInitialFocus(); | 356 tab_contents->view()->SetInitialFocus(); |
357 } | 357 } |
358 | 358 |
359 /////////////////////////////////////////////////////////////////////////////// | 359 /////////////////////////////////////////////////////////////////////////////// |
360 // Browser, State Storage and Retrieval for UI: | 360 // Browser, State Storage and Retrieval for UI: |
361 | 361 |
362 std::wstring Browser::GetWindowPlacementKey() const { | 362 std::wstring Browser::GetWindowPlacementKey() const { |
363 std::wstring name(prefs::kBrowserWindowPlacement); | 363 std::wstring name(prefs::kBrowserWindowPlacement); |
364 if (!app_name_.empty()) { | 364 if (!app_name_.empty()) { |
365 name.append(L"_"); | 365 name.append(L"_"); |
366 name.append(app_name_); | 366 name.append(app_name_); |
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1890 } | 1890 } |
1891 | 1891 |
1892 void Browser::ConvertContentsToApplication(TabContents* contents) { | 1892 void Browser::ConvertContentsToApplication(TabContents* contents) { |
1893 const GURL& url = contents->controller().GetActiveEntry()->url(); | 1893 const GURL& url = contents->controller().GetActiveEntry()->url(); |
1894 std::wstring app_name = ComputeApplicationNameFromURL(url); | 1894 std::wstring app_name = ComputeApplicationNameFromURL(url); |
1895 RegisterAppPrefs(app_name); | 1895 RegisterAppPrefs(app_name); |
1896 | 1896 |
1897 DetachContents(contents); | 1897 DetachContents(contents); |
1898 Browser* browser = Browser::CreateForApp(app_name, profile_, false); | 1898 Browser* browser = Browser::CreateForApp(app_name, profile_, false); |
1899 browser->tabstrip_model()->AppendTabContents(contents, true); | 1899 browser->tabstrip_model()->AppendTabContents(contents, true); |
1900 browser->GetSelectedTabContents()->render_view_host()->SetRendererPrefs( | 1900 TabContents* tab_contents = browser->GetSelectedTabContents(); |
1901 browser->GetSelectedTabContents()->delegate()->GetRendererPrefs()); | 1901 tab_contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1902 tab_contents->render_view_host()->SyncRendererPrefs(); |
1902 browser->window()->Show(); | 1903 browser->window()->Show(); |
1903 } | 1904 } |
1904 | 1905 |
1905 bool Browser::ShouldDisplayURLField() { | 1906 bool Browser::ShouldDisplayURLField() { |
1906 return !IsApplication(); | 1907 return !IsApplication(); |
1907 } | 1908 } |
1908 | 1909 |
1909 void Browser::BeforeUnloadFired(TabContents* tab, | 1910 void Browser::BeforeUnloadFired(TabContents* tab, |
1910 bool proceed, | 1911 bool proceed, |
1911 bool* proceed_to_fire_unload) { | 1912 bool* proceed_to_fire_unload) { |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2764 /////////////////////////////////////////////////////////////////////////////// | 2765 /////////////////////////////////////////////////////////////////////////////// |
2765 // BrowserToolbarModel (private): | 2766 // BrowserToolbarModel (private): |
2766 | 2767 |
2767 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 2768 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { |
2768 // This |current_tab| can be NULL during the initialization of the | 2769 // This |current_tab| can be NULL during the initialization of the |
2769 // toolbar during window creation (i.e. before any tabs have been added | 2770 // toolbar during window creation (i.e. before any tabs have been added |
2770 // to the window). | 2771 // to the window). |
2771 TabContents* current_tab = browser_->GetSelectedTabContents(); | 2772 TabContents* current_tab = browser_->GetSelectedTabContents(); |
2772 return current_tab ? ¤t_tab->controller() : NULL; | 2773 return current_tab ? ¤t_tab->controller() : NULL; |
2773 } | 2774 } |
OLD | NEW |