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

Side by Side Diff: chrome/browser/extensions/extension_tab_util.cc

Issue 10697017: Tabs Extension: Implementation of tabs.duplicate api. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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/extensions/extension_tab_util.h" 5 #include "chrome/browser/extensions/extension_tab_util.h"
6 6
7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
8 #include "chrome/browser/extensions/tab_helper.h" 8 #include "chrome/browser/extensions/tab_helper.h"
9 #include "chrome/browser/extensions/window_controller.h" 9 #include "chrome/browser/extensions/window_controller.h"
10 #include "chrome/browser/net/url_fixer_upper.h" 10 #include "chrome/browser/net/url_fixer_upper.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 tab_list->Append(ExtensionTabUtil::CreateTabValue( 76 tab_list->Append(ExtensionTabUtil::CreateTabValue(
77 tab_strip->GetTabContentsAt(i)->web_contents(), tab_strip, i)); 77 tab_strip->GetTabContentsAt(i)->web_contents(), tab_strip, i));
78 } 78 }
79 79
80 return tab_list; 80 return tab_list;
81 } 81 }
82 82
83 DictionaryValue* ExtensionTabUtil::CreateTabValue(const WebContents* contents, 83 DictionaryValue* ExtensionTabUtil::CreateTabValue(const WebContents* contents,
84 TabStripModel* tab_strip, 84 TabStripModel* tab_strip,
85 int tab_index) { 85 int tab_index) {
86 return ExtensionTabUtil::CreateTabValue(contents, tab_strip, tab_index,
87 INCLUDE_PRIVACY_SENSITIVE_FIELDS);
88 }
89
90 DictionaryValue* ExtensionTabUtil::CreateTabValue(const WebContents* contents,
91 TabStripModel* tab_strip,
92 int tab_index,
93 PrivacyFlags flag) {
86 DictionaryValue* result = new DictionaryValue(); 94 DictionaryValue* result = new DictionaryValue();
87 bool is_loading = contents->IsLoading(); 95 bool is_loading = contents->IsLoading();
88 result->SetInteger(keys::kIdKey, ExtensionTabUtil::GetTabId(contents)); 96 result->SetInteger(keys::kIdKey, ExtensionTabUtil::GetTabId(contents));
89 result->SetInteger(keys::kIndexKey, tab_index); 97 result->SetInteger(keys::kIndexKey, tab_index);
90 result->SetInteger(keys::kWindowIdKey, 98 result->SetInteger(keys::kWindowIdKey,
91 ExtensionTabUtil::GetWindowIdOfTab(contents)); 99 ExtensionTabUtil::GetWindowIdOfTab(contents));
92 result->SetString(keys::kUrlKey, contents->GetURL().spec());
93 result->SetString(keys::kStatusKey, GetTabStatusText(is_loading)); 100 result->SetString(keys::kStatusKey, GetTabStatusText(is_loading));
94 result->SetBoolean(keys::kActiveKey, 101 result->SetBoolean(keys::kActiveKey,
95 tab_strip && tab_index == tab_strip->active_index()); 102 tab_strip && tab_index == tab_strip->active_index());
96 result->SetBoolean(keys::kSelectedKey, 103 result->SetBoolean(keys::kSelectedKey,
97 tab_strip && tab_index == tab_strip->active_index()); 104 tab_strip && tab_index == tab_strip->active_index());
98 result->SetBoolean(keys::kHighlightedKey, 105 result->SetBoolean(keys::kHighlightedKey,
99 tab_strip && tab_strip->IsTabSelected(tab_index)); 106 tab_strip && tab_strip->IsTabSelected(tab_index));
100 result->SetBoolean(keys::kPinnedKey, 107 result->SetBoolean(keys::kPinnedKey,
101 tab_strip && tab_strip->IsTabPinned(tab_index)); 108 tab_strip && tab_strip->IsTabPinned(tab_index));
102 result->SetString(keys::kTitleKey, contents->GetTitle());
103 result->SetBoolean(keys::kIncognitoKey, 109 result->SetBoolean(keys::kIncognitoKey,
104 contents->GetBrowserContext()->IsOffTheRecord()); 110 contents->GetBrowserContext()->IsOffTheRecord());
105 111
106 if (tab_strip) { 112 if (tab_strip) {
107 content::NavigationController* opener = 113 content::NavigationController* opener =
108 tab_strip->GetOpenerOfTabContentsAt(tab_index); 114 tab_strip->GetOpenerOfTabContentsAt(tab_index);
109 if (opener) { 115 if (opener) {
110 result->SetInteger(keys::kOpenerTabIdKey, 116 result->SetInteger(keys::kOpenerTabIdKey,
111 ExtensionTabUtil::GetTabId(opener->GetWebContents())); 117 ExtensionTabUtil::GetTabId(opener->GetWebContents()));
112 } 118 }
113 } 119 }
114 120 if (flag == INCLUDE_PRIVACY_SENSITIVE_FIELDS) {
115 if (!is_loading) { 121 result->SetString(keys::kUrlKey, contents->GetURL().spec());
116 NavigationEntry* entry = contents->GetController().GetActiveEntry(); 122 result->SetString(keys::kTitleKey, contents->GetTitle());
117 if (entry) { 123 if (!is_loading) {
118 if (entry->GetFavicon().valid) 124 NavigationEntry* entry = contents->GetController().GetActiveEntry();
119 result->SetString(keys::kFaviconUrlKey, entry->GetFavicon().url.spec()); 125 if (entry) {
126 if (entry->GetFavicon().valid)
127 result->SetString(keys::kFaviconUrlKey,
128 entry->GetFavicon().url.spec());
129 }
120 } 130 }
121 } 131 }
122 132
123 return result; 133 return result;
124 } 134 }
125 135
126 DictionaryValue* ExtensionTabUtil::CreateTabValueActive( 136 DictionaryValue* ExtensionTabUtil::CreateTabValueActive(
127 const WebContents* contents, 137 const WebContents* contents,
128 bool active) { 138 bool active) {
129 DictionaryValue* result = ExtensionTabUtil::CreateTabValue(contents); 139 DictionaryValue* result = ExtensionTabUtil::CreateTabValue(contents);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 273
264 // static 274 // static
265 extensions::WindowController* ExtensionTabUtil::GetWindowControllerOfTab( 275 extensions::WindowController* ExtensionTabUtil::GetWindowControllerOfTab(
266 const WebContents* web_contents) { 276 const WebContents* web_contents) {
267 Browser* browser = browser::FindBrowserWithWebContents(web_contents); 277 Browser* browser = browser::FindBrowserWithWebContents(web_contents);
268 if (browser != NULL) 278 if (browser != NULL)
269 return browser->extension_window_controller(); 279 return browser->extension_window_controller();
270 280
271 return NULL; 281 return NULL;
272 } 282 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698