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

Unified Diff: chrome/browser/ui/panels/panel.cc

Issue 10900038: [Panel refactor]Populate window.tabs with web content info. (Closed) Base URL: svn://svn.chromium.org/chrome/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel.cc
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index ac995394bfeebeb01ec39b4da3c441bad5c0c070..af6adf1a705e6a1a7f1c3abbf8e156b4ed7e6462 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/extensions/window_controller_list.h"
#include "chrome/browser/extensions/window_event_router.h"
@@ -80,7 +81,41 @@ std::string PanelExtensionWindowController::GetWindowTypeText() const {
base::DictionaryValue*
PanelExtensionWindowController::CreateWindowValueWithTabs() const {
- return CreateWindowValue();
+ base::DictionaryValue* result = CreateWindowValue();
+
+ // Safe to include info about the web contents as this is only called
+ // by the extension that owns this window. See IsVisibleToExtension().
+ // TODO(jennb): DCHECK this after chebert's patch 10829186 lands.
+ content::WebContents* web_contents = panel_->GetWebContents();
+ if (web_contents) {
+ DictionaryValue* tab_value = new DictionaryValue();
+ // TabId must be >= 0. Use panel session id to avoid conflict with
+ // browser tab ids (which are also session ids).
+ tab_value->SetInteger(extensions::tabs_constants::kIdKey,
+ panel_->session_id().id());
+ tab_value->SetInteger(extensions::tabs_constants::kIndexKey, 0);
+ tab_value->SetInteger(
+ extensions::tabs_constants::kWindowIdKey, GetWindowId());
+ tab_value->SetString(
+ extensions::tabs_constants::kUrlKey, web_contents->GetURL().spec());
+ tab_value->SetString(extensions::tabs_constants::kStatusKey,
+ ExtensionTabUtil::GetTabStatusText(web_contents->IsLoading()));
+ tab_value->SetBoolean(
+ extensions::tabs_constants::kActiveKey, panel_->IsActive());
+ tab_value->SetBoolean(extensions::tabs_constants::kSelectedKey, true);
+ tab_value->SetBoolean(extensions::tabs_constants::kHighlightedKey, true);
+ tab_value->SetBoolean(extensions::tabs_constants::kPinnedKey, false);
+ tab_value->SetString(
+ extensions::tabs_constants::kTitleKey, web_contents->GetTitle());
+ tab_value->SetBoolean(
+ extensions::tabs_constants::kIncognitoKey,
+ web_contents->GetBrowserContext()->IsOffTheRecord());
+
+ base::ListValue* tab_list = new ListValue();
+ tab_list->Append(tab_value);
+ result->Set(extensions::tabs_constants::kTabsKey, tab_list);
+ }
+ return result;
}
bool PanelExtensionWindowController::CanClose(Reason* reason) const {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698