| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_UI_BROWSER_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_H_ |
| 6 #define CHROME_BROWSER_UI_BROWSER_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 // Returns true if the tab strip is editable (for extensions). | 441 // Returns true if the tab strip is editable (for extensions). |
| 442 bool IsTabStripEditable() const; | 442 bool IsTabStripEditable() const; |
| 443 | 443 |
| 444 // Returns the index to insert a tab at during session restore and startup. | 444 // Returns the index to insert a tab at during session restore and startup. |
| 445 // |relative_index| gives the index of the url into the number of tabs that | 445 // |relative_index| gives the index of the url into the number of tabs that |
| 446 // are going to be opened. For example, if three urls are passed in on the | 446 // are going to be opened. For example, if three urls are passed in on the |
| 447 // command line this is invoked three times with the values 0, 1 and 2. | 447 // command line this is invoked three times with the values 0, 1 and 2. |
| 448 int GetIndexForInsertionDuringRestore(int relative_index); | 448 int GetIndexForInsertionDuringRestore(int relative_index); |
| 449 | 449 |
| 450 // Adds a selected tab with the specified URL and transition, returns the | 450 // Adds a selected tab with the specified URL and transition, returns the |
| 451 // created TabContents. | 451 // created TabContentsWrapper. |
| 452 TabContentsWrapper* AddSelectedTabWithURL( | 452 TabContentsWrapper* AddSelectedTabWithURL( |
| 453 const GURL& url, | 453 const GURL& url, |
| 454 content::PageTransition transition); | 454 content::PageTransition transition); |
| 455 | 455 |
| 456 // Add a new tab, given a TabContents. A TabContents appropriate to | 456 // Add a new tab, given a TabContentsWrapper. A WebContents appropriate to |
| 457 // display the last committed entry is created and returned. | 457 // display the last committed entry is created and returned. |
| 458 content::WebContents* AddTab(TabContentsWrapper* tab_contents, | 458 content::WebContents* AddTab(TabContentsWrapper* tab_contents, |
| 459 content::PageTransition type); | 459 content::PageTransition type); |
| 460 | 460 |
| 461 // Add a tab with its session history restored from the SessionRestore | 461 // Add a tab with its session history restored from the SessionRestore |
| 462 // system. If select is true, the tab is selected. |tab_index| gives the index | 462 // system. If select is true, the tab is selected. |tab_index| gives the index |
| 463 // to insert the tab at. |selected_navigation| is the index of the | 463 // to insert the tab at. |selected_navigation| is the index of the |
| 464 // TabNavigation in |navigations| to select. If |extension_app_id| is | 464 // TabNavigation in |navigations| to select. If |extension_app_id| is |
| 465 // non-empty the tab is an app tab and |extension_app_id| is the id of the | 465 // non-empty the tab is an app tab and |extension_app_id| is the id of the |
| 466 // extension. If |pin| is true and |tab_index|/ is the last pinned tab, then | 466 // extension. If |pin| is true and |tab_index|/ is the last pinned tab, then |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 | 810 |
| 811 // Overridden from CommandUpdater::CommandUpdaterDelegate: | 811 // Overridden from CommandUpdater::CommandUpdaterDelegate: |
| 812 virtual void ExecuteCommandWithDisposition( | 812 virtual void ExecuteCommandWithDisposition( |
| 813 int id, | 813 int id, |
| 814 WindowOpenDisposition disposition) OVERRIDE; | 814 WindowOpenDisposition disposition) OVERRIDE; |
| 815 | 815 |
| 816 // Overridden from TabRestoreServiceObserver: | 816 // Overridden from TabRestoreServiceObserver: |
| 817 virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE; | 817 virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE; |
| 818 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE; | 818 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE; |
| 819 | 819 |
| 820 // Centralized method for creating a TabContents, configuring and installing | 820 // Centralized method for creating a TabContentsWrapper, configuring and |
| 821 // all its supporting objects and observers. | 821 // installing all its supporting objects and observers. |
| 822 static TabContentsWrapper* TabContentsFactory( | 822 static TabContentsWrapper* TabContentsFactory( |
| 823 Profile* profile, | 823 Profile* profile, |
| 824 content::SiteInstance* site_instance, | 824 content::SiteInstance* site_instance, |
| 825 int routing_id, | 825 int routing_id, |
| 826 const content::WebContents* base_web_contents, | 826 const content::WebContents* base_web_contents, |
| 827 content::SessionStorageNamespace* session_storage_namespace); | 827 content::SessionStorageNamespace* session_storage_namespace); |
| 828 | 828 |
| 829 // Overridden from TabHandlerDelegate: | 829 // Overridden from TabHandlerDelegate: |
| 830 virtual Profile* GetProfile() const OVERRIDE; | 830 virtual Profile* GetProfile() const OVERRIDE; |
| 831 virtual Browser* AsBrowser() OVERRIDE; | 831 virtual Browser* AsBrowser() OVERRIDE; |
| 832 | 832 |
| 833 // Overridden from TabStripModelDelegate: | 833 // Overridden from TabStripModelDelegate: |
| 834 virtual TabContentsWrapper* AddBlankTab(bool foreground); | 834 virtual TabContentsWrapper* AddBlankTab(bool foreground); |
| 835 virtual TabContentsWrapper* AddBlankTabAt(int index, bool foreground); | 835 virtual TabContentsWrapper* AddBlankTabAt(int index, bool foreground); |
| 836 virtual Browser* CreateNewStripWithContents( | 836 virtual Browser* CreateNewStripWithContents( |
| 837 TabContentsWrapper* detached_contents, | 837 TabContentsWrapper* detached_contents, |
| 838 const gfx::Rect& window_bounds, | 838 const gfx::Rect& window_bounds, |
| 839 const DockInfo& dock_info, | 839 const DockInfo& dock_info, |
| 840 bool maximize); | 840 bool maximize); |
| 841 virtual int GetDragActions() const; | 841 virtual int GetDragActions() const; |
| 842 // Construct a TabContents for a given URL, profile and transition type. | 842 // Construct a TabContentsWrapper for a given URL, profile and transition |
| 843 // If instance is not null, its process will be used to render the tab. | 843 // type. If instance is not null, its process will be used to render the tab. |
| 844 virtual TabContentsWrapper* CreateTabContentsForURL( | 844 virtual TabContentsWrapper* CreateTabContentsForURL( |
| 845 const GURL& url, | 845 const GURL& url, |
| 846 const content::Referrer& referrer, | 846 const content::Referrer& referrer, |
| 847 Profile* profile, | 847 Profile* profile, |
| 848 content::PageTransition transition, | 848 content::PageTransition transition, |
| 849 bool defer_load, | 849 bool defer_load, |
| 850 content::SiteInstance* instance) const; | 850 content::SiteInstance* instance) const; |
| 851 virtual bool CanDuplicateContentsAt(int index); | 851 virtual bool CanDuplicateContentsAt(int index); |
| 852 virtual void DuplicateContentsAt(int index); | 852 virtual void DuplicateContentsAt(int index); |
| 853 virtual void CloseFrameAfterDragSession(); | 853 virtual void CloseFrameAfterDragSession(); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 // Updates the printing command state. | 1182 // Updates the printing command state. |
| 1183 void UpdatePrintingState(int content_restrictions); | 1183 void UpdatePrintingState(int content_restrictions); |
| 1184 | 1184 |
| 1185 // Updates the save-page-as command state. | 1185 // Updates the save-page-as command state. |
| 1186 void UpdateSaveAsState(int content_restrictions); | 1186 void UpdateSaveAsState(int content_restrictions); |
| 1187 | 1187 |
| 1188 // Updates the open-file state (Mac Only). | 1188 // Updates the open-file state (Mac Only). |
| 1189 void UpdateOpenFileState(); | 1189 void UpdateOpenFileState(); |
| 1190 | 1190 |
| 1191 // Ask the Reload/Stop button to change its icon, and update the Stop command | 1191 // Ask the Reload/Stop button to change its icon, and update the Stop command |
| 1192 // state. |is_loading| is true if the current TabContents is loading. | 1192 // state. |is_loading| is true if the current WebContents is loading. |
| 1193 // |force| is true if the button should change its icon immediately. | 1193 // |force| is true if the button should change its icon immediately. |
| 1194 void UpdateReloadStopState(bool is_loading, bool force); | 1194 void UpdateReloadStopState(bool is_loading, bool force); |
| 1195 | 1195 |
| 1196 // UI update coalescing and handling //////////////////////////////////////// | 1196 // UI update coalescing and handling //////////////////////////////////////// |
| 1197 | 1197 |
| 1198 // Asks the toolbar (and as such the location bar) to update its state to | 1198 // Asks the toolbar (and as such the location bar) to update its state to |
| 1199 // reflect the current tab's current URL, security state, etc. | 1199 // reflect the current tab's current URL, security state, etc. |
| 1200 // If |should_restore_state| is true, we're switching (back?) to this tab and | 1200 // If |should_restore_state| is true, we're switching (back?) to this tab and |
| 1201 // should restore any previous location bar state (such as user editing) as | 1201 // should restore any previous location bar state (such as user editing) as |
| 1202 // well. | 1202 // well. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 // across sessions. | 1393 // across sessions. |
| 1394 const SessionID session_id_; | 1394 const SessionID session_id_; |
| 1395 | 1395 |
| 1396 // The model for the toolbar view. | 1396 // The model for the toolbar view. |
| 1397 scoped_ptr<ToolbarModel> toolbar_model_; | 1397 scoped_ptr<ToolbarModel> toolbar_model_; |
| 1398 | 1398 |
| 1399 // UI update coalescing and handling //////////////////////////////////////// | 1399 // UI update coalescing and handling //////////////////////////////////////// |
| 1400 | 1400 |
| 1401 typedef std::map<const content::WebContents*, int> UpdateMap; | 1401 typedef std::map<const content::WebContents*, int> UpdateMap; |
| 1402 | 1402 |
| 1403 // Maps from TabContents to pending UI updates that need to be processed. | 1403 // Maps from WebContents to pending UI updates that need to be processed. |
| 1404 // We don't update things like the URL or tab title right away to avoid | 1404 // We don't update things like the URL or tab title right away to avoid |
| 1405 // flickering and extra painting. | 1405 // flickering and extra painting. |
| 1406 // See ScheduleUIUpdate and ProcessPendingUIUpdates. | 1406 // See ScheduleUIUpdate and ProcessPendingUIUpdates. |
| 1407 UpdateMap scheduled_updates_; | 1407 UpdateMap scheduled_updates_; |
| 1408 | 1408 |
| 1409 // The following factory is used for chrome update coalescing. | 1409 // The following factory is used for chrome update coalescing. |
| 1410 base::WeakPtrFactory<Browser> chrome_updater_factory_; | 1410 base::WeakPtrFactory<Browser> chrome_updater_factory_; |
| 1411 | 1411 |
| 1412 // OnBeforeUnload handling ////////////////////////////////////////////////// | 1412 // OnBeforeUnload handling ////////////////////////////////////////////////// |
| 1413 | 1413 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 | 1474 |
| 1475 // Different types of action when web app info is available. | 1475 // Different types of action when web app info is available. |
| 1476 // OnDidGetApplicationInfo uses this to dispatch calls. | 1476 // OnDidGetApplicationInfo uses this to dispatch calls. |
| 1477 enum WebAppAction { | 1477 enum WebAppAction { |
| 1478 NONE, // No action at all. | 1478 NONE, // No action at all. |
| 1479 CREATE_SHORTCUT, // Bring up create application shortcut dialog. | 1479 CREATE_SHORTCUT, // Bring up create application shortcut dialog. |
| 1480 UPDATE_SHORTCUT // Update icon for app shortcut. | 1480 UPDATE_SHORTCUT // Update icon for app shortcut. |
| 1481 }; | 1481 }; |
| 1482 | 1482 |
| 1483 // Which deferred action to perform when OnDidGetApplicationInfo is notified | 1483 // Which deferred action to perform when OnDidGetApplicationInfo is notified |
| 1484 // from a TabContents. Currently, only one pending action is allowed. | 1484 // from a WebContents. Currently, only one pending action is allowed. |
| 1485 WebAppAction pending_web_app_action_; | 1485 WebAppAction pending_web_app_action_; |
| 1486 | 1486 |
| 1487 // The profile's tab restore service. The service is owned by the profile, | 1487 // The profile's tab restore service. The service is owned by the profile, |
| 1488 // and we install ourselves as an observer. | 1488 // and we install ourselves as an observer. |
| 1489 TabRestoreService* tab_restore_service_; | 1489 TabRestoreService* tab_restore_service_; |
| 1490 | 1490 |
| 1491 // Helper which implements the ContentSettingBubbleModel interface. | 1491 // Helper which implements the ContentSettingBubbleModel interface. |
| 1492 scoped_ptr<BrowserContentSettingBubbleModelDelegate> | 1492 scoped_ptr<BrowserContentSettingBubbleModelDelegate> |
| 1493 content_setting_bubble_model_delegate_; | 1493 content_setting_bubble_model_delegate_; |
| 1494 | 1494 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1514 bool window_has_shown_; | 1514 bool window_has_shown_; |
| 1515 | 1515 |
| 1516 // Currently open color chooser. Non-NULL after OpenColorChooser is called and | 1516 // Currently open color chooser. Non-NULL after OpenColorChooser is called and |
| 1517 // before DidEndColorChooser is called. | 1517 // before DidEndColorChooser is called. |
| 1518 scoped_ptr<content::ColorChooser> color_chooser_; | 1518 scoped_ptr<content::ColorChooser> color_chooser_; |
| 1519 | 1519 |
| 1520 DISALLOW_COPY_AND_ASSIGN(Browser); | 1520 DISALLOW_COPY_AND_ASSIGN(Browser); |
| 1521 }; | 1521 }; |
| 1522 | 1522 |
| 1523 #endif // CHROME_BROWSER_UI_BROWSER_H_ | 1523 #endif // CHROME_BROWSER_UI_BROWSER_H_ |
| OLD | NEW |