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 #include "chrome/browser/ui/panels/panel.h" | 5 #include "chrome/browser/ui/panels/panel.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
| 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
12 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/devtools/devtools_window.h" | 17 #include "chrome/browser/devtools/devtools_window.h" |
16 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 18 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
17 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" | 19 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" |
18 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" | 20 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 namespace panel_internal { | 57 namespace panel_internal { |
56 | 58 |
57 class PanelExtensionWindowController : public extensions::WindowController { | 59 class PanelExtensionWindowController : public extensions::WindowController { |
58 public: | 60 public: |
59 PanelExtensionWindowController(Panel* panel, Profile* profile); | 61 PanelExtensionWindowController(Panel* panel, Profile* profile); |
60 ~PanelExtensionWindowController() override; | 62 ~PanelExtensionWindowController() override; |
61 | 63 |
62 // Overridden from extensions::WindowController. | 64 // Overridden from extensions::WindowController. |
63 int GetWindowId() const override; | 65 int GetWindowId() const override; |
64 std::string GetWindowTypeText() const override; | 66 std::string GetWindowTypeText() const override; |
65 base::DictionaryValue* CreateWindowValueWithTabs( | 67 std::unique_ptr<base::DictionaryValue> CreateWindowValueWithTabs( |
66 const extensions::Extension* extension) const override; | 68 const extensions::Extension* extension) const override; |
67 base::DictionaryValue* CreateTabValue(const extensions::Extension* extension, | 69 base::DictionaryValue* CreateTabValue(const extensions::Extension* extension, |
68 int tab_index) const override; | 70 int tab_index) const override; |
69 std::unique_ptr<extensions::api::tabs::Tab> CreateTabObject( | 71 std::unique_ptr<extensions::api::tabs::Tab> CreateTabObject( |
70 const extensions::Extension* extension, | 72 const extensions::Extension* extension, |
71 int tab_index) const override; | 73 int tab_index) const override; |
72 bool CanClose(Reason* reason) const override; | 74 bool CanClose(Reason* reason) const override; |
73 void SetFullscreenMode(bool is_fullscreen, | 75 void SetFullscreenMode(bool is_fullscreen, |
74 const GURL& extension_url) const override; | 76 const GURL& extension_url) const override; |
75 bool IsVisibleToExtension( | 77 bool IsVisibleToExtension( |
(...skipping 16 matching lines...) Expand all Loading... |
92 } | 94 } |
93 | 95 |
94 int PanelExtensionWindowController::GetWindowId() const { | 96 int PanelExtensionWindowController::GetWindowId() const { |
95 return static_cast<int>(panel_->session_id().id()); | 97 return static_cast<int>(panel_->session_id().id()); |
96 } | 98 } |
97 | 99 |
98 std::string PanelExtensionWindowController::GetWindowTypeText() const { | 100 std::string PanelExtensionWindowController::GetWindowTypeText() const { |
99 return extensions::tabs_constants::kWindowTypeValuePanel; | 101 return extensions::tabs_constants::kWindowTypeValuePanel; |
100 } | 102 } |
101 | 103 |
102 base::DictionaryValue* | 104 std::unique_ptr<base::DictionaryValue> |
103 PanelExtensionWindowController::CreateWindowValueWithTabs( | 105 PanelExtensionWindowController::CreateWindowValueWithTabs( |
104 const extensions::Extension* extension) const { | 106 const extensions::Extension* extension) const { |
105 base::DictionaryValue* result = CreateWindowValue(); | 107 std::unique_ptr<base::DictionaryValue> result = CreateWindowValue(); |
106 | 108 |
107 base::DictionaryValue* tab_value = CreateTabValue(extension, 0); | 109 base::DictionaryValue* tab_value = CreateTabValue(extension, 0); |
108 if (tab_value) { | 110 if (tab_value) { |
109 base::ListValue* tab_list = new base::ListValue(); | 111 base::ListValue* tab_list = new base::ListValue(); |
110 tab_list->Append(tab_value); | 112 tab_list->Append(tab_value); |
111 result->Set(extensions::tabs_constants::kTabsKey, tab_list); | 113 result->Set(extensions::tabs_constants::kTabsKey, tab_list); |
112 } | 114 } |
113 return result; | 115 return result; |
114 } | 116 } |
115 | 117 |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 // static | 906 // static |
905 void Panel::FormatTitleForDisplay(base::string16* title) { | 907 void Panel::FormatTitleForDisplay(base::string16* title) { |
906 size_t current_index = 0; | 908 size_t current_index = 0; |
907 size_t match_index; | 909 size_t match_index; |
908 while ((match_index = title->find(L'\n', current_index)) != | 910 while ((match_index = title->find(L'\n', current_index)) != |
909 base::string16::npos) { | 911 base::string16::npos) { |
910 title->replace(match_index, 1, base::string16()); | 912 title->replace(match_index, 1, base::string16()); |
911 current_index = match_index; | 913 current_index = match_index; |
912 } | 914 } |
913 } | 915 } |
OLD | NEW |