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

Side by Side 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, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/panels/panel.h" 5 #include "chrome/browser/ui/panels/panel.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_system.h" 13 #include "chrome/browser/extensions/extension_system.h"
14 #include "chrome/browser/extensions/extension_tab_util.h"
14 #include "chrome/browser/extensions/window_controller.h" 15 #include "chrome/browser/extensions/window_controller.h"
15 #include "chrome/browser/extensions/window_controller_list.h" 16 #include "chrome/browser/extensions/window_controller_list.h"
16 #include "chrome/browser/extensions/window_event_router.h" 17 #include "chrome/browser/extensions/window_event_router.h"
17 #include "chrome/browser/lifetime/application_lifetime.h" 18 #include "chrome/browser/lifetime/application_lifetime.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/themes/theme_service.h" 20 #include "chrome/browser/themes/theme_service.h"
20 #include "chrome/browser/themes/theme_service_factory.h" 21 #include "chrome/browser/themes/theme_service_factory.h"
21 #include "chrome/browser/ui/panels/native_panel.h" 22 #include "chrome/browser/ui/panels/native_panel.h"
22 #include "chrome/browser/ui/panels/panel_host.h" 23 #include "chrome/browser/ui/panels/panel_host.h"
23 #include "chrome/browser/ui/panels/panel_manager.h" 24 #include "chrome/browser/ui/panels/panel_manager.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 int PanelExtensionWindowController::GetWindowId() const { 74 int PanelExtensionWindowController::GetWindowId() const {
74 return static_cast<int>(panel_->session_id().id()); 75 return static_cast<int>(panel_->session_id().id());
75 } 76 }
76 77
77 std::string PanelExtensionWindowController::GetWindowTypeText() const { 78 std::string PanelExtensionWindowController::GetWindowTypeText() const {
78 return extensions::tabs_constants::kWindowTypeValuePanel; 79 return extensions::tabs_constants::kWindowTypeValuePanel;
79 } 80 }
80 81
81 base::DictionaryValue* 82 base::DictionaryValue*
82 PanelExtensionWindowController::CreateWindowValueWithTabs() const { 83 PanelExtensionWindowController::CreateWindowValueWithTabs() const {
83 return CreateWindowValue(); 84 base::DictionaryValue* result = CreateWindowValue();
85
86 // Safe to include info about the web contents as this is only called
87 // by the extension that owns this window. See IsVisibleToExtension().
88 // TODO(jennb): DCHECK this after chebert's patch 10829186 lands.
89 content::WebContents* web_contents = panel_->GetWebContents();
90 if (web_contents) {
91 DictionaryValue* tab_value = new DictionaryValue();
92 // TabId must be >= 0. Use panel session id to avoid conflict with
93 // browser tab ids (which are also session ids).
94 tab_value->SetInteger(extensions::tabs_constants::kIdKey,
95 panel_->session_id().id());
96 tab_value->SetInteger(extensions::tabs_constants::kIndexKey, 0);
97 tab_value->SetInteger(
98 extensions::tabs_constants::kWindowIdKey, GetWindowId());
99 tab_value->SetString(
100 extensions::tabs_constants::kUrlKey, web_contents->GetURL().spec());
101 tab_value->SetString(extensions::tabs_constants::kStatusKey,
102 ExtensionTabUtil::GetTabStatusText(web_contents->IsLoading()));
103 tab_value->SetBoolean(
104 extensions::tabs_constants::kActiveKey, panel_->IsActive());
105 tab_value->SetBoolean(extensions::tabs_constants::kSelectedKey, true);
106 tab_value->SetBoolean(extensions::tabs_constants::kHighlightedKey, true);
107 tab_value->SetBoolean(extensions::tabs_constants::kPinnedKey, false);
108 tab_value->SetString(
109 extensions::tabs_constants::kTitleKey, web_contents->GetTitle());
110 tab_value->SetBoolean(
111 extensions::tabs_constants::kIncognitoKey,
112 web_contents->GetBrowserContext()->IsOffTheRecord());
113
114 base::ListValue* tab_list = new ListValue();
115 tab_list->Append(tab_value);
116 result->Set(extensions::tabs_constants::kTabsKey, tab_list);
117 }
118 return result;
84 } 119 }
85 120
86 bool PanelExtensionWindowController::CanClose(Reason* reason) const { 121 bool PanelExtensionWindowController::CanClose(Reason* reason) const {
87 return true; 122 return true;
88 } 123 }
89 124
90 void PanelExtensionWindowController::SetFullscreenMode( 125 void PanelExtensionWindowController::SetFullscreenMode(
91 bool is_fullscreen, const GURL& extension_url) const { 126 bool is_fullscreen, const GURL& extension_url) const {
92 // Do nothing. Panels cannot be fullscreen. 127 // Do nothing. Panels cannot be fullscreen.
93 } 128 }
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 803
769 void Panel::LoadingStateChanged(bool is_loading) { 804 void Panel::LoadingStateChanged(bool is_loading) {
770 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); 805 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading);
771 native_panel_->UpdatePanelLoadingAnimations(is_loading); 806 native_panel_->UpdatePanelLoadingAnimations(is_loading);
772 UpdateTitleBar(); 807 UpdateTitleBar();
773 } 808 }
774 809
775 void Panel::WebContentsFocused(content::WebContents* contents) { 810 void Panel::WebContentsFocused(content::WebContents* contents) {
776 native_panel_->PanelWebContentsFocused(contents); 811 native_panel_->PanelWebContentsFocused(contents);
777 } 812 }
OLDNEW
« 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