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

Side by Side Diff: chrome/browser/ui/browser_tabrestore.cc

Issue 2930013005: [Tab Metrics] Measure FP, FCP and FMP for Foreground Tab during Session Restore (Closed)
Patch Set: Add RemoveFromWebContents() to RestoreOrigin. Created 3 years, 5 months 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
OLDNEW
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 #include "chrome/browser/ui/browser_tabrestore.h" 5 #include "chrome/browser/ui/browser_tabrestore.h"
6 6
7 #include "chrome/browser/extensions/tab_helper.h" 7 #include "chrome/browser/extensions/tab_helper.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/sessions/session_service.h" 9 #include "chrome/browser/sessions/session_service.h"
10 #include "chrome/browser/sessions/session_service_factory.h" 10 #include "chrome/browser/sessions/session_service_factory.h"
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 39
40 WebContents* CreateRestoredTab( 40 WebContents* CreateRestoredTab(
41 Browser* browser, 41 Browser* browser,
42 const std::vector<SerializedNavigationEntry>& navigations, 42 const std::vector<SerializedNavigationEntry>& navigations,
43 int selected_navigation, 43 int selected_navigation,
44 const std::string& extension_app_id, 44 const std::string& extension_app_id,
45 bool from_last_session, 45 bool from_last_session,
46 content::SessionStorageNamespace* session_storage_namespace, 46 content::SessionStorageNamespace* session_storage_namespace,
47 const std::string& user_agent_override, 47 const std::string& user_agent_override,
48 bool initially_hidden) { 48 bool initially_hidden,
49 base::Optional<RestoreOrigin::Type> restore_origin_type = base::nullopt) {
49 GURL restore_url = navigations.at(selected_navigation).virtual_url(); 50 GURL restore_url = navigations.at(selected_navigation).virtual_url();
50 // TODO(ajwong): Remove the temporary session_storage_namespace_map when 51 // TODO(ajwong): Remove the temporary session_storage_namespace_map when
51 // we teach session restore to understand that one tab can have multiple 52 // we teach session restore to understand that one tab can have multiple
52 // SessionStorageNamespace objects. Also remove the 53 // SessionStorageNamespace objects. Also remove the
53 // session_storage_namespace.h include since we only need that to assign 54 // session_storage_namespace.h include since we only need that to assign
54 // into the map. 55 // into the map.
55 content::SessionStorageNamespaceMap session_storage_namespace_map; 56 content::SessionStorageNamespaceMap session_storage_namespace_map;
56 session_storage_namespace_map[std::string()] = session_storage_namespace; 57 session_storage_namespace_map[std::string()] = session_storage_namespace;
57 WebContents::CreateParams create_params( 58 WebContents::CreateParams create_params(
58 browser->profile(), 59 browser->profile(),
59 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url)); 60 tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url));
60 create_params.initially_hidden = initially_hidden; 61 create_params.initially_hidden = initially_hidden;
61 WebContents* base_web_contents = 62 WebContents* base_web_contents =
62 browser->tab_strip_model()->GetActiveWebContents(); 63 browser->tab_strip_model()->GetActiveWebContents();
63 if (base_web_contents) { 64 if (base_web_contents) {
64 create_params.initial_size = 65 create_params.initial_size =
65 base_web_contents->GetContainerBounds().size(); 66 base_web_contents->GetContainerBounds().size();
66 } 67 }
67 WebContents* web_contents = content::WebContents::CreateWithSessionStorage( 68 WebContents* web_contents = content::WebContents::CreateWithSessionStorage(
68 create_params, 69 create_params,
69 session_storage_namespace_map); 70 session_storage_namespace_map);
71 if (restore_origin_type) {
72 RestoreOrigin::CreateForWebContents(web_contents,
73 restore_origin_type.value());
74 }
70 extensions::TabHelper::CreateForWebContents(web_contents); 75 extensions::TabHelper::CreateForWebContents(web_contents);
71 extensions::TabHelper::FromWebContents(web_contents)-> 76 extensions::TabHelper::FromWebContents(web_contents)->
72 SetExtensionAppById(extension_app_id); 77 SetExtensionAppById(extension_app_id);
73 std::vector<std::unique_ptr<NavigationEntry>> entries = 78 std::vector<std::unique_ptr<NavigationEntry>> entries =
74 ContentSerializedNavigationBuilder::ToNavigationEntries( 79 ContentSerializedNavigationBuilder::ToNavigationEntries(
75 navigations, browser->profile()); 80 navigations, browser->profile());
76 web_contents->SetUserAgentOverride(user_agent_override); 81 web_contents->SetUserAgentOverride(user_agent_override);
77 web_contents->GetController().Restore( 82 web_contents->GetController().Restore(
78 selected_navigation, GetRestoreType(browser, from_last_session), 83 selected_navigation, GetRestoreType(browser, from_last_session),
79 &entries); 84 &entries);
80 DCHECK_EQ(0u, entries.size()); 85 DCHECK_EQ(0u, entries.size());
81 86
82 return web_contents; 87 return web_contents;
83 } 88 }
84 89
85 } // namespace 90 } // namespace
86 91
87 content::WebContents* AddRestoredTab( 92 content::WebContents* AddRestoredTab(
88 Browser* browser, 93 Browser* browser,
89 const std::vector<SerializedNavigationEntry>& navigations, 94 const std::vector<SerializedNavigationEntry>& navigations,
90 int tab_index, 95 int tab_index,
91 int selected_navigation, 96 int selected_navigation,
92 const std::string& extension_app_id, 97 const std::string& extension_app_id,
93 bool select, 98 bool select,
94 bool pin, 99 bool pin,
95 bool from_last_session, 100 bool from_last_session,
96 content::SessionStorageNamespace* session_storage_namespace, 101 content::SessionStorageNamespace* session_storage_namespace,
97 const std::string& user_agent_override) { 102 const std::string& user_agent_override,
98 WebContents* web_contents = CreateRestoredTab(browser, 103 base::Optional<RestoreOrigin::Type> restore_origin_type) {
99 navigations, 104 WebContents* web_contents = CreateRestoredTab(
100 selected_navigation, 105 browser, navigations, selected_navigation, extension_app_id,
101 extension_app_id, 106 from_last_session, session_storage_namespace, user_agent_override,
102 from_last_session, 107 !select, restore_origin_type);
103 session_storage_namespace,
104 user_agent_override,
105 !select);
106 108
107 int add_types = select ? TabStripModel::ADD_ACTIVE 109 int add_types = select ? TabStripModel::ADD_ACTIVE
108 : TabStripModel::ADD_NONE; 110 : TabStripModel::ADD_NONE;
109 if (pin) { 111 if (pin) {
110 tab_index = std::min( 112 tab_index = std::min(
111 tab_index, browser->tab_strip_model()->IndexOfFirstNonPinnedTab()); 113 tab_index, browser->tab_strip_model()->IndexOfFirstNonPinnedTab());
112 add_types |= TabStripModel::ADD_PINNED; 114 add_types |= TabStripModel::ADD_PINNED;
113 } 115 }
114 browser->tab_strip_model()->InsertWebContentsAt(tab_index, web_contents, 116 browser->tab_strip_model()->InsertWebContentsAt(tab_index, web_contents,
115 add_types); 117 add_types);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 int insertion_index = tab_strip->active_index(); 162 int insertion_index = tab_strip->active_index();
161 tab_strip->InsertWebContentsAt(insertion_index + 1, 163 tab_strip->InsertWebContentsAt(insertion_index + 1,
162 web_contents, 164 web_contents,
163 TabStripModel::ADD_ACTIVE | 165 TabStripModel::ADD_ACTIVE |
164 TabStripModel::ADD_INHERIT_GROUP); 166 TabStripModel::ADD_INHERIT_GROUP);
165 tab_strip->CloseWebContentsAt(insertion_index, TabStripModel::CLOSE_NONE); 167 tab_strip->CloseWebContentsAt(insertion_index, TabStripModel::CLOSE_NONE);
166 return web_contents; 168 return web_contents;
167 } 169 }
168 170
169 } // namespace chrome 171 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698